Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/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 "base/utf_string_conversions.h" | |
| 8 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/net/predictor.h" | 10 #include "chrome/browser/net/predictor.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/simple_message_box.h" | |
| 11 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
| 12 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/extensions/extension_messages.h" | 15 #include "chrome/common/extensions/extension_messages.h" |
| 14 #include "chrome/common/render_messages.h" | 16 #include "chrome/common/render_messages.h" |
| 15 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 16 #include "content/public/browser/child_process_security_policy.h" | 18 #include "content/public/browser/child_process_security_policy.h" |
| 17 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 18 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
| 19 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/render_view_host_delegate.h" | 22 #include "content/public/browser/render_view_host_delegate.h" |
| 23 #include "content/public/browser/render_widget_host_view.h" | |
| 21 #include "content/public/browser/site_instance.h" | 24 #include "content/public/browser/site_instance.h" |
| 25 #include "grit/generated_resources.h" | |
| 26 #include "ui/base/l10n/l10n_util.h" | |
| 22 | 27 |
| 23 using content::ChildProcessSecurityPolicy; | 28 using content::ChildProcessSecurityPolicy; |
| 24 using content::RenderViewHost; | 29 using content::RenderViewHost; |
| 25 using content::SiteInstance; | 30 using content::SiteInstance; |
| 26 | 31 |
| 27 ChromeRenderViewHostObserver::ChromeRenderViewHostObserver( | 32 ChromeRenderViewHostObserver::ChromeRenderViewHostObserver( |
| 28 RenderViewHost* render_view_host, chrome_browser_net::Predictor* predictor) | 33 RenderViewHost* render_view_host, chrome_browser_net::Predictor* predictor) |
| 29 : content::RenderViewHostObserver(render_view_host), | 34 : content::RenderViewHostObserver(render_view_host), |
| 30 predictor_(predictor) { | 35 predictor_(predictor) { |
| 31 SiteInstance* site_instance = render_view_host->GetSiteInstance(); | 36 SiteInstance* site_instance = render_view_host->GetSiteInstance(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 (url.SchemeIs(chrome::kHttpScheme) || url.SchemeIs(chrome::kHttpsScheme))) | 68 (url.SchemeIs(chrome::kHttpScheme) || url.SchemeIs(chrome::kHttpsScheme))) |
| 64 predictor_->PreconnectUrlAndSubresources(url); | 69 predictor_->PreconnectUrlAndSubresources(url); |
| 65 } | 70 } |
| 66 | 71 |
| 67 bool ChromeRenderViewHostObserver::OnMessageReceived( | 72 bool ChromeRenderViewHostObserver::OnMessageReceived( |
| 68 const IPC::Message& message) { | 73 const IPC::Message& message) { |
| 69 bool handled = true; | 74 bool handled = true; |
| 70 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewHostObserver, message) | 75 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewHostObserver, message) |
| 71 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusedEditableNodeTouched, | 76 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusedEditableNodeTouched, |
| 72 OnFocusedEditableNodeTouched) | 77 OnFocusedEditableNodeTouched) |
| 78 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_GetTalkPermission, | |
| 79 OnGetTalkPermission) | |
| 73 IPC_MESSAGE_UNHANDLED(handled = false) | 80 IPC_MESSAGE_UNHANDLED(handled = false) |
| 74 IPC_END_MESSAGE_MAP() | 81 IPC_END_MESSAGE_MAP() |
| 75 return handled; | 82 return handled; |
| 76 } | 83 } |
| 77 | 84 |
| 78 void ChromeRenderViewHostObserver::InitRenderViewHostForExtensions() { | 85 void ChromeRenderViewHostObserver::InitRenderViewHostForExtensions() { |
| 79 const Extension* extension = GetExtension(); | 86 const Extension* extension = GetExtension(); |
| 80 if (!extension) | 87 if (!extension) |
| 81 return; | 88 return; |
| 82 | 89 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 if (process_manager) | 177 if (process_manager) |
| 171 process_manager->UnregisterRenderViewHost(rvh); | 178 process_manager->UnregisterRenderViewHost(rvh); |
| 172 } | 179 } |
| 173 | 180 |
| 174 void ChromeRenderViewHostObserver::OnFocusedEditableNodeTouched() { | 181 void ChromeRenderViewHostObserver::OnFocusedEditableNodeTouched() { |
| 175 content::NotificationService::current()->Notify( | 182 content::NotificationService::current()->Notify( |
| 176 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, | 183 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, |
| 177 content::Source<RenderViewHost>(render_view_host()), | 184 content::Source<RenderViewHost>(render_view_host()), |
| 178 content::NotificationService::NoDetails()); | 185 content::NotificationService::NoDetails()); |
| 179 } | 186 } |
| 187 | |
| 188 void ChromeRenderViewHostObserver::OnGetTalkPermission( | |
| 189 const ppapi::HostResource& resource) { | |
| 190 #if defined(USE_AURA) | |
| 191 string16 title = l10n_util::GetStringUTF16( | |
| 192 IDS_GTALK_SCREEN_SHARE_DIALOG_TITLE); | |
| 193 string16 message = l10n_util::GetStringUTF16( | |
| 194 IDS_GTALK_SCREEN_SHARE_DIALOG_MESSAGE); | |
| 195 int32_t result = browser::ShowYesNoBox( | |
| 196 render_view_host()->GetView()->GetNativeView(), title, message); | |
| 197 | |
| 198 Send(new ChromeViewMsg_GetTalkPermissionACK( | |
|
jam
2012/03/15 02:05:26
what you're doing here is basically a sync IPC, so
brettw
2012/03/15 17:44:32
I talked to John and we can keep this async. I thi
varunjain
2012/03/15 17:54:15
Done.
varunjain
2012/03/15 17:54:15
reverted to async
| |
| 199 render_view_host()->GetRoutingID(), resource, result)); | |
| 200 #endif | |
| 201 } | |
| OLD | NEW |