OLD | NEW |
1 // Copyright (c) 2010 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_installer.h" | 5 #include "chrome/browser/plugin_installer_infobar_delegate.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/string_util.h" | |
10 #include "chrome/browser/renderer_host/render_view_host.h" | 9 #include "chrome/browser/renderer_host/render_view_host.h" |
11 #include "chrome/browser/tab_contents/tab_contents.h" | 10 #include "chrome/browser/tab_contents/tab_contents.h" |
12 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
13 #include "grit/locale_settings.h" | 12 #include "grit/locale_settings.h" |
14 #include "grit/theme_resources.h" | 13 #include "grit/theme_resources.h" |
15 #include "webkit/plugins/npapi/default_plugin_shared.h" | 14 #include "webkit/plugins/npapi/default_plugin_shared.h" |
16 | 15 |
17 // The URL for the "Problems installing" page for the Plugins infobar. | 16 PluginInstallerInfoBarDelegate::PluginInstallerInfoBarDelegate( |
18 static const char kLearnMorePluginInstallerUrl[] = | 17 TabContents* tab_contents) |
19 "http://www.google.com/support/chrome/bin/answer.py?answer=95697&topic=1
4687"; | |
20 | |
21 PluginInstaller::PluginInstaller(TabContents* tab_contents) | |
22 : ConfirmInfoBarDelegate(tab_contents), | 18 : ConfirmInfoBarDelegate(tab_contents), |
23 tab_contents_(tab_contents) { | 19 tab_contents_(tab_contents) { |
24 } | 20 } |
25 | 21 |
26 PluginInstaller::~PluginInstaller() { | 22 PluginInstallerInfoBarDelegate::~PluginInstallerInfoBarDelegate() { |
27 // Remove any InfoBars we may be showing. | 23 // Remove any InfoBars we may be showing. |
28 tab_contents_->RemoveInfoBar(this); | 24 tab_contents_->RemoveInfoBar(this); |
29 } | 25 } |
30 | 26 |
31 void PluginInstaller::OnMissingPluginStatus(int status) { | 27 void PluginInstallerInfoBarDelegate::OnMissingPluginStatus(int status) { |
32 switch (status) { | 28 switch (status) { |
33 case webkit::npapi::default_plugin::MISSING_PLUGIN_AVAILABLE: { | 29 case webkit::npapi::default_plugin::MISSING_PLUGIN_AVAILABLE: { |
34 tab_contents_->AddInfoBar(this); | 30 tab_contents_->AddInfoBar(this); |
35 break; | 31 break; |
36 } | 32 } |
37 case webkit::npapi::default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD: { | 33 case webkit::npapi::default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD: { |
38 // Hide the InfoBar if user already started download/install of the | 34 // Hide the InfoBar if user already started download/install of the |
39 // missing plugin. | 35 // missing plugin. |
40 tab_contents_->RemoveInfoBar(this); | 36 tab_contents_->RemoveInfoBar(this); |
41 break; | 37 break; |
42 } | 38 } |
43 default: { | 39 default: { |
44 NOTREACHED(); | 40 NOTREACHED(); |
45 break; | 41 break; |
46 } | 42 } |
47 } | 43 } |
48 } | 44 } |
49 | 45 |
50 string16 PluginInstaller::GetMessageText() const { | 46 SkBitmap* PluginInstallerInfoBarDelegate::GetIcon() const { |
51 return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_MISSINGPLUGIN_PROMPT); | |
52 } | |
53 | |
54 SkBitmap* PluginInstaller::GetIcon() const { | |
55 return ResourceBundle::GetSharedInstance().GetBitmapNamed( | 47 return ResourceBundle::GetSharedInstance().GetBitmapNamed( |
56 IDR_INFOBAR_PLUGIN_INSTALL); | 48 IDR_INFOBAR_PLUGIN_INSTALL); |
57 } | 49 } |
58 | 50 |
59 int PluginInstaller::GetButtons() const { | 51 string16 PluginInstallerInfoBarDelegate::GetMessageText() const { |
| 52 return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_MISSINGPLUGIN_PROMPT); |
| 53 } |
| 54 |
| 55 int PluginInstallerInfoBarDelegate::GetButtons() const { |
60 return BUTTON_OK; | 56 return BUTTON_OK; |
61 } | 57 } |
62 | 58 |
63 string16 PluginInstaller::GetButtonLabel(InfoBarButton button) const { | 59 string16 PluginInstallerInfoBarDelegate::GetButtonLabel( |
64 if (button == BUTTON_OK) | 60 InfoBarButton button) const { |
65 return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_INSTALLPLUGIN_BUTTON); | 61 DCHECK_EQ(BUTTON_OK, button); |
66 return ConfirmInfoBarDelegate::GetButtonLabel(button); | 62 return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_INSTALLPLUGIN_BUTTON); |
67 } | 63 } |
68 | 64 |
69 bool PluginInstaller::Accept() { | 65 bool PluginInstallerInfoBarDelegate::Accept() { |
70 tab_contents_->render_view_host()->InstallMissingPlugin(); | 66 tab_contents_->render_view_host()->InstallMissingPlugin(); |
71 return true; | 67 return true; |
72 } | 68 } |
73 | 69 |
74 string16 PluginInstaller::GetLinkText() { | 70 string16 PluginInstallerInfoBarDelegate::GetLinkText() { |
75 return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_PROBLEMSINSTALLING); | 71 return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_PROBLEMSINSTALLING); |
76 } | 72 } |
77 | 73 |
78 bool PluginInstaller::LinkClicked(WindowOpenDisposition disposition) { | 74 bool PluginInstallerInfoBarDelegate::LinkClicked( |
| 75 WindowOpenDisposition disposition) { |
79 // Ignore the click dispostion and always open in a new top level tab. | 76 // Ignore the click dispostion and always open in a new top level tab. |
| 77 static const char kLearnMorePluginInstallerUrl[] = "http://www.google.com/" |
| 78 "support/chrome/bin/answer.py?answer=95697&topic=14687"; |
80 tab_contents_->OpenURL(GURL(kLearnMorePluginInstallerUrl), GURL(), | 79 tab_contents_->OpenURL(GURL(kLearnMorePluginInstallerUrl), GURL(), |
81 NEW_FOREGROUND_TAB, PageTransition::LINK); | 80 NEW_FOREGROUND_TAB, PageTransition::LINK); |
82 return false; // Do not dismiss the info bar. | 81 return false; |
83 } | 82 } |
OLD | NEW |