Commit message: None
CVE: None
Vulnerability description: None

Project: Chrome

void AutoFillHelper::FrameWillClose(WebFrame* frame) {
   form_manager_.ResetFrame(frame);
 }

Project: Chrome

void RenderView::AcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window,
                                                int32 width,
                                                int32 height,
                                                uint64 io_surface_identifier) {
  Send(new ViewHostMsg_AcceleratedSurfaceSetIOSurface(
      routing_id(), window, width, height, io_surface_identifier));
}

Project: Chrome

void RenderView::AddGURLSearchProvider(const GURL& osd_url, bool autodetected) {
  if (!osd_url.is_empty())
    Send(new ViewHostMsg_PageHasOSDD(routing_id_, page_id_, osd_url,
                                     autodetected));
}

Project: Chrome

void RenderView::AddSearchProvider(const std::string& url) {
  AddGURLSearchProvider(GURL(url),
                        false);  // not autodetected
}

Project: Chrome

void RenderView::CapturePageInfo(int load_id, bool preliminary_capture) {
  if (load_id != page_id_)
    return;  // this capture call is no longer relevant due to navigation
  if (load_id == last_indexed_page_id_)
    return;  // we already indexed this page

  if (!webview())
    return;

  WebFrame* main_frame = webview()->mainFrame();
  if (!main_frame)
    return;

  if (main_frame->isViewSourceModeEnabled())
    return;

  WebDataSource* ds = main_frame->dataSource();
  if (ds && ds->hasUnreachableURL())
    return;

  if (!preliminary_capture)
    last_indexed_page_id_ = load_id;

  GURL url(main_frame->url());
  if (url.is_empty())
    return;

  string16 contents;
  CaptureText(main_frame, &contents);
  if (contents.size()) {
    base::TimeTicks begin_time = base::TimeTicks::Now();
    std::string language = DetermineTextLanguage(contents);
    UMA_HISTOGRAM_MEDIUM_TIMES("Renderer4.LanguageDetection",
                               base::TimeTicks::Now() - begin_time);
    WebKit::WebDocument document = main_frame->document();
    Send(new ViewHostMsg_PageContents(routing_id_, url, load_id, contents,
                                      language, IsPageTranslatable(&document)));
  }

  OnCaptureThumbnail();
}

Project: Chrome

void RenderView::ExecuteCodeImpl(WebFrame* frame,
                                 const ViewMsg_ExecuteCode_Params& params) {
  GURL frame_url = GURL(frame->url());
  if (frame_url.host() == GURL(Extension::ChromeStoreURL()).host()
      && !CommandLine::ForCurrentProcess()->HasSwitch(
          switches::kAllowScriptingGallery)) {
    Send(new ViewMsg_ExecuteCodeFinished(routing_id_, params.request_id, true));
    return;
  }

  std::vector<WebFrame*> frame_vector;
  frame_vector.push_back(frame);
  if (params.all_frames)
    GetAllChildFrames(frame, &frame_vector);

  for (std::vector<WebFrame*>::iterator frame_it = frame_vector.begin();
       frame_it != frame_vector.end(); ++frame_it) {
    WebFrame* frame = *frame_it;
    if (params.is_javascript) {
      if (!UrlMatchesPermissions(frame->url(), params.host_permissions))
        continue;

      std::vector<WebScriptSource> sources;
      sources.push_back(
          WebScriptSource(WebString::fromUTF8(params.code)));
      UserScriptSlave::InsertInitExtensionCode(&sources, params.extension_id);
      frame->executeScriptInIsolatedWorld(
          UserScriptSlave::GetIsolatedWorldId(params.extension_id),
          &sources.front(), sources.size(), EXTENSION_GROUP_CONTENT_SCRIPTS);
    } else {
      frame->insertStyleText(WebString::fromUTF8(params.code), WebString());
    }
  }

  Send(new ViewMsg_ExecuteCodeFinished(routing_id_, params.request_id, true));
}

Project: Chrome

