Fixing build: GetViewContainer changed name from under me. :)
[chromium-blink-merge.git] / chrome / browser / plugin_installer.cc
blob1d42d8095785aa4156fe83c71d9de6b782eee67d
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),
18 current_bar_(NULL) {
21 PluginInstaller::~PluginInstaller() {
22 if (current_bar_)
23 current_bar_->Close();
26 void PluginInstaller::OnMissingPluginStatus(int status) {
27 switch(status) {
28 case default_plugin::MISSING_PLUGIN_AVAILABLE: {
29 // Display missing plugin InfoBar if a missing plugin is available.
30 if (current_bar_)
31 return;
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_);
38 break;
40 case default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD: {
41 // Hide the InfoBar if user already started download/install of the
42 // missing plugin.
43 if (current_bar_)
44 current_bar_->Close();
45 break;
47 default: {
48 NOTREACHED();
49 break;
54 void PluginInstaller::OnStartLoading() {
55 if (current_bar_)
56 current_bar_->BeginClose();
59 void PluginInstaller::OnBarDestroy(InfoBarConfirmView* bar) {
60 if (current_bar_ == bar)
61 current_bar_ = NULL;
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),
72 InfoBarConfirmView(
73 l10n_util::GetString(IDS_PLUGININSTALLER_MISSINGPLUGIN_PROMPT)) {
74 SetOKButtonLabel(
75 l10n_util::GetString(IDS_PLUGININSTALLER_INSTALLPLUGIN_BUTTON));
76 RemoveCancelButton();
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();