blob: 1d42d8095785aa4156fe83c71d9de6b782eee67d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/plugin_installer.h"
#include "chrome/app/theme/theme_resources.h"
#include "chrome/browser/web_contents_view.h"
#include "base/string_util.h"
#include "chrome/common/l10n_util.h"
#include "chrome/common/resource_bundle.h"
#include "webkit/default_plugin/default_plugin_shared.h"
#include "generated_resources.h"
PluginInstaller::PluginInstaller(WebContents* web_contents)
: web_contents_(web_contents),
current_bar_(NULL) {
}
PluginInstaller::~PluginInstaller() {
if (current_bar_)
current_bar_->Close();
}
void PluginInstaller::OnMissingPluginStatus(int status) {
switch(status) {
case default_plugin::MISSING_PLUGIN_AVAILABLE: {
// Display missing plugin InfoBar if a missing plugin is available.
if (current_bar_)
return;
// TODO(brettw) have a more general way to add to the info bar rather
// than mucking with it directly.
InfoBarView* view = web_contents_->view()->GetInfoBarView();
current_bar_ = new PluginInstallerBar(this);
view->AddChildView(current_bar_);
break;
}
case default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD: {
// Hide the InfoBar if user already started download/install of the
// missing plugin.
if (current_bar_)
current_bar_->Close();
break;
}
default: {
NOTREACHED();
break;
}
}
}
void PluginInstaller::OnStartLoading() {
if (current_bar_)
current_bar_->BeginClose();
}
void PluginInstaller::OnBarDestroy(InfoBarConfirmView* bar) {
if (current_bar_ == bar)
current_bar_ = NULL;
}
void PluginInstaller::OnOKButtonPressed() {
current_bar_->BeginClose();
web_contents_->render_view_host()->InstallMissingPlugin();
}
PluginInstaller::PluginInstallerBar
::PluginInstallerBar(PluginInstaller* plugin_installer)
: plugin_installer_(plugin_installer),
InfoBarConfirmView(
l10n_util::GetString(IDS_PLUGININSTALLER_MISSINGPLUGIN_PROMPT)) {
SetOKButtonLabel(
l10n_util::GetString(IDS_PLUGININSTALLER_INSTALLPLUGIN_BUTTON));
RemoveCancelButton();
ResourceBundle &rb = ResourceBundle::GetSharedInstance();
SetIcon(*rb.GetBitmapNamed(IDR_INFOBAR_PLUGIN_INSTALL));
}
PluginInstaller::PluginInstallerBar::~PluginInstallerBar() {
plugin_installer_->OnBarDestroy(this);
}
void PluginInstaller::PluginInstallerBar::OKButtonPressed() {
plugin_installer_->OnOKButtonPressed();
}
|