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/plugin_observer.h" | 5 #include "chrome/browser/plugin_observer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
11 #include "chrome/browser/google/google_util.h" | 11 #include "chrome/browser/google/google_util.h" |
12 #include "chrome/browser/infobars/infobar_tab_helper.h" | 12 #include "chrome/browser/infobars/infobar_tab_helper.h" |
13 #include "chrome/browser/plugin_finder.h" | 13 #include "chrome/browser/plugin_finder.h" |
14 #include "chrome/browser/plugin_installer.h" | |
14 #include "chrome/browser/plugin_installer_infobar_delegate.h" | 15 #include "chrome/browser/plugin_installer_infobar_delegate.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 17 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
18 #include "chrome/common/render_messages.h" | 19 #include "chrome/common/render_messages.h" |
19 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
20 #include "content/browser/renderer_host/render_view_host.h" | 21 #include "content/browser/renderer_host/render_view_host.h" |
21 #include "content/browser/tab_contents/tab_contents.h" | 22 #include "content/browser/tab_contents/tab_contents.h" |
23 #include "content/browser/tab_contents/tab_contents_delegate.h" | |
22 #include "content/browser/user_metrics.h" | 24 #include "content/browser/user_metrics.h" |
23 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
24 #include "grit/theme_resources_standard.h" | 26 #include "grit/theme_resources_standard.h" |
25 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
26 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
27 #include "webkit/plugins/npapi/plugin_group.h" | 29 #include "webkit/plugins/npapi/plugin_group.h" |
28 #include "webkit/plugins/webplugininfo.h" | 30 #include "webkit/plugins/webplugininfo.h" |
29 | 31 |
30 namespace { | 32 namespace { |
31 | 33 |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 plugin_finder->FindPlugin( | 325 plugin_finder->FindPlugin( |
324 mime_type, lang, | 326 mime_type, lang, |
325 base::Bind(&PluginObserver::FoundMissingPlugin, | 327 base::Bind(&PluginObserver::FoundMissingPlugin, |
326 weak_ptr_factory_.GetWeakPtr(), placeholder_id, mime_type), | 328 weak_ptr_factory_.GetWeakPtr(), placeholder_id, mime_type), |
327 base::Bind(&PluginObserver::DidNotFindMissingPlugin, | 329 base::Bind(&PluginObserver::DidNotFindMissingPlugin, |
328 weak_ptr_factory_.GetWeakPtr(), placeholder_id, mime_type)); | 330 weak_ptr_factory_.GetWeakPtr(), placeholder_id, mime_type)); |
329 } | 331 } |
330 | 332 |
331 void PluginObserver::FoundMissingPlugin(int placeholder_id, | 333 void PluginObserver::FoundMissingPlugin(int placeholder_id, |
332 const std::string& mime_type, | 334 const std::string& mime_type, |
333 const GURL& url, | 335 PluginInstaller* installer) { |
334 const string16& name, | 336 Send(new ChromeViewMsg_FoundMissingPlugin(placeholder_id, installer->name())); |
335 bool display_url) { | |
336 Send(new ChromeViewMsg_FoundMissingPlugin(placeholder_id, name)); | |
337 InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); | 337 InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); |
338 infobar_helper->AddInfoBar(new PluginInstallerInfoBarDelegate( | 338 infobar_helper->AddInfoBar(new PluginInstallerInfoBarDelegate( |
339 infobar_helper, | 339 infobar_helper, |
340 name, | 340 installer->name(), |
341 GURL(), // TODO(bauerb): Get URL from JSON file. | 341 installer->help_url(), |
342 base::Bind(&PluginObserver::InstallMissingPlugin, | 342 base::Bind(&PluginObserver::InstallMissingPlugin, |
343 weak_ptr_factory_.GetWeakPtr(), url, display_url))); | 343 weak_ptr_factory_.GetWeakPtr(), installer))); |
battre
2011/11/30 14:10:06
life-time issue
Bernhard Bauer
2011/11/30 14:29:23
The PluginObserver is bound to the lifetime of the
| |
344 } | 344 } |
345 | 345 |
346 void PluginObserver::DidNotFindMissingPlugin(int placeholder_id, | 346 void PluginObserver::DidNotFindMissingPlugin(int placeholder_id, |
347 const std::string& mime_type) { | 347 const std::string& mime_type) { |
348 Send(new ChromeViewMsg_DidNotFindMissingPlugin(placeholder_id)); | 348 Send(new ChromeViewMsg_DidNotFindMissingPlugin(placeholder_id)); |
349 } | 349 } |
350 | 350 |
351 void PluginObserver::InstallMissingPlugin(const GURL& url, | 351 void PluginObserver::InstallMissingPlugin(PluginInstaller* installer) { |
352 bool display_url) { | 352 if (installer->url_for_display()) { |
353 if (display_url) { | 353 tab_contents()->OpenURL(installer->plugin_url(), tab_contents()->GetURL(), |
354 tab_contents()->OpenURL(url, tab_contents()->GetURL(), NEW_FOREGROUND_TAB, | 354 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_TYPED); |
355 content::PAGE_TRANSITION_TYPED); | |
356 } else { | 355 } else { |
357 NOTIMPLEMENTED(); | 356 NOTIMPLEMENTED(); |
358 } | 357 } |
359 } | 358 } |
OLD | NEW |