summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_install_ui.cc
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-01 00:12:02 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-01 00:12:02 +0000
commit25e02aca12eabfdcd8ba0506ce242cf91ef54150 (patch)
tree8886296a844e7e2b5338b4ef9a146aaf8f257dd1 /chrome/browser/extensions/extension_install_ui.cc
parent6fd3e87645a59cbc5d28b2173ead9004ce22559e (diff)
downloadchromium_src-25e02aca12eabfdcd8ba0506ce242cf91ef54150.zip
chromium_src-25e02aca12eabfdcd8ba0506ce242cf91ef54150.tar.gz
chromium_src-25e02aca12eabfdcd8ba0506ce242cf91ef54150.tar.bz2
Rollback 22228
TBR=mpcomplete@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22231 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_install_ui.cc')
-rw-r--r--chrome/browser/extensions/extension_install_ui.cc118
1 files changed, 0 insertions, 118 deletions
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc
deleted file mode 100644
index 4416701..0000000
--- a/chrome/browser/extensions/extension_install_ui.cc
+++ /dev/null
@@ -1,118 +0,0 @@
-// 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/extension_install_ui.h"
-
-#include "app/l10n_util.h"
-#include "grit/chromium_strings.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/extensions/theme_preview_infobar_delegate.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
-
-#if defined(OS_WIN)
-#include "app/win_util.h"
-#elif defined(OS_MACOSX)
-#include "base/scoped_cftyperef.h"
-#include "base/sys_string_conversions.h"
-#include <CoreFoundation/CFUserNotification.h>
-#endif
-
-ExtensionInstallUI::ExtensionInstallUI(Profile* profile)
- : profile_(profile), ui_loop_(MessageLoop::current()) {
-}
-
-bool ExtensionInstallUI::ConfirmInstall(Extension* extension) {
- DCHECK(ui_loop_ == MessageLoop::current());
-
- // We special-case themes to not show any confirm UI. Instead they are
- // immediately installed, and then we show an infobar (see OnInstallSuccess)
- // to allow the user to revert if they don't like it.
- if (extension->IsTheme())
- return true;
-
-#if defined(OS_WIN)
- if (win_util::MessageBox(GetForegroundWindow(),
- L"Are you sure you want to install this extension?\n\n"
- L"You should only install extensions from sources you trust.",
- l10n_util::GetString(IDS_PRODUCT_NAME).c_str(),
- MB_OKCANCEL) != IDOK) {
- return false;
- }
-#elif defined(OS_MACOSX)
- // Using CoreFoundation to do this dialog is unimaginably lame but will do
- // until the UI is redone.
- scoped_cftyperef<CFStringRef> product_name(
- base::SysWideToCFStringRef(l10n_util::GetString(IDS_PRODUCT_NAME)));
- CFOptionFlags response;
- if (kCFUserNotificationAlternateResponse == CFUserNotificationDisplayAlert(
- 0, kCFUserNotificationCautionAlertLevel, NULL, NULL, NULL,
- product_name,
- CFSTR("Are you sure you want to install this extension?\n\n"
- "This is a temporary message and it will be removed when "
- "extensions UI is finalized."),
- NULL, CFSTR("Cancel"), NULL, &response)) {
- return false;
- }
-#else
- NOTREACHED();
-#endif // OS_*
-
- return true;
-}
-
-void ExtensionInstallUI::OnInstallSuccess(Extension* extension) {
- ShowThemeInfoBar(extension);
-}
-
-void ExtensionInstallUI::OnInstallFailure(const std::string& error) {
- DCHECK(ui_loop_ == MessageLoop::current());
-
-#if defined(OS_WIN)
- win_util::MessageBox(NULL, UTF8ToWide(error), L"Extension Install Error",
- MB_OK | MB_SETFOREGROUND);
-#elif defined(OS_MACOSX)
- // There must be a better way to do this, for all platforms.
- scoped_cftyperef<CFStringRef> message_cf(
- base::SysUTF8ToCFStringRef(error));
- CFOptionFlags response;
- CFUserNotificationDisplayAlert(
- 0, kCFUserNotificationCautionAlertLevel, NULL, NULL, NULL,
- CFSTR("Extension Install Error"), message_cf,
- NULL, NULL, NULL, &response);
-#else
- LOG(ERROR) << "Extension install failed: " << error.c_str();
- NOTREACHED();
-#endif
-}
-
-void ExtensionInstallUI::OnOverinstallAttempted(Extension* extension) {
- ShowThemeInfoBar(extension);
-}
-
-void ExtensionInstallUI::ShowThemeInfoBar(Extension* extension) {
- if (!extension->IsTheme())
- return;
-
- Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
- if (!browser)
- return;
-
- TabContents* tab_contents = browser->GetSelectedTabContents();
- if (!tab_contents)
- return;
-
- // First remove any previous theme preview infobar.
- for (int i = 0; i < tab_contents->infobar_delegate_count(); ++i) {
- InfoBarDelegate* delegate = tab_contents->GetInfoBarDelegateAt(i);
- if (delegate->AsThemePreviewInfobarDelegate()) {
- tab_contents->RemoveInfoBar(delegate);
- break;
- }
- }
-
- // Now add the new one.
- tab_contents->AddInfoBar(new ThemePreviewInfobarDelegate(
- tab_contents, extension->name()));
-}