WebFrame* RenderView::GetChildFrame(const std::wstring& xpath) const {
  if (xpath.empty())
    return webview()->mainFrame();


  WebFrame* frame = webview()->mainFrame();

  std::wstring xpath_remaining = xpath;
  while (!xpath_remaining.empty()) {
    std::wstring::size_type delim_pos = xpath_remaining.find_first_of(L'\n');
    std::wstring xpath_child;
    if (delim_pos != std::wstring::npos) {
      xpath_child = xpath_remaining.substr(0, delim_pos);
      xpath_remaining.erase(0, delim_pos + 1);
    } else {
      xpath_remaining.swap(xpath_child);
    }
    frame = frame->findChildByExpression(WideToUTF16Hack(xpath_child));
  }

  return frame;
}

Project: Chrome

WebCookieJar* RenderView::GetCookieJar() {
  return &cookie_jar_;
}

Project: Chrome

void RenderView::InsertCSS(const std::wstring& frame_xpath,
                           const std::string& css,
                           const std::string& id) {
  WebFrame* web_frame = GetChildFrame(frame_xpath);
  if (!web_frame)
    return;

  web_frame->insertStyleText(WebString::fromUTF8(css), WebString::fromUTF8(id));
}

Project: Chrome

void RenderView::OnAllowBindings(int enabled_bindings_flags) {
  enabled_bindings_ |= enabled_bindings_flags;
}

Project: Chrome

void RenderView::OnClosePage(const ViewMsg_ClosePage_Params& params) {
  WebFrame* main_frame = webview()->mainFrame();
  if (main_frame) {
    const GURL& url = main_frame->url();
    if (url.SchemeIs(chrome::kHttpScheme) ||
        url.SchemeIs(chrome::kHttpsScheme))
      DumpLoadHistograms();
  }
  webview()->dispatchUnloadEvent();

  cross_origin_access_count_ = 0;
  same_origin_access_count_ = 0;

  Send(new ViewHostMsg_ClosePage_ACK(routing_id_, params));
}

Project: Chrome

void RenderView::OnExecuteCode(const ViewMsg_ExecuteCode_Params& params) {
  WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL;
  if (!main_frame) {
    Send(new ViewMsg_ExecuteCodeFinished(routing_id_, params.request_id,
                                         false));
    return;
  }

  WebDataSource* ds = main_frame->dataSource();
  NavigationState* navigation_state = NavigationState::FromDataSource(ds);
  if (!navigation_state->user_script_idle_scheduler()->has_run()) {
    pending_code_execution_queue_.push(
        linked_ptr<ViewMsg_ExecuteCode_Params>(
            new ViewMsg_ExecuteCode_Params(params)));
    return;
  }

  ExecuteCodeImpl(main_frame, params);
}

Project: Chrome

void RenderView::OnLoadBlockedPlugins() {
  NotificationService::current()->Notify(NotificationType::SHOULD_LOAD_PLUGINS,
                                         Source<RenderView>(this),
                                         NotificationService::NoDetails());
}

Project: Chrome

void RenderView::OnPaste() {
  if (!webview())
    return;

  webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Paste"));
  UserMetricsRecordAction("Paste");
}

Project: Chrome

void RenderView::OnResetPageEncodingToDefault() {
  WebString no_encoding;
  webview()->setPageEncoding(no_encoding);
}

Project: Chrome

void RenderView::OnScriptEvalRequest(const std::wstring& frame_xpath,
                                     const std::wstring& jscript) {
  EvaluateScript(frame_xpath, jscript);
}

Project: Chrome

void RenderView::OnUserScriptIdleTriggered(WebFrame* frame) {
  if (RenderThread::current()) {  // Will be NULL during unit tests.
    RenderThread::current()->user_script_slave()->InjectScripts(
        frame, UserScript::DOCUMENT_IDLE);
  }

  WebFrame* main_frame = webview()->mainFrame();
  if (frame == main_frame) {
    while (!pending_code_execution_queue_.empty()) {
      linked_ptr<ViewMsg_ExecuteCode_Params>& params =
          pending_code_execution_queue_.front();
      ExecuteCodeImpl(main_frame, *params);
      pending_code_execution_queue_.pop();
    }
  }
}

