| OLD | NEW |
| 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 "chrome/browser/renderer_host/chrome_render_view_host_observer.h" | 5 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/dom_operation_notification_details.h" | 8 #include "chrome/browser/dom_operation_notification_details.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/net/predictor_api.h" | 10 #include "chrome/browser/net/predictor.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/extensions/extension_messages.h" | 14 #include "chrome/common/extensions/extension_messages.h" |
| 15 #include "chrome/common/render_messages.h" | 15 #include "chrome/common/render_messages.h" |
| 16 #include "content/browser/browsing_instance.h" | 16 #include "content/browser/browsing_instance.h" |
| 17 #include "content/browser/child_process_security_policy.h" | 17 #include "content/browser/child_process_security_policy.h" |
| 18 #include "content/browser/renderer_host/render_view_host_delegate.h" | 18 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 19 #include "content/browser/renderer_host/render_view_host.h" | 19 #include "content/browser/renderer_host/render_view_host.h" |
| 20 #include "content/browser/site_instance.h" | 20 #include "content/browser/site_instance.h" |
| 21 #include "content/common/bindings_policy.h" | 21 #include "content/common/bindings_policy.h" |
| 22 #include "content/common/notification_service.h" | 22 #include "content/common/notification_service.h" |
| 23 #include "content/common/url_constants.h" | 23 #include "content/common/url_constants.h" |
| 24 #include "content/common/view_messages.h" | 24 #include "content/common/view_messages.h" |
| 25 | 25 |
| 26 ChromeRenderViewHostObserver::ChromeRenderViewHostObserver( | 26 ChromeRenderViewHostObserver::ChromeRenderViewHostObserver( |
| 27 RenderViewHost* render_view_host) | 27 RenderViewHost* render_view_host, chrome_browser_net::Predictor* predictor) |
| 28 : RenderViewHostObserver(render_view_host) { | 28 : RenderViewHostObserver(render_view_host), |
| 29 predictor_(predictor) { |
| 29 InitRenderViewHostForExtensions(); | 30 InitRenderViewHostForExtensions(); |
| 30 } | 31 } |
| 31 | 32 |
| 32 ChromeRenderViewHostObserver::~ChromeRenderViewHostObserver() { | 33 ChromeRenderViewHostObserver::~ChromeRenderViewHostObserver() { |
| 33 } | 34 } |
| 34 | 35 |
| 35 void ChromeRenderViewHostObserver::RenderViewHostInitialized() { | 36 void ChromeRenderViewHostObserver::RenderViewHostInitialized() { |
| 36 InitRenderViewForExtensions(); | 37 InitRenderViewForExtensions(); |
| 37 } | 38 } |
| 38 | 39 |
| 39 void ChromeRenderViewHostObserver::Navigate( | 40 void ChromeRenderViewHostObserver::Navigate( |
| 40 const ViewMsg_Navigate_Params& params) { | 41 const ViewMsg_Navigate_Params& params) { |
| 41 const GURL& url = params.url; | 42 const GURL& url = params.url; |
| 43 if (!predictor_) |
| 44 return; |
| 42 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeFrame) && | 45 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeFrame) && |
| 43 (url.SchemeIs(chrome::kHttpScheme) || url.SchemeIs(chrome::kHttpsScheme))) | 46 (url.SchemeIs(chrome::kHttpScheme) || url.SchemeIs(chrome::kHttpsScheme))) |
| 44 chrome_browser_net::PreconnectUrlAndSubresources(url); | 47 predictor_->PreconnectUrlAndSubresources(url); |
| 45 } | 48 } |
| 46 | 49 |
| 47 bool ChromeRenderViewHostObserver::OnMessageReceived( | 50 bool ChromeRenderViewHostObserver::OnMessageReceived( |
| 48 const IPC::Message& message) { | 51 const IPC::Message& message) { |
| 49 bool handled = true; | 52 bool handled = true; |
| 50 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewHostObserver, message) | 53 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewHostObserver, message) |
| 51 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DomOperationResponse, | 54 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DomOperationResponse, |
| 52 OnDomOperationResponse) | 55 OnDomOperationResponse) |
| 53 IPC_MESSAGE_UNHANDLED(handled = false) | 56 IPC_MESSAGE_UNHANDLED(handled = false) |
| 54 IPC_END_MESSAGE_MAP() | 57 IPC_END_MESSAGE_MAP() |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 } | 158 } |
| 156 | 159 |
| 157 void ChromeRenderViewHostObserver::OnDomOperationResponse( | 160 void ChromeRenderViewHostObserver::OnDomOperationResponse( |
| 158 const std::string& json_string, int automation_id) { | 161 const std::string& json_string, int automation_id) { |
| 159 DomOperationNotificationDetails details(json_string, automation_id); | 162 DomOperationNotificationDetails details(json_string, automation_id); |
| 160 NotificationService::current()->Notify( | 163 NotificationService::current()->Notify( |
| 161 chrome::NOTIFICATION_DOM_OPERATION_RESPONSE, | 164 chrome::NOTIFICATION_DOM_OPERATION_RESPONSE, |
| 162 Source<RenderViewHost>(render_view_host()), | 165 Source<RenderViewHost>(render_view_host()), |
| 163 Details<DomOperationNotificationDetails>(&details)); | 166 Details<DomOperationNotificationDetails>(&details)); |
| 164 } | 167 } |
| OLD | NEW |