Commit message: None
CVE: None
Vulnerability description: None

Project: Chrome

void InterstitialPage::CancelForNavigation() {
  Disable();
  if (new_navigation_)
    TakeActionOnResourceDispatcher(RESUME);
  else
    TakeActionOnResourceDispatcher(CANCEL);
}

Project: Chrome

void InterstitialPage::InterstitialPageRVHViewDelegate::CreateNewWidget(
    int route_id, bool activatable) {
  NOTREACHED() << "InterstitialPage does not support showing drop-downs yet.";
}

Project: Chrome

void InterstitialPage::InterstitialPageRVHViewDelegate::CreateNewWindow(
    int route_id) {
  NOTREACHED() << "InterstitialPage does not support showing popups yet.";
}

Project: Chrome

RenderViewHost* InterstitialPage::CreateRenderViewHost() {
  RenderViewHost* render_view_host = new RenderViewHost(
      SiteInstance::CreateSiteInstance(tab()->profile()),
      this, MSG_ROUTING_NONE, kInvalidSessionStorageNamespaceId);
  return render_view_host;
}

Project: Chrome

TabContentsView* InterstitialPage::CreateTabContentsView() {
  TabContentsView* tab_contents_view = tab()->view();
  RenderWidgetHostView* view =
      tab_contents_view->CreateViewForWidget(render_view_host_);
  render_view_host_->set_view(view);
  render_view_host_->AllowBindings(BindingsPolicy::DOM_AUTOMATION);

  scoped_refptr<URLRequestContextGetter> request_context =
      tab()->request_context();
  if (!request_context.get())
    request_context = tab()->profile()->GetRequestContext();

  render_view_host_->CreateRenderView(request_context.get());
  view->SetSize(tab_contents_view->GetContainerSize());
  view->Hide();
  return tab_contents_view;
}

Project: Chrome

void InterstitialPage::DidNavigate(
    RenderViewHost* render_view_host,
    const ViewHostMsg_FrameNavigate_Params& params) {
  if (!enabled_) {
    DontProceed();
    return;
  }

  render_view_host_->view()->Show();
  tab_->set_interstitial_page(this);

  RenderWidgetHostView* rwh_view = tab_->render_view_host()->view();

  if (rwh_view) {
    if (rwh_view->HasFocus())
      Focus();

    rwh_view->Hide();
  }

  tab_->SetIsLoading(false, NULL);
}

Project: Chrome

void InterstitialPage::Disable() {
  enabled_ = false;
}

Project: Chrome

void InterstitialPage::DomOperationResponse(const std::string& json_string,
                                            int automation_id) {
  if (enabled_)
    CommandReceived(json_string);
}

Project: Chrome

void InterstitialPage::Focus() {
  render_view_host_->view()->Focus();
}

Project: Chrome

void InterstitialPage::FocusThroughTabTraversal(bool reverse) {
  render_view_host_->SetInitialFocus(reverse);
}

Project: Chrome

int InterstitialPage::GetBrowserWindowID() const {
  return tab_->GetBrowserWindowID();
}

Project: Chrome

InterstitialPage* InterstitialPage::GetInterstitialPage(
    TabContents* tab_contents) {
  InitInterstitialPageMap();
  InterstitialPageMap::const_iterator iter =
      tab_to_interstitial_page_->find(tab_contents);
  if (iter == tab_to_interstitial_page_->end())
    return NULL;

  return iter->second;
}

Project: Chrome

const GURL& InterstitialPage::GetURL() const {
  return url_;
}

Project: Chrome

RenderViewHostDelegate::View* InterstitialPage::GetViewDelegate() {
  return rvh_view_delegate_.get();
}

Project: Chrome

void InterstitialPage::InterstitialPageRVHViewDelegate::GotFocus() {
}

Project: Chrome

void InterstitialPage::InterstitialPageRVHViewDelegate::HandleKeyboardEvent(
    const NativeWebKeyboardEvent& event) {
  if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate())
    interstitial_page_->tab()->GetViewDelegate()->HandleKeyboardEvent(event);
}

Project: Chrome