Project: Chrome

void RenderView::OnWasRestored(bool needs_repainting) {
  RenderWidget::OnWasRestored(needs_repainting);

  std::set<WebPluginDelegateProxy*>::iterator plugin_it;
  for (plugin_it = plugin_delegates_.begin();
       plugin_it != plugin_delegates_.end(); ++plugin_it) {
    (*plugin_it)->SetContainerVisibility(true);
  }
}

Project: Chrome

void RenderView::SendExtensionRequest(const std::string& name,
                                      const ListValue& args,
                                      const GURL& source_url,
                                      int request_id,
                                      bool has_callback) {
  Send(new ViewHostMsg_ExtensionRequest(routing_id_,
                                        name,
                                        args,
                                        source_url,
                                        request_id,
                                        has_callback));
}

Project: Chrome

void RenderView::UpdateEncoding(WebFrame* frame,
                                const std::string& encoding_name) {
  if (webview()->mainFrame() == frame &&
      last_encoding_name_ != encoding_name) {
    last_encoding_name_ = encoding_name;

    Send(new ViewHostMsg_UpdateEncoding(routing_id_, last_encoding_name_));
  }
}

Project: Chrome

void RenderView::UpdateTargetURL(const GURL& url, const GURL& fallback_url) {
  GURL latest_url = url.is_empty() ? fallback_url : url;
  if (latest_url == target_url_)
    return;

  if (target_url_status_ == TARGET_INFLIGHT ||
      target_url_status_ == TARGET_PENDING) {
    pending_target_url_ = latest_url;
    target_url_status_ = TARGET_PENDING;
  } else {
    Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, latest_url));
    target_url_ = latest_url;
    target_url_status_ = TARGET_INFLIGHT;
  }
}

Project: Chrome

void RenderView::UserMetricsRecordAction(const std::string& action) {
  Send(new ViewHostMsg_UserMetricsRecordAction(routing_id_, action));
}

Project: Chrome

bool RenderView::allowPlugins(WebFrame* frame, bool enabled_per_settings) {
  if (CommandLine::ForCurrentProcess()->HasSwitch(
      switches::kEnableClickToPlay)) {
    return WebFrameClient::allowPlugins(frame, enabled_per_settings);
  }
  return (enabled_per_settings &&
      AllowContentType(CONTENT_SETTINGS_TYPE_PLUGINS));
}

Project: Chrome

WebURLError RenderView::cannotHandleRequestError(
    WebFrame* frame, const WebURLRequest& request) {
  NOTREACHED();  // Since we said we can handle all requests.
  return WebURLError();
}

Project: Chrome

WebWidget* RenderView::createPopupMenu(const WebPopupMenuInfo& info) {
  RenderWidget* widget = RenderWidget::Create(routing_id_,
                                              render_thread_,
                                              WebKit::WebPopupTypeSelect);
  widget->ConfigureAsExternalPopupMenu(info);
  return widget->webwidget();
}

Project: Chrome

void RenderView::didFailLoad(WebFrame* frame, const WebURLError& error) {
}

Project: Chrome

void RenderView::didFailProvisionalLoad(WebFrame* frame,
                                        const WebURLError& error) {
  WebDataSource* ds = frame->provisionalDataSource();
  DCHECK(ds);

  const WebURLRequest& failed_request = ds->request();

  bool show_repost_interstitial =
      (error.reason == net::ERR_CACHE_MISS &&
       EqualsASCII(failed_request.httpMethod(), "POST"));
  Send(new ViewHostMsg_DidFailProvisionalLoadWithError(
      routing_id_, !frame->parent(), error.reason, error.unreachableURL,
      show_repost_interstitial));

  if (error.reason == net::ERR_ABORTED)
    return;

  frame->enableViewSourceMode(false);

  NavigationState* navigation_state = NavigationState::FromDataSource(ds);

  bool replace =
      navigation_state->pending_page_id() != -1 ||
      navigation_state->transition_type() == PageTransition::AUTO_SUBFRAME;

  if (!navigation_state->is_content_initiated()) {
    pending_navigation_state_.reset(NavigationState::CreateBrowserInitiated(
        navigation_state->pending_page_id(),
        navigation_state->pending_history_list_offset(),
        navigation_state->transition_type(),
        navigation_state->request_time()));
  }

  if (MaybeLoadAlternateErrorPage(frame, error, replace))
    return;

  LoadNavigationErrorPage(frame, failed_request, error, std::string(),
                          replace);
}

