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
3// found in the LICENSE file.
4
5#include "chrome/browser/plugin_installer_infobar_delegate.h"
6
7#include "content/browser/renderer_host/render_view_host.h"
8#include "content/browser/tab_contents/tab_contents.h"
9#include "grit/generated_resources.h"
10#include "grit/locale_settings.h"
11#include "grit/theme_resources.h"
12#include "ui/base/l10n/l10n_util.h"
13#include "ui/base/resource/resource_bundle.h"
14
15PluginInstallerInfoBarDelegate::PluginInstallerInfoBarDelegate(
16    TabContents* tab_contents)
17    : ConfirmInfoBarDelegate(tab_contents),
18      tab_contents_(tab_contents) {
19}
20
21PluginInstallerInfoBarDelegate::~PluginInstallerInfoBarDelegate() {
22}
23
24SkBitmap* PluginInstallerInfoBarDelegate::GetIcon() const {
25  return ResourceBundle::GetSharedInstance().GetBitmapNamed(
26      IDR_INFOBAR_PLUGIN_INSTALL);
27}
28
29PluginInstallerInfoBarDelegate*
30    PluginInstallerInfoBarDelegate::AsPluginInstallerInfoBarDelegate() {
31  return this;
32}
33
34string16 PluginInstallerInfoBarDelegate::GetMessageText() const {
35  return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_MISSINGPLUGIN_PROMPT);
36}
37
38int PluginInstallerInfoBarDelegate::GetButtons() const {
39  return BUTTON_OK;
40}
41
42string16 PluginInstallerInfoBarDelegate::GetButtonLabel(
43    InfoBarButton button) const {
44  DCHECK_EQ(BUTTON_OK, button);
45  return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_INSTALLPLUGIN_BUTTON);
46}
47
48bool PluginInstallerInfoBarDelegate::Accept() {
49  tab_contents_->render_view_host()->InstallMissingPlugin();
50  return true;
51}
52
53string16 PluginInstallerInfoBarDelegate::GetLinkText() {
54  return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_PROBLEMSINSTALLING);
55}
56
57bool PluginInstallerInfoBarDelegate::LinkClicked(
58    WindowOpenDisposition disposition) {
59  // Ignore the click dispostion and always open in a new top level tab.
60  static const char kLearnMorePluginInstallerUrl[] = "http://www.google.com/"
61      "support/chrome/bin/answer.py?answer=95697&topic=14687";
62  tab_contents_->OpenURL(GURL(kLearnMorePluginInstallerUrl), GURL(),
63                         NEW_FOREGROUND_TAB, PageTransition::LINK);
64  return false;
65}
66