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" |
| 22 | 25 |
| 23 using content::ChildProcessSecurityPolicy; | 26 using content::ChildProcessSecurityPolicy; |
| 24 using content::RenderViewHost; | 27 using content::RenderViewHost; |
| 25 using content::SiteInstance; | 28 using content::SiteInstance; |
| 26 | 29 |
| 27 ChromeRenderViewHostObserver::ChromeRenderViewHostObserver( | 30 ChromeRenderViewHostObserver::ChromeRenderViewHostObserver( |
| 28 RenderViewHost* render_view_host, chrome_browser_net::Predictor* predictor) | 31 RenderViewHost* render_view_host, chrome_browser_net::Predictor* predictor) |
| 29 : content::RenderViewHostObserver(render_view_host), | 32 : content::RenderViewHostObserver(render_view_host), |
| 30 predictor_(predictor) { | 33 predictor_(predictor) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 (url.SchemeIs(chrome::kHttpScheme) || url.SchemeIs(chrome::kHttpsScheme))) | 66 (url.SchemeIs(chrome::kHttpScheme) || url.SchemeIs(chrome::kHttpsScheme))) |
| 64 predictor_->PreconnectUrlAndSubresources(url); | 67 predictor_->PreconnectUrlAndSubresources(url); |
| 65 } | 68 } |
| 66 | 69 |
| 67 bool ChromeRenderViewHostObserver::OnMessageReceived( | 70 bool ChromeRenderViewHostObserver::OnMessageReceived( |
| 68 const IPC::Message& message) { | 71 const IPC::Message& message) { |
| 69 bool handled = true; | 72 bool handled = true; |
| 70 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewHostObserver, message) | 73 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewHostObserver, message) |
| 71 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusedEditableNodeTouched, | 74 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusedEditableNodeTouched, |
| 72 OnFocusedEditableNodeTouched) | 75 OnFocusedEditableNodeTouched) |
| 76 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_GetTalkPermission, | |
| 77 OnGetTalkPermission) | |
| 73 IPC_MESSAGE_UNHANDLED(handled = false) | 78 IPC_MESSAGE_UNHANDLED(handled = false) |
| 74 IPC_END_MESSAGE_MAP() | 79 IPC_END_MESSAGE_MAP() |
| 75 return handled; | 80 return handled; |
| 76 } | 81 } |
| 77 | 82 |
| 78 void ChromeRenderViewHostObserver::InitRenderViewHostForExtensions() { | 83 void ChromeRenderViewHostObserver::InitRenderViewHostForExtensions() { |
| 79 const Extension* extension = GetExtension(); | 84 const Extension* extension = GetExtension(); |
| 80 if (!extension) | 85 if (!extension) |
| 81 return; | 86 return; |
| 82 | 87 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 if (process_manager) | 175 if (process_manager) |
| 171 process_manager->UnregisterRenderViewHost(rvh); | 176 process_manager->UnregisterRenderViewHost(rvh); |
| 172 } | 177 } |
| 173 | 178 |
| 174 void ChromeRenderViewHostObserver::OnFocusedEditableNodeTouched() { | 179 void ChromeRenderViewHostObserver::OnFocusedEditableNodeTouched() { |
| 175 content::NotificationService::current()->Notify( | 180 content::NotificationService::current()->Notify( |
| 176 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, | 181 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, |
| 177 content::Source<RenderViewHost>(render_view_host()), | 182 content::Source<RenderViewHost>(render_view_host()), |
| 178 content::NotificationService::NoDetails()); | 183 content::NotificationService::NoDetails()); |
| 179 } | 184 } |
| 185 | |
| 186 void ChromeRenderViewHostObserver::OnGetTalkPermission( | |
| 187 const ppapi::HostResource& resource) { | |
| 188 string16 title = ASCIIToUTF16("System Dialog"); | |
| 189 string16 message = ASCIIToUTF16("Share your screen?"); | |
|
Josh Horwich
2012/03/14 18:41:45
Should we be using l10n_util::GetStringUTF16 for t
varunjain
2012/03/14 18:49:08
the talk code already has localized versions of th
Avi (use Gerrit)
2012/03/14 21:03:00
I'm not familiar with the design of this area, but
| |
| 190 int32_t result = browser::ShowYesNoBox( | |
| 191 render_view_host()->GetView()->GetNativeView(), title, message); | |
| 192 | |
| 193 Send(new ChromeViewMsg_GetTalkPermissionACK( | |
| 194 render_view_host()->GetRoutingID(), resource, result)); | |
| 195 } | |
| OLD | NEW |