Project: Chrome

void RenderView::didFinishResourceLoad(
    WebFrame* frame, unsigned identifier) {
  NavigationState* navigation_state =
      NavigationState::FromDataSource(frame->dataSource());
  if (!navigation_state->postpone_loading_data())
    return;


  const GURL& frame_url = frame->url();

  const GURL& error_page_url = GetAlternateErrorPageURL(frame_url, HTTP_404);
  DCHECK(error_page_url.is_valid());

  WebURLError original_error;
  original_error.unreachableURL = frame_url;

  navigation_state->set_alt_error_page_fetcher(
      new AltErrorPageResourceFetcher(
          error_page_url, frame, original_error,
          NewCallback(this, &RenderView::AltErrorPageFinished)));
}

Project: Chrome

void RenderView::didStartLoading() {
  if (is_loading_) {
    DLOG(WARNING) << "didStartLoading called while loading";
    return;
  }

  is_loading_ = true;
  first_default_plugin_.reset();

  Send(new ViewHostMsg_DidStartLoading(routing_id_));
}

Project: Chrome

void RenderView::exitFullscreenForNode(const WebKit::WebNode& node) {
  NOTIMPLEMENTED();
}

Project: Chrome

void RenderView::printPage(WebFrame* frame) {
  DCHECK(frame);
  Print(frame, true);
}

Project: Chrome

void RenderView::showSpellingUI(bool show) {
  Send(new ViewHostMsg_ShowSpellingPanel(routing_id_, show));
}

Project: Chrome

void RenderView::spellCheck(const WebString& text,
                            int& misspelled_offset,
                            int& misspelled_length) {
  EnsureDocumentTag();

  string16 word(text);
  RenderThread* thread = RenderThread::current();
  if (thread) {
    thread->spellchecker()->SpellCheckWord(
        word.c_str(), word.size(), document_tag_,
        &misspelled_offset, &misspelled_length, NULL);
  }
}

Project: Chrome

bool RenderView::supportsFullscreen() {
  return CommandLine::ForCurrentProcess()->HasSwitch(
      switches::kEnableVideoFullscreen);
}

Project: Chrome

void RenderView::willSubmitForm(WebFrame* frame, const WebFormElement& form) {
  NavigationState* navigation_state =
      NavigationState::FromDataSource(frame->provisionalDataSource());

  if (navigation_state->transition_type() == PageTransition::LINK)
    navigation_state->set_transition_type(PageTransition::FORM_SUBMIT);

  WebSearchableFormData web_searchable_form_data(form);
  navigation_state->set_searchable_form_url(web_searchable_form_data.url());
  navigation_state->set_searchable_form_encoding(
      web_searchable_form_data.encoding().utf8());
  PasswordForm* password_form_data =
      PasswordFormDomManager::CreatePasswordForm(form);
  navigation_state->set_password_form_data(password_form_data);

  if (password_form_data && password_form_data->password_value.empty()) {
    NavigationState* old_navigation_state =
        NavigationState::FromDataSource(frame->dataSource());
    if (old_navigation_state) {
      PasswordForm* old_form_data = old_navigation_state->password_form_data();
      if (old_form_data && old_form_data->action == password_form_data->action)
        password_form_data->password_value = old_form_data->password_value;
    }
  }

  FormData form_data;
  if (FormManager::WebFormElementToFormData(
          form, FormManager::REQUIRE_AUTOCOMPLETE, true, &form_data))
    Send(new ViewHostMsg_FormSubmitted(routing_id_, form_data));
}