| 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 "chrome/browser/dom_operation_notification_details.h" | 7 #include "chrome/browser/dom_operation_notification_details.h" |
| 8 #include "chrome/browser/net/predictor_api.h" |
| 8 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
| 10 #include "content/browser/renderer_host/render_view_host.h" |
| 11 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 9 #include "content/common/notification_service.h" | 12 #include "content/common/notification_service.h" |
| 13 #include "content/common/url_constants.h" |
| 10 #include "content/common/view_messages.h" | 14 #include "content/common/view_messages.h" |
| 11 | 15 |
| 12 ChromeRenderViewHostObserver::ChromeRenderViewHostObserver( | 16 ChromeRenderViewHostObserver::ChromeRenderViewHostObserver( |
| 13 RenderViewHost* render_view_host) | 17 RenderViewHost* render_view_host) |
| 14 : RenderViewHostObserver(render_view_host) { | 18 : RenderViewHostObserver(render_view_host) { |
| 15 } | 19 } |
| 16 | 20 |
| 17 ChromeRenderViewHostObserver::~ChromeRenderViewHostObserver() { | 21 ChromeRenderViewHostObserver::~ChromeRenderViewHostObserver() { |
| 18 } | 22 } |
| 19 | 23 |
| 24 void ChromeRenderViewHostObserver::Navigate( |
| 25 const ViewMsg_Navigate_Params& params) { |
| 26 const GURL& url = params.url; |
| 27 if (!render_view_host()->delegate()->IsExternalTabContainer() && |
| 28 (url.SchemeIs(chrome::kHttpScheme) || url.SchemeIs(chrome::kHttpsScheme))) |
| 29 chrome_browser_net::PreconnectUrlAndSubresources(url); |
| 30 } |
| 31 |
| 20 bool ChromeRenderViewHostObserver::OnMessageReceived( | 32 bool ChromeRenderViewHostObserver::OnMessageReceived( |
| 21 const IPC::Message& message) { | 33 const IPC::Message& message) { |
| 22 bool handled = true; | 34 bool handled = true; |
| 23 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewHostObserver, message) | 35 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewHostObserver, message) |
| 24 IPC_MESSAGE_HANDLER(ViewHostMsg_DomOperationResponse, | 36 IPC_MESSAGE_HANDLER(ViewHostMsg_DomOperationResponse, |
| 25 OnDomOperationResponse) | 37 OnDomOperationResponse) |
| 26 IPC_MESSAGE_UNHANDLED(handled = false) | 38 IPC_MESSAGE_UNHANDLED(handled = false) |
| 27 IPC_END_MESSAGE_MAP() | 39 IPC_END_MESSAGE_MAP() |
| 28 return handled; | 40 return handled; |
| 29 } | 41 } |
| 30 | 42 |
| 31 void ChromeRenderViewHostObserver::OnDomOperationResponse( | 43 void ChromeRenderViewHostObserver::OnDomOperationResponse( |
| 32 const std::string& json_string, int automation_id) { | 44 const std::string& json_string, int automation_id) { |
| 33 DomOperationNotificationDetails details(json_string, automation_id); | 45 DomOperationNotificationDetails details(json_string, automation_id); |
| 34 NotificationService::current()->Notify( | 46 NotificationService::current()->Notify( |
| 35 NotificationType::DOM_OPERATION_RESPONSE, | 47 NotificationType::DOM_OPERATION_RESPONSE, |
| 36 Source<RenderViewHost>(render_view_host()), | 48 Source<RenderViewHost>(render_view_host()), |
| 37 Details<DomOperationNotificationDetails>(&details)); | 49 Details<DomOperationNotificationDetails>(&details)); |
| 38 } | 50 } |
| OLD | NEW |