void InterstitialPage::Hide() {
  RenderWidgetHostView* old_view = tab_->render_view_host()->view();
  if (old_view) {
    old_view->Show();
  }

  if (render_view_host_->view() && render_view_host_->view()->HasFocus() &&
      tab_->render_view_host()->view()) {
    tab_->render_view_host()->view()->Focus();
  }

  render_view_host_->Shutdown();
  render_view_host_ = NULL;
  if (tab_->interstitial_page())
    tab_->remove_interstitial_page();
  NavigationEntry* entry = tab_->controller().GetActiveEntry();
  if (!new_navigation_ && should_revert_tab_title_) {
    entry->set_title(WideToUTF16Hack(original_tab_title_));
    tab_->NotifyNavigationStateChanged(TabContents::INVALIDATE_TITLE);
  }
  delete this;
}

Project: Chrome

void InterstitialPage::InitInterstitialPageMap() {
  if (!tab_to_interstitial_page_)
    tab_to_interstitial_page_ = new InterstitialPageMap;
}

Project: Chrome

InterstitialPage::InterstitialPage(TabContents* tab,
                                   bool new_navigation,
                                   const GURL& url)
    : tab_(tab),
      url_(url),
      new_navigation_(new_navigation),
      should_discard_pending_nav_entry_(new_navigation),
      enabled_(true),
      action_taken_(NO_ACTION),
      render_view_host_(NULL),
      original_child_id_(tab->render_view_host()->process()->id()),
      original_rvh_id_(tab->render_view_host()->routing_id()),
      should_revert_tab_title_(false),
      resource_dispatcher_host_notified_(false),
      ALLOW_THIS_IN_INITIALIZER_LIST(rvh_view_delegate_(
          new InterstitialPageRVHViewDelegate(this))) {
  renderer_preferences_util::UpdateFromSystemSettings(
      &renderer_preferences_, tab_->profile());

  InitInterstitialPageMap();
  DCHECK(new_navigation || !tab->controller().pending_entry());
}

Project: Chrome

void InterstitialPage::InterstitialPageRVHViewDelegate::OnFindReply(
    int request_id, int number_of_matches, const gfx::Rect& selection_rect,
    int active_match_ordinal, bool final_update) {
}

Project: Chrome

bool InterstitialPage::InterstitialPageRVHViewDelegate::PreHandleKeyboardEvent(
    const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) {
  if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate())
    return interstitial_page_->tab()->GetViewDelegate()->PreHandleKeyboardEvent(
        event, is_keyboard_shortcut);
  return false;
}

Project: Chrome

void InterstitialPage::Proceed() {
  if (action_taken_ != NO_ACTION) {
    NOTREACHED();
    return;
  }
  Disable();
  action_taken_ = PROCEED_ACTION;

  tab_->SetIsLoading(true, NULL);

  if (new_navigation_)
    TakeActionOnResourceDispatcher(CANCEL);
  else
    TakeActionOnResourceDispatcher(RESUME);

  if (!new_navigation_) {
    Hide();
  }
}

Project: Chrome

void InterstitialPage::RenderViewGone(RenderViewHost* render_view_host) {
  DontProceed();
}

Project: Chrome

  ResourceRequestTask(int process_id,
                      int render_view_host_id,
                      ResourceRequestAction action)
      : action_(action),
        process_id_(process_id),
        render_view_host_id_(render_view_host_id),
        resource_dispatcher_host_(
            g_browser_process->resource_dispatcher_host()) {
  }

Project: Chrome

  virtual void Run() {
    switch (action_) {
      case BLOCK:
        resource_dispatcher_host_->BlockRequestsForRoute(
            process_id_, render_view_host_id_);
        break;
      case RESUME:
        resource_dispatcher_host_->ResumeBlockedRequestsForRoute(
            process_id_, render_view_host_id_);
        break;
      case CANCEL:
        resource_dispatcher_host_->CancelBlockedRequestsForRoute(
            process_id_, render_view_host_id_);
        break;
      default:
        NOTREACHED();
    }
  }

Project: Chrome

