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

Side by Side Diff: content/renderer/render_view.cc

Issue 6765011: Move the dispatching of extension messages out of RenderThread. This also moves a bunch of exten... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 months 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
« no previous file with comments | « content/renderer/render_process_observer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/renderer/render_view.h" 5 #include "content/renderer/render_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 30 matching lines...) Expand all
41 #include "chrome/common/url_constants.h" 41 #include "chrome/common/url_constants.h"
42 #include "chrome/common/web_apps.h" 42 #include "chrome/common/web_apps.h"
43 #include "chrome/renderer/about_handler.h" 43 #include "chrome/renderer/about_handler.h"
44 #include "chrome/renderer/autofill/autofill_agent.h" 44 #include "chrome/renderer/autofill/autofill_agent.h"
45 #include "chrome/renderer/autofill/form_manager.h" 45 #include "chrome/renderer/autofill/form_manager.h"
46 #include "chrome/renderer/autofill/password_autofill_manager.h" 46 #include "chrome/renderer/autofill/password_autofill_manager.h"
47 #include "chrome/renderer/automation/dom_automation_controller.h" 47 #include "chrome/renderer/automation/dom_automation_controller.h"
48 #include "chrome/renderer/devtools_agent.h" 48 #include "chrome/renderer/devtools_agent.h"
49 #include "chrome/renderer/devtools_client.h" 49 #include "chrome/renderer/devtools_client.h"
50 #include "chrome/renderer/extension_groups.h" 50 #include "chrome/renderer/extension_groups.h"
51 #include "chrome/renderer/extensions/bindings_utils.h"
52 #include "chrome/renderer/extensions/event_bindings.h" 51 #include "chrome/renderer/extensions/event_bindings.h"
52 #include "chrome/renderer/extensions/extension_dispatcher.h"
53 #include "chrome/renderer/extensions/extension_helper.h" 53 #include "chrome/renderer/extensions/extension_helper.h"
54 #include "chrome/renderer/extensions/extension_process_bindings.h" 54 #include "chrome/renderer/extensions/extension_process_bindings.h"
55 #include "chrome/renderer/extensions/extension_resource_request_policy.h" 55 #include "chrome/renderer/extensions/extension_resource_request_policy.h"
56 #include "chrome/renderer/extensions/renderer_extension_bindings.h" 56 #include "chrome/renderer/extensions/renderer_extension_bindings.h"
57 #include "chrome/renderer/external_host_bindings.h" 57 #include "chrome/renderer/external_host_bindings.h"
58 #include "chrome/renderer/localized_error.h" 58 #include "chrome/renderer/localized_error.h"
59 #include "chrome/renderer/page_click_tracker.h" 59 #include "chrome/renderer/page_click_tracker.h"
60 #include "chrome/renderer/page_load_histograms.h" 60 #include "chrome/renderer/page_load_histograms.h"
61 #include "chrome/renderer/print_web_view_helper.h" 61 #include "chrome/renderer/print_web_view_helper.h"
62 #include "chrome/renderer/render_process.h" 62 #include "chrome/renderer/render_process.h"
(...skipping 2504 matching lines...) Expand 10 before | Expand all | Expand 10 after
2567 // created RenderView (i.e., as a constrained popup or as a new tab). 2567 // created RenderView (i.e., as a constrained popup or as a new tab).
2568 // 2568 //
2569 void RenderView::show(WebNavigationPolicy policy) { 2569 void RenderView::show(WebNavigationPolicy policy) {
2570 DCHECK(!did_show_) << "received extraneous Show call"; 2570 DCHECK(!did_show_) << "received extraneous Show call";
2571 DCHECK(opener_id_ != MSG_ROUTING_NONE); 2571 DCHECK(opener_id_ != MSG_ROUTING_NONE);
2572 2572
2573 if (did_show_) 2573 if (did_show_)
2574 return; 2574 return;
2575 did_show_ = true; 2575 did_show_ = true;
2576 2576
2577 // Extensions and apps always allowed to create unrequested popups. The second 2577 if (content::GetContentClient()->renderer()->AllowPopup(creator_url_))
2578 // check is necessary to include content scripts.
2579 if (render_thread_->GetExtensions()->GetByURL(creator_url_) ||
2580 bindings_utils::GetInfoForCurrentContext()) {
2581 opened_by_user_gesture_ = true; 2578 opened_by_user_gesture_ = true;
2582 }
2583 2579
2584 // Force new windows to a popup if they were not opened with a user gesture. 2580 // Force new windows to a popup if they were not opened with a user gesture.
2585 if (!opened_by_user_gesture_) { 2581 if (!opened_by_user_gesture_) {
2586 // We exempt background tabs for compat with older versions of Chrome. 2582 // We exempt background tabs for compat with older versions of Chrome.
2587 // TODO(darin): This seems bogus. These should have a user gesture, so 2583 // TODO(darin): This seems bogus. These should have a user gesture, so
2588 // we probably don't need this check. 2584 // we probably don't need this check.
2589 if (policy != WebKit::WebNavigationPolicyNewBackgroundTab) 2585 if (policy != WebKit::WebNavigationPolicyNewBackgroundTab)
2590 policy = WebKit::WebNavigationPolicyNewPopup; 2586 policy = WebKit::WebNavigationPolicyNewPopup;
2591 } 2587 }
2592 2588
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2824 // If the navigation would cross an app extent boundary, we also need 2820 // If the navigation would cross an app extent boundary, we also need
2825 // to defer to the browser to ensure process isolation. 2821 // to defer to the browser to ensure process isolation.
2826 // TODO(erikkay) This is happening inside of a check to is_content_initiated 2822 // TODO(erikkay) This is happening inside of a check to is_content_initiated
2827 // which means that things like the back button won't trigger it. Is that 2823 // which means that things like the back button won't trigger it. Is that
2828 // OK? 2824 // OK?
2829 // TODO(creis): For hosted apps, we currently only swap processes to enter 2825 // TODO(creis): For hosted apps, we currently only swap processes to enter
2830 // the app and not exit it, since we currently lose context (e.g., 2826 // the app and not exit it, since we currently lose context (e.g.,
2831 // window.opener) if the window navigates back. See crbug.com/65953. 2827 // window.opener) if the window navigates back. See crbug.com/65953.
2832 if (!should_fork && 2828 if (!should_fork &&
2833 CrossesExtensionExtents( 2829 CrossesExtensionExtents(
2834 render_thread_->GetExtensions(), 2830 ExtensionDispatcher::Get()->extensions(), frame, url)) {
2835 frame,
2836 url)) {
2837 // Include the referrer in this case since we're going from a hosted web 2831 // Include the referrer in this case since we're going from a hosted web
2838 // page. (the packaged case is handled previously by the extension 2832 // page. (the packaged case is handled previously by the extension
2839 // navigation test) 2833 // navigation test)
2840 should_fork = true; 2834 should_fork = true;
2841 send_referrer = true; 2835 send_referrer = true;
2842 2836
2843 if (is_content_initiated) { 2837 if (is_content_initiated) {
2844 const Extension* extension = 2838 const Extension* extension =
2845 render_thread_->GetExtensions()->GetByURL(url); 2839 ExtensionDispatcher::Get()->extensions()->GetByURL(url);
2846 if (extension && extension->is_app()) { 2840 if (extension && extension->is_app()) {
2847 UMA_HISTOGRAM_ENUMERATION( 2841 UMA_HISTOGRAM_ENUMERATION(
2848 extension_misc::kAppLaunchHistogram, 2842 extension_misc::kAppLaunchHistogram,
2849 extension_misc::APP_LAUNCH_CONTENT_NAVIGATION, 2843 extension_misc::APP_LAUNCH_CONTENT_NAVIGATION,
2850 extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); 2844 extension_misc::APP_LAUNCH_BUCKET_BOUNDARY);
2851 } 2845 }
2852 } 2846 }
2853 } 2847 }
2854 2848
2855 if (should_fork) { 2849 if (should_fork) {
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
3301 } 3295 }
3302 if (BindingsPolicy::is_external_host_enabled(enabled_bindings_)) { 3296 if (BindingsPolicy::is_external_host_enabled(enabled_bindings_)) {
3303 GetExternalHostBindings()->set_message_sender(this); 3297 GetExternalHostBindings()->set_message_sender(this);
3304 GetExternalHostBindings()->set_routing_id(routing_id_); 3298 GetExternalHostBindings()->set_routing_id(routing_id_);
3305 GetExternalHostBindings()->BindToJavascript(frame, "externalHost"); 3299 GetExternalHostBindings()->BindToJavascript(frame, "externalHost");
3306 } 3300 }
3307 } 3301 }
3308 3302
3309 void RenderView::didCreateDocumentElement(WebFrame* frame) { 3303 void RenderView::didCreateDocumentElement(WebFrame* frame) {
3310 if (RenderThread::current()) { // Will be NULL during unit tests. 3304 if (RenderThread::current()) { // Will be NULL during unit tests.
3311 RenderThread::current()->user_script_slave()->InjectScripts( 3305 ExtensionDispatcher::Get()->user_script_slave()->InjectScripts(
3312 frame, UserScript::DOCUMENT_START); 3306 frame, UserScript::DOCUMENT_START);
3313 } 3307 }
3314 3308
3315 // Notify the browser about non-blank documents loading in the top frame. 3309 // Notify the browser about non-blank documents loading in the top frame.
3316 GURL url = frame->url(); 3310 GURL url = frame->url();
3317 if (url.is_valid() && url.spec() != chrome::kAboutBlankURL) { 3311 if (url.is_valid() && url.spec() != chrome::kAboutBlankURL) {
3318 if (frame == webview()->mainFrame()) 3312 if (frame == webview()->mainFrame())
3319 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); 3313 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_));
3320 } 3314 }
3321 } 3315 }
(...skipping 22 matching lines...) Expand all
3344 3338
3345 Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_, frame->identifier())); 3339 Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_, frame->identifier()));
3346 3340
3347 FOR_EACH_OBSERVER(RenderViewObserver, observers_, 3341 FOR_EACH_OBSERVER(RenderViewObserver, observers_,
3348 DidFinishDocumentLoad(frame)); 3342 DidFinishDocumentLoad(frame));
3349 3343
3350 // Check whether we have new encoding name. 3344 // Check whether we have new encoding name.
3351 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); 3345 UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
3352 3346
3353 if (RenderThread::current()) { // Will be NULL during unit tests. 3347 if (RenderThread::current()) { // Will be NULL during unit tests.
3354 RenderThread::current()->user_script_slave()->InjectScripts( 3348 ExtensionDispatcher::Get()->user_script_slave()->InjectScripts(
3355 frame, UserScript::DOCUMENT_END); 3349 frame, UserScript::DOCUMENT_END);
3356 } 3350 }
3357 3351
3358 // InjectScripts() can end up creating a new NavigationState if it triggers a 3352 // InjectScripts() can end up creating a new NavigationState if it triggers a
3359 // fragment navigation, so we need to re-fetch it here. 3353 // fragment navigation, so we need to re-fetch it here.
3360 navigation_state = NavigationState::FromDataSource(ds); 3354 navigation_state = NavigationState::FromDataSource(ds);
3361 navigation_state->user_script_idle_scheduler()->DidFinishDocumentLoad(); 3355 navigation_state->user_script_idle_scheduler()->DidFinishDocumentLoad();
3362 } 3356 }
3363 3357
3364 void RenderView::OnUserScriptIdleTriggered(WebFrame* frame) { 3358 void RenderView::OnUserScriptIdleTriggered(WebFrame* frame) {
3365 if (RenderThread::current()) { // Will be NULL during unit tests. 3359 if (RenderThread::current()) { // Will be NULL during unit tests.
3366 RenderThread::current()->user_script_slave()->InjectScripts( 3360 ExtensionDispatcher::Get()->user_script_slave()->InjectScripts(
3367 frame, UserScript::DOCUMENT_IDLE); 3361 frame, UserScript::DOCUMENT_IDLE);
3368 } 3362 }
3369 3363
3370 WebFrame* main_frame = webview()->mainFrame(); 3364 WebFrame* main_frame = webview()->mainFrame();
3371 if (frame == main_frame) { 3365 if (frame == main_frame) {
3372 while (!pending_code_execution_queue_.empty()) { 3366 while (!pending_code_execution_queue_.empty()) {
3373 linked_ptr<ExtensionMsg_ExecuteCode_Params>& params = 3367 linked_ptr<ExtensionMsg_ExecuteCode_Params>& params =
3374 pending_code_execution_queue_.front(); 3368 pending_code_execution_queue_.front();
3375 ExecuteCodeImpl(main_frame, *params); 3369 ExecuteCodeImpl(main_frame, *params);
3376 pending_code_execution_queue_.pop(); 3370 pending_code_execution_queue_.pop();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
3442 provisional_data_source ? provisional_data_source : top_data_source; 3436 provisional_data_source ? provisional_data_source : top_data_source;
3443 3437
3444 // If the request is for an extension resource, check whether it should be 3438 // If the request is for an extension resource, check whether it should be
3445 // allowed. If not allowed, we reset the URL to something invalid to prevent 3439 // allowed. If not allowed, we reset the URL to something invalid to prevent
3446 // the request and cause an error. 3440 // the request and cause an error.
3447 GURL request_url(request.url()); 3441 GURL request_url(request.url());
3448 if (request_url.SchemeIs(chrome::kExtensionScheme) && 3442 if (request_url.SchemeIs(chrome::kExtensionScheme) &&
3449 !ExtensionResourceRequestPolicy::CanRequestResource( 3443 !ExtensionResourceRequestPolicy::CanRequestResource(
3450 request_url, 3444 request_url,
3451 GURL(frame->url()), 3445 GURL(frame->url()),
3452 render_thread_->GetExtensions())) { 3446 ExtensionDispatcher::Get()->extensions())) {
3453 request.setURL(WebURL(GURL("chrome-extension://invalid/"))); 3447 request.setURL(WebURL(GURL("chrome-extension://invalid/")));
3454 } 3448 }
3455 3449
3456 if (data_source) { 3450 if (data_source) {
3457 NavigationState* state = NavigationState::FromDataSource(data_source); 3451 NavigationState* state = NavigationState::FromDataSource(data_source);
3458 if (state && state->is_cache_policy_override_set()) 3452 if (state && state->is_cache_policy_override_set())
3459 request.setCachePolicy(state->cache_policy_override()); 3453 request.setCachePolicy(state->cache_policy_override());
3460 } 3454 }
3461 3455
3462 if (top_data_source) { 3456 if (top_data_source) {
(...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after
4987 std::vector<WebFrame*> frame_vector; 4981 std::vector<WebFrame*> frame_vector;
4988 frame_vector.push_back(frame); 4982 frame_vector.push_back(frame);
4989 if (params.all_frames) 4983 if (params.all_frames)
4990 GetAllChildFrames(frame, &frame_vector); 4984 GetAllChildFrames(frame, &frame_vector);
4991 4985
4992 for (std::vector<WebFrame*>::iterator frame_it = frame_vector.begin(); 4986 for (std::vector<WebFrame*>::iterator frame_it = frame_vector.begin();
4993 frame_it != frame_vector.end(); ++frame_it) { 4987 frame_it != frame_vector.end(); ++frame_it) {
4994 WebFrame* frame = *frame_it; 4988 WebFrame* frame = *frame_it;
4995 if (params.is_javascript) { 4989 if (params.is_javascript) {
4996 const Extension* extension = 4990 const Extension* extension =
4997 render_thread_->GetExtensions()->GetByID(params.extension_id); 4991 ExtensionDispatcher::Get()->extensions()->GetByID(
4992 params.extension_id);
4998 4993
4999 // Since extension info is sent separately from user script info, they can 4994 // Since extension info is sent separately from user script info, they can
5000 // be out of sync. We just ignore this situation. 4995 // be out of sync. We just ignore this situation.
5001 if (!extension) 4996 if (!extension)
5002 continue; 4997 continue;
5003 4998
5004 if (!extension->CanExecuteScriptOnPage(frame->url(), NULL, NULL)) 4999 if (!extension->CanExecuteScriptOnPage(frame->url(), NULL, NULL))
5005 continue; 5000 continue;
5006 5001
5007 std::vector<WebScriptSource> sources; 5002 std::vector<WebScriptSource> sources;
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
5374 const webkit_glue::CustomContextMenuContext& custom_context) { 5369 const webkit_glue::CustomContextMenuContext& custom_context) {
5375 if (custom_context.is_pepper_menu) 5370 if (custom_context.is_pepper_menu)
5376 pepper_delegate_.OnContextMenuClosed(custom_context); 5371 pepper_delegate_.OnContextMenuClosed(custom_context);
5377 else 5372 else
5378 context_menu_node_.reset(); 5373 context_menu_node_.reset();
5379 } 5374 }
5380 5375
5381 void RenderView::OnNetworkStateChanged(bool online) { 5376 void RenderView::OnNetworkStateChanged(bool online) {
5382 WebNetworkStateNotifier::setOnLine(online); 5377 WebNetworkStateNotifier::setOnLine(online);
5383 } 5378 }
OLDNEW
« no previous file with comments | « content/renderer/render_process_observer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698