Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: chrome/renderer/chrome_render_view_observer.cc

Issue 107893003: Make the renderer-side prerendering code use RenderFrames instead of RenderViews. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/chrome_render_view_observer.h" 5 #include "chrome/renderer/chrome_render_view_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/renderer/chrome_render_process_observer.h" 21 #include "chrome/renderer/chrome_render_process_observer.h"
22 #include "chrome/renderer/content_settings_observer.h" 22 #include "chrome/renderer/content_settings_observer.h"
23 #include "chrome/renderer/extensions/dispatcher.h" 23 #include "chrome/renderer/extensions/dispatcher.h"
24 #include "chrome/renderer/external_host_bindings.h" 24 #include "chrome/renderer/external_host_bindings.h"
25 #include "chrome/renderer/prerender/prerender_helper.h" 25 #include "chrome/renderer/prerender/prerender_helper.h"
26 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" 26 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h"
27 #include "chrome/renderer/translate/translate_helper.h" 27 #include "chrome/renderer/translate/translate_helper.h"
28 #include "chrome/renderer/webview_color_overlay.h" 28 #include "chrome/renderer/webview_color_overlay.h"
29 #include "content/public/common/bindings_policy.h" 29 #include "content/public/common/bindings_policy.h"
30 #include "content/public/renderer/content_renderer_client.h" 30 #include "content/public/renderer/content_renderer_client.h"
31 #include "content/public/renderer/render_frame.h"
31 #include "content/public/renderer/render_view.h" 32 #include "content/public/renderer/render_view.h"
32 #include "extensions/common/constants.h" 33 #include "extensions/common/constants.h"
33 #include "extensions/common/stack_frame.h" 34 #include "extensions/common/stack_frame.h"
34 #include "net/base/data_url.h" 35 #include "net/base/data_url.h"
35 #include "skia/ext/image_operations.h" 36 #include "skia/ext/image_operations.h"
36 #include "skia/ext/platform_canvas.h" 37 #include "skia/ext/platform_canvas.h"
37 #include "third_party/WebKit/public/platform/WebCString.h" 38 #include "third_party/WebKit/public/platform/WebCString.h"
38 #include "third_party/WebKit/public/platform/WebRect.h" 39 #include "third_party/WebKit/public/platform/WebRect.h"
39 #include "third_party/WebKit/public/platform/WebSize.h" 40 #include "third_party/WebKit/public/platform/WebSize.h"
40 #include "third_party/WebKit/public/platform/WebString.h" 41 #include "third_party/WebKit/public/platform/WebString.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 #if defined(OS_ANDROID) 316 #if defined(OS_ANDROID)
316 IPC_MESSAGE_HANDLER(ChromeViewMsg_UpdateTopControlsState, 317 IPC_MESSAGE_HANDLER(ChromeViewMsg_UpdateTopControlsState,
317 OnUpdateTopControlsState) 318 OnUpdateTopControlsState)
318 IPC_MESSAGE_HANDLER(ChromeViewMsg_RetrieveWebappInformation, 319 IPC_MESSAGE_HANDLER(ChromeViewMsg_RetrieveWebappInformation,
319 OnRetrieveWebappInformation) 320 OnRetrieveWebappInformation)
320 #endif 321 #endif
321 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetWindowFeatures, OnSetWindowFeatures) 322 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetWindowFeatures, OnSetWindowFeatures)
322 IPC_MESSAGE_UNHANDLED(handled = false) 323 IPC_MESSAGE_UNHANDLED(handled = false)
323 IPC_END_MESSAGE_MAP() 324 IPC_END_MESSAGE_MAP()
324 325
325 // Filter only.
326 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message)
327 IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering, OnSetIsPrerendering);
328 IPC_END_MESSAGE_MAP()
329
330 return handled; 326 return handled;
331 } 327 }
332 328
333 void ChromeRenderViewObserver::OnWebUIJavaScript( 329 void ChromeRenderViewObserver::OnWebUIJavaScript(
334 const base::string16& frame_xpath, 330 const base::string16& frame_xpath,
335 const base::string16& jscript, 331 const base::string16& jscript,
336 int id, 332 int id,
337 bool notify_result) { 333 bool notify_result) {
338 webui_javascript_.reset(new WebUIJavaScript()); 334 webui_javascript_.reset(new WebUIJavaScript());
339 webui_javascript_->frame_xpath = frame_xpath; 335 webui_javascript_->frame_xpath = frame_xpath;
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 } 752 }
757 753
758 void ChromeRenderViewObserver::didNotAllowPlugins(WebFrame* frame) { 754 void ChromeRenderViewObserver::didNotAllowPlugins(WebFrame* frame) {
759 content_settings_->DidNotAllowPlugins(); 755 content_settings_->DidNotAllowPlugins();
760 } 756 }
761 757
762 void ChromeRenderViewObserver::didNotAllowScript(WebFrame* frame) { 758 void ChromeRenderViewObserver::didNotAllowScript(WebFrame* frame) {
763 content_settings_->DidNotAllowScript(); 759 content_settings_->DidNotAllowScript();
764 } 760 }
765 761
766 void ChromeRenderViewObserver::OnSetIsPrerendering(bool is_prerendering) {
767 if (is_prerendering) {
768 DCHECK(!prerender::PrerenderHelper::Get(render_view()));
769 // The PrerenderHelper will destroy itself either after recording histograms
770 // or on destruction of the RenderView.
771 new prerender::PrerenderHelper(render_view());
772 }
773 }
774
775 void ChromeRenderViewObserver::DidStartLoading() { 762 void ChromeRenderViewObserver::DidStartLoading() {
776 if ((render_view()->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) && 763 if ((render_view()->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) &&
777 webui_javascript_.get()) { 764 webui_javascript_.get()) {
778 render_view()->EvaluateScript(webui_javascript_->frame_xpath, 765 render_view()->EvaluateScript(webui_javascript_->frame_xpath,
779 webui_javascript_->jscript, 766 webui_javascript_->jscript,
780 webui_javascript_->id, 767 webui_javascript_->id,
781 webui_javascript_->notify_result); 768 webui_javascript_->notify_result);
782 webui_javascript_.reset(); 769 webui_javascript_.reset();
783 } 770 }
784 } 771 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 if (main_frame->isViewSourceModeEnabled()) 858 if (main_frame->isViewSourceModeEnabled())
872 return; 859 return;
873 860
874 // Don't index/capture pages that failed to load. This only checks the top 861 // Don't index/capture pages that failed to load. This only checks the top
875 // level frame so the thumbnail may contain a frame that failed to load. 862 // level frame so the thumbnail may contain a frame that failed to load.
876 WebDataSource* ds = main_frame->dataSource(); 863 WebDataSource* ds = main_frame->dataSource();
877 if (ds && ds->hasUnreachableURL()) 864 if (ds && ds->hasUnreachableURL())
878 return; 865 return;
879 866
880 // Don't index/capture pages that are being prerendered. 867 // Don't index/capture pages that are being prerendered.
881 if (prerender::PrerenderHelper::IsPrerendering(render_view())) 868 if (prerender::PrerenderHelper::IsPrerendering(
869 render_view()->GetMainRenderFrame())) {
882 return; 870 return;
871 }
883 872
884 // Retrieve the frame's full text (up to kMaxIndexChars), and pass it to the 873 // Retrieve the frame's full text (up to kMaxIndexChars), and pass it to the
885 // translate helper for language detection and possible translation. 874 // translate helper for language detection and possible translation.
886 base::string16 contents; 875 base::string16 contents;
887 base::TimeTicks capture_begin_time = base::TimeTicks::Now(); 876 base::TimeTicks capture_begin_time = base::TimeTicks::Now();
888 CaptureText(main_frame, &contents); 877 CaptureText(main_frame, &contents);
889 UMA_HISTOGRAM_TIMES(kTranslateCaptureText, 878 UMA_HISTOGRAM_TIMES(kTranslateCaptureText,
890 base::TimeTicks::Now() - capture_begin_time); 879 base::TimeTicks::Now() - capture_begin_time);
891 if (translate_helper_) 880 if (translate_helper_)
892 translate_helper_->PageCaptured(page_id, contents); 881 translate_helper_->PageCaptured(page_id, contents);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 WebElement element = node.to<WebElement>(); 992 WebElement element = node.to<WebElement>();
1004 if (!element.hasTagName(tag_name)) 993 if (!element.hasTagName(tag_name))
1005 continue; 994 continue;
1006 WebString value = element.getAttribute(attribute_name); 995 WebString value = element.getAttribute(attribute_name);
1007 if (value.isNull() || !LowerCaseEqualsASCII(value, "refresh")) 996 if (value.isNull() || !LowerCaseEqualsASCII(value, "refresh"))
1008 continue; 997 continue;
1009 return true; 998 return true;
1010 } 999 }
1011 return false; 1000 return false;
1012 } 1001 }
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_view_observer.h ('k') | chrome/renderer/plugins/chrome_plugin_placeholder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698