summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 04:29:58 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 04:29:58 +0000
commitdccce12ad336b63071ac90cb252e171e781df9bf (patch)
treed6c5c26a7f53ad9fa761c1162a53a4efd771b433 /chrome/browser/extensions
parent7657947d3efae4662ff3d643106776fbbf6459fb (diff)
downloadchromium_src-dccce12ad336b63071ac90cb252e171e781df9bf.zip
chromium_src-dccce12ad336b63071ac90cb252e171e781df9bf.tar.gz
chromium_src-dccce12ad336b63071ac90cb252e171e781df9bf.tar.bz2
copy files to new location to help git cl patch
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28519 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc25
-rw-r--r--chrome/browser/extensions/gtk_theme_installed_infobar_delegate.h27
-rw-r--r--chrome/browser/extensions/theme_installed_infobar_delegate.cc75
-rw-r--r--chrome/browser/extensions/theme_installed_infobar_delegate.h41
4 files changed, 168 insertions, 0 deletions
diff --git a/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc b/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc
new file mode 100644
index 0000000..e577158
--- /dev/null
+++ b/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc
@@ -0,0 +1,25 @@
+// Copyright (c) 2009 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/extensions/gtk_theme_preview_infobar_delegate.h"
+
+#include "chrome/browser/profile.h"
+
+GtkThemePreviewInfobarDelegate::GtkThemePreviewInfobarDelegate(
+ TabContents* tab_contents,
+ const std::string& name,
+ const std::string& previous_theme,
+ bool previous_use_gtk_theme)
+ : ThemePreviewInfobarDelegate(tab_contents, name, previous_theme),
+ previous_use_gtk_theme_(previous_use_gtk_theme) {
+}
+
+bool GtkThemePreviewInfobarDelegate::Cancel() {
+ if (previous_use_gtk_theme_) {
+ profile()->SetNativeTheme();
+ return true;
+ } else {
+ return ThemePreviewInfobarDelegate::Cancel();
+ }
+}
diff --git a/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.h b/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.h
new file mode 100644
index 0000000..cfc213de
--- /dev/null
+++ b/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.h
@@ -0,0 +1,27 @@
+// Copyright (c) 2009 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.
+
+#ifndef CHROME_BROWSER_VIEWS_EXTENSIONS_GTK_THEME_PREVIEW_INFOBAR_DELEGATE_H_
+#define CHROME_BROWSER_VIEWS_EXTENSIONS_GTK_THEME_PREVIEW_INFOBAR_DELEGATE_H_
+
+#include "chrome/browser/extensions/theme_preview_infobar_delegate.h"
+
+class SkBitmap;
+class TabContents;
+
+// A specialization of ThemePreviewInfobarDelegate to make "Undo" reset to the
+// GTK theme if the user was in GTK theme mode before installing the theme.
+class GtkThemePreviewInfobarDelegate : public ThemePreviewInfobarDelegate {
+ public:
+ GtkThemePreviewInfobarDelegate(TabContents* tab_contents,
+ const std::string& name,
+ const std::string& previous_theme,
+ bool previous_use_gtk_theme);
+ virtual bool Cancel();
+
+ private:
+ bool previous_use_gtk_theme_;
+};
+
+#endif // CHROME_BROWSER_VIEWS_EXTENSIONS_GTK_THEME_PREVIEW_INFOBAR_DELEGATE_H_
diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.cc b/chrome/browser/extensions/theme_installed_infobar_delegate.cc
new file mode 100644
index 0000000..06b8ed6
--- /dev/null
+++ b/chrome/browser/extensions/theme_installed_infobar_delegate.cc
@@ -0,0 +1,75 @@
+// Copyright (c) 2009 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/extensions/theme_preview_infobar_delegate.h"
+
+#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
+#include "base/string_util.h"
+#include "chrome/browser/extensions/extensions_service.h"
+#include "chrome/browser/profile.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/extensions/extension.h"
+#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
+
+ThemePreviewInfobarDelegate::ThemePreviewInfobarDelegate(
+ TabContents* tab_contents, const std::string& name,
+ const std::string& previous_theme_id)
+ : ConfirmInfoBarDelegate(tab_contents),
+ profile_(tab_contents->profile()), name_(name),
+ previous_theme_id_(previous_theme_id) {
+}
+
+void ThemePreviewInfobarDelegate::InfoBarClosed() {
+ delete this;
+}
+
+std::wstring ThemePreviewInfobarDelegate::GetMessageText() const {
+ return l10n_util::GetStringF(IDS_THEME_INSTALL_INFOBAR_LABEL,
+ UTF8ToWide(name_));
+}
+
+SkBitmap* ThemePreviewInfobarDelegate::GetIcon() const {
+ // TODO(aa): Reply with the theme's icon, but this requires reading it
+ // asynchronously from disk.
+ return ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_INFOBAR_THEME);
+}
+
+ThemePreviewInfobarDelegate*
+ ThemePreviewInfobarDelegate::AsThemePreviewInfobarDelegate() {
+ return this;
+}
+
+int ThemePreviewInfobarDelegate::GetButtons() const {
+ return BUTTON_CANCEL;
+}
+
+std::wstring ThemePreviewInfobarDelegate::GetButtonLabel(
+ ConfirmInfoBarDelegate::InfoBarButton button) const {
+ switch (button) {
+ case BUTTON_CANCEL: {
+ return l10n_util::GetString(IDS_THEME_INSTALL_INFOBAR_UNDO_BUTTON);
+ }
+ default:
+ return L"";
+ }
+}
+
+bool ThemePreviewInfobarDelegate::Cancel() {
+ if (!previous_theme_id_.empty()) {
+ ExtensionsService* service = profile_->GetExtensionsService();
+ if (service) {
+ Extension* previous_theme = service->GetExtensionById(previous_theme_id_);
+ if (previous_theme) {
+ profile_->SetTheme(previous_theme);
+ return true;
+ }
+ }
+ }
+
+ profile_->ClearTheme();
+ return true;
+}
diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.h b/chrome/browser/extensions/theme_installed_infobar_delegate.h
new file mode 100644
index 0000000..fdffe07
--- /dev/null
+++ b/chrome/browser/extensions/theme_installed_infobar_delegate.h
@@ -0,0 +1,41 @@
+// Copyright (c) 2009 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.
+
+#ifndef CHROME_BROWSER_VIEWS_EXTENSIONS_THEME_PREVIEW_INFOBAR_DELEGATE_H_
+#define CHROME_BROWSER_VIEWS_EXTENSIONS_THEME_PREVIEW_INFOBAR_DELEGATE_H_
+
+#include "chrome/browser/tab_contents/infobar_delegate.h"
+
+class SkBitmap;
+class TabContents;
+
+// When a user installs a theme, we display it immediately, but provide an
+// infobar allowing them to cancel.
+//
+// TODO(aa): Rename this to ThemeInstalledInfoBarDelegate, since it isn't
+// used for previewing anymore.
+class ThemePreviewInfobarDelegate : public ConfirmInfoBarDelegate {
+ public:
+ ThemePreviewInfobarDelegate(TabContents* tab_contents,
+ const std::string& name,
+ const std::string& previous_theme);
+ virtual void InfoBarClosed();
+ virtual std::wstring GetMessageText() const;
+ virtual SkBitmap* GetIcon() const;
+ virtual ThemePreviewInfobarDelegate* AsThemePreviewInfobarDelegate();
+ virtual int GetButtons() const;
+ virtual std::wstring GetButtonLabel(
+ ConfirmInfoBarDelegate::InfoBarButton button) const;
+ virtual bool Cancel();
+
+ protected:
+ Profile* profile() { return profile_; }
+
+ private:
+ Profile* profile_;
+ std::string name_; // name of theme to install
+ std::string previous_theme_id_; // used to undo theme install
+};
+
+#endif // CHROME_BROWSER_VIEWS_EXTENSIONS_THEME_PREVIEW_INFOBAR_DELEGATE_H_