void InterstitialPage::Show() {
  if (tab_->interstitial_page()) {
    if (tab_->interstitial_page()->action_taken_ != NO_ACTION) {
      tab_->interstitial_page()->Hide();
    } else {
      if (new_navigation_ && tab_->interstitial_page()->new_navigation_)
        tab_->interstitial_page()->should_discard_pending_nav_entry_= false;
      tab_->interstitial_page()->DontProceed();
    }
  }

  TakeActionOnResourceDispatcher(BLOCK);
  notification_registrar_.Add(
      this, NotificationType::RENDER_WIDGET_HOST_DESTROYED,
      Source<RenderWidgetHost>(tab_->render_view_host()));

  InterstitialPageMap::const_iterator iter =
      tab_to_interstitial_page_->find(tab_);
  DCHECK(iter == tab_to_interstitial_page_->end());
  (*tab_to_interstitial_page_)[tab_] = this;

  if (new_navigation_) {
    NavigationEntry* entry = new NavigationEntry;
    entry->set_url(url_);
    entry->set_virtual_url(url_);
    entry->set_page_type(NavigationEntry::INTERSTITIAL_PAGE);

    UpdateEntry(entry);

    tab_->controller().AddTransientEntry(entry);
  }

  DCHECK(!render_view_host_);
  render_view_host_ = CreateRenderViewHost();
  CreateTabContentsView();

  std::string data_url = "data:text/html;charset=utf-8," +
                         EscapePath(GetHTMLContents());
  render_view_host_->NavigateToURL(GURL(data_url));

  notification_registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED,
                              Source<TabContents>(tab_));
  notification_registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
      Source<NavigationController>(&tab_->controller()));
  notification_registrar_.Add(this, NotificationType::NAV_ENTRY_PENDING,
      Source<NavigationController>(&tab_->controller()));
}

Project: Chrome

void InterstitialPage::InterstitialPageRVHViewDelegate::ShowContextMenu(
    const ContextMenuParams& params) {
}

Project: Chrome

void InterstitialPage::InterstitialPageRVHViewDelegate::StartDragging(
    const WebDropData& drop_data,
    WebDragOperationsMask allowed_operations,
    const SkBitmap& image,
    const gfx::Point& image_offset) {
  NOTREACHED() << "InterstitialPage does not support dragging yet.";
}

Project: Chrome

void InterstitialPage::TakeActionOnResourceDispatcher(
    ResourceRequestAction action) {
  DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)) <<
      "TakeActionOnResourceDispatcher should be called on the main thread.";

  if (action == CANCEL || action == RESUME) {
    if (resource_dispatcher_host_notified_)
      return;
    resource_dispatcher_host_notified_ = true;
  }

  RenderViewHost* rvh = RenderViewHost::FromID(original_child_id_,
                                               original_rvh_id_);
  if (!rvh || !g_browser_process->resource_dispatcher_host())
    return;

  ChromeThread::PostTask(
      ChromeThread::IO, FROM_HERE,
      new ResourceRequestTask(original_child_id_, original_rvh_id_, action));
}

Project: Chrome

void InterstitialPage::InterstitialPageRVHViewDelegate::UpdateDragCursor(
    WebDragOperation) {
  NOTREACHED() << "InterstitialPage does not support dragging yet.";
}

Project: Chrome

void InterstitialPage::InterstitialPageRVHViewDelegate::UpdatePreferredSize(
    const gfx::Size& pref_size) {
}

Project: Chrome

void InterstitialPage::UpdateTitle(RenderViewHost* render_view_host,
                                   int32 page_id,
                                   const std::wstring& title) {
  DCHECK(render_view_host == render_view_host_);
  NavigationEntry* entry = tab_->controller().GetActiveEntry();
  if (!entry) {
    NOTREACHED();
    return;
  }

  if (!new_navigation_ && !should_revert_tab_title_) {
    original_tab_title_ = UTF16ToWideHack(entry->title());
    should_revert_tab_title_ = true;
  }
  entry->set_title(WideToUTF16Hack(title));
  tab_->NotifyNavigationStateChanged(TabContents::INVALIDATE_TITLE);
}

Project: Chrome

InterstitialPage::~InterstitialPage() {
  InterstitialPageMap::iterator iter = tab_to_interstitial_page_->find(tab_);
  DCHECK(iter != tab_to_interstitial_page_->end()) <<
      "InterstitialPage missing from map. Please add a comment to the bug "
      "http://crbug.com/9442 with the URL you were visiting";
  if (iter != tab_to_interstitial_page_->end())
    tab_to_interstitial_page_->erase(iter);
  DCHECK(!render_view_host_);
}