1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/plugin_installer.h"
7 #include "chrome/app/theme/theme_resources.h"
8 #include "chrome/browser/web_contents_view.h"
9 #include "base/string_util.h"
10 #include "chrome/common/l10n_util.h"
11 #include "chrome/common/resource_bundle.h"
12 #include "webkit/default_plugin/default_plugin_shared.h"
14 #include "generated_resources.h"
16 PluginInstaller::PluginInstaller(WebContents
* web_contents
)
17 : web_contents_(web_contents
),
21 PluginInstaller::~PluginInstaller() {
23 current_bar_
->Close();
26 void PluginInstaller::OnMissingPluginStatus(int status
) {
28 case default_plugin::MISSING_PLUGIN_AVAILABLE
: {
29 // Display missing plugin InfoBar if a missing plugin is available.
33 // TODO(brettw) have a more general way to add to the info bar rather
34 // than mucking with it directly.
35 InfoBarView
* view
= web_contents_
->view()->GetInfoBarView();
36 current_bar_
= new PluginInstallerBar(this);
37 view
->AddChildView(current_bar_
);
40 case default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD
: {
41 // Hide the InfoBar if user already started download/install of the
44 current_bar_
->Close();
54 void PluginInstaller::OnStartLoading() {
56 current_bar_
->BeginClose();
59 void PluginInstaller::OnBarDestroy(InfoBarConfirmView
* bar
) {
60 if (current_bar_
== bar
)
64 void PluginInstaller::OnOKButtonPressed() {
65 current_bar_
->BeginClose();
66 web_contents_
->render_view_host()->InstallMissingPlugin();
69 PluginInstaller::PluginInstallerBar
70 ::PluginInstallerBar(PluginInstaller
* plugin_installer
)
71 : plugin_installer_(plugin_installer
),
73 l10n_util::GetString(IDS_PLUGININSTALLER_MISSINGPLUGIN_PROMPT
)) {
75 l10n_util::GetString(IDS_PLUGININSTALLER_INSTALLPLUGIN_BUTTON
));
77 ResourceBundle
&rb
= ResourceBundle::GetSharedInstance();
78 SetIcon(*rb
.GetBitmapNamed(IDR_INFOBAR_PLUGIN_INSTALL
));
81 PluginInstaller::PluginInstallerBar::~PluginInstallerBar() {
82 plugin_installer_
->OnBarDestroy(this);
85 void PluginInstaller::PluginInstallerBar::OKButtonPressed() {
86 plugin_installer_
->OnOKButtonPressed();