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/plugins/plugin_observer.h" | 5 #include "chrome/browser/plugins/plugin_observer.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/content_settings/host_content_settings_map.h" | 14 #include "chrome/browser/content_settings/host_content_settings_map.h" |
15 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 15 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
16 #include "chrome/browser/infobars/infobar_service.h" | 16 #include "chrome/browser/infobars/infobar_service.h" |
17 #include "chrome/browser/infobars/simple_alert_infobar_delegate.h" | 17 #include "chrome/browser/infobars/simple_alert_infobar_delegate.h" |
18 #include "chrome/browser/lifetime/application_lifetime.h" | 18 #include "chrome/browser/lifetime/application_lifetime.h" |
19 #include "chrome/browser/metrics/metrics_service.h" | 19 #include "chrome/browser/metrics/metrics_service.h" |
20 #include "chrome/browser/plugins/plugin_finder.h" | 20 #include "chrome/browser/plugins/plugin_finder.h" |
21 #include "chrome/browser/plugins/plugin_infobar_delegates.h" | 21 #include "chrome/browser/plugins/plugin_infobar_delegates.h" |
22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" | 23 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" |
24 #include "chrome/common/render_messages.h" | 24 #include "chrome/common/render_messages.h" |
25 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
26 #include "content/public/browser/plugin_service.h" | 26 #include "content/public/browser/plugin_service.h" |
| 27 #include "content/public/browser/render_frame_host.h" |
27 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
28 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
29 #include "content/public/browser/web_contents_delegate.h" | 30 #include "content/public/browser/web_contents_delegate.h" |
30 #include "content/public/browser/web_contents_view.h" | 31 #include "content/public/browser/web_contents_view.h" |
31 #include "content/public/common/webplugininfo.h" | 32 #include "content/public/common/webplugininfo.h" |
32 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
33 #include "grit/theme_resources.h" | 34 #include "grit/theme_resources.h" |
34 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
35 | 36 |
36 #if defined(ENABLE_PLUGIN_INSTALLATION) | 37 #if defined(ENABLE_PLUGIN_INSTALLATION) |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 : content::WebContentsObserver(web_contents), | 176 : content::WebContentsObserver(web_contents), |
176 weak_ptr_factory_(this) { | 177 weak_ptr_factory_(this) { |
177 } | 178 } |
178 | 179 |
179 PluginObserver::~PluginObserver() { | 180 PluginObserver::~PluginObserver() { |
180 #if defined(ENABLE_PLUGIN_INSTALLATION) | 181 #if defined(ENABLE_PLUGIN_INSTALLATION) |
181 STLDeleteValues(&plugin_placeholders_); | 182 STLDeleteValues(&plugin_placeholders_); |
182 #endif | 183 #endif |
183 } | 184 } |
184 | 185 |
185 void PluginObserver::RenderViewCreated( | 186 void PluginObserver::RenderFrameCreated( |
186 content::RenderViewHost* render_view_host) { | 187 content::RenderFrameHost* render_frame_host) { |
187 #if defined(USE_AURA) && defined(OS_WIN) | 188 #if defined(USE_AURA) && defined(OS_WIN) |
188 // If the window belongs to the Ash desktop, before we navigate we need | 189 // If the window belongs to the Ash desktop, before we navigate we need |
189 // to tell the renderview that NPAPI plugins are not supported so it does | 190 // to tell the renderview that NPAPI plugins are not supported so it does |
190 // not try to instantiate them. The final decision is actually done in | 191 // not try to instantiate them. The final decision is actually done in |
191 // the IO thread by PluginInfoMessageFilter of this proces,s but it's more | 192 // the IO thread by PluginInfoMessageFilter of this proces,s but it's more |
192 // complex to manage a map of Ash views in PluginInfoMessageFilter than | 193 // complex to manage a map of Ash views in PluginInfoMessageFilter than |
193 // just telling the renderer via IPC. | 194 // just telling the renderer via IPC. |
194 | 195 |
195 // TODO(shrikant): Implement solution which will help associate | 196 // TODO(shrikant): Implement solution which will help associate |
196 // render_view_host/webcontents/view/window instance with host desktop. | 197 // render_view_host/webcontents/view/window instance with host desktop. |
197 // Refer to issue http://crbug.com/317940. | 198 // Refer to issue http://crbug.com/317940. |
198 // When non-active tabs are restored they are not added in view/window parent | 199 // When non-active tabs are restored they are not added in view/window parent |
199 // hierarchy (chrome::CreateRestoredTab/CreateParams). Normally we traverse | 200 // hierarchy (chrome::CreateRestoredTab/CreateParams). Normally we traverse |
200 // parent hierarchy to identify containing desktop (like in function | 201 // parent hierarchy to identify containing desktop (like in function |
201 // chrome::GetHostDesktopTypeForNativeView). | 202 // chrome::GetHostDesktopTypeForNativeView). |
202 // Possible issue with chrome::GetActiveDesktop, is that it's global | 203 // Possible issue with chrome::GetActiveDesktop, is that it's global |
203 // state, which remembers last active desktop, which may break in scenarios | 204 // state, which remembers last active desktop, which may break in scenarios |
204 // where we have instances on both Ash and Native desktop. | 205 // where we have instances on both Ash and Native desktop. |
205 | 206 |
206 // We will do both tests. Both have some factor of unreliability. | 207 // We will do both tests. Both have some factor of unreliability. |
207 aura::Window* window = web_contents()->GetView()->GetNativeView(); | 208 aura::Window* window = web_contents()->GetView()->GetNativeView(); |
208 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH || | 209 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH || |
209 chrome::GetHostDesktopTypeForNativeView(window) == | 210 chrome::GetHostDesktopTypeForNativeView(window) == |
210 chrome::HOST_DESKTOP_TYPE_ASH) { | 211 chrome::HOST_DESKTOP_TYPE_ASH) { |
211 int routing_id = render_view_host->GetRoutingID(); | 212 int routing_id = render_frame_host->GetRoutingID(); |
212 render_view_host->Send(new ChromeViewMsg_NPAPINotSupported(routing_id)); | 213 render_frame_host->Send(new ChromeViewMsg_NPAPINotSupported(routing_id)); |
213 } | 214 } |
214 #endif | 215 #endif |
215 } | 216 } |
216 | 217 |
217 void PluginObserver::PluginCrashed(const base::FilePath& plugin_path, | 218 void PluginObserver::PluginCrashed(const base::FilePath& plugin_path, |
218 base::ProcessId plugin_pid) { | 219 base::ProcessId plugin_pid) { |
219 DCHECK(!plugin_path.value().empty()); | 220 DCHECK(!plugin_path.value().empty()); |
220 | 221 |
221 base::string16 plugin_name = | 222 base::string16 plugin_name = |
222 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); | 223 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 scoped_ptr<PluginMetadata> plugin; | 412 scoped_ptr<PluginMetadata> plugin; |
412 bool ret = PluginFinder::GetInstance()->FindPluginWithIdentifier( | 413 bool ret = PluginFinder::GetInstance()->FindPluginWithIdentifier( |
413 identifier, NULL, &plugin); | 414 identifier, NULL, &plugin); |
414 DCHECK(ret); | 415 DCHECK(ret); |
415 | 416 |
416 PluginMetroModeInfoBarDelegate::Create( | 417 PluginMetroModeInfoBarDelegate::Create( |
417 InfoBarService::FromWebContents(web_contents()), | 418 InfoBarService::FromWebContents(web_contents()), |
418 PluginMetroModeInfoBarDelegate::DESKTOP_MODE_REQUIRED, plugin->name()); | 419 PluginMetroModeInfoBarDelegate::DESKTOP_MODE_REQUIRED, plugin->name()); |
419 #endif | 420 #endif |
420 } | 421 } |
OLD | NEW |