Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5325)

Unified Diff: chrome/browser/extensions/extension_install_ui_default.cc

Issue 10581043: Merge 142921 - Use an infobar instead of alert box for extension install (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1180/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_install_ui_default.h ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_install_ui_default.cc
===================================================================
--- chrome/browser/extensions/extension_install_ui_default.cc (revision 143212)
+++ chrome/browser/extensions/extension_install_ui_default.cc (working copy)
@@ -5,10 +5,12 @@
#include "chrome/browser/extensions/extension_install_ui_default.h"
#include "base/command_line.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/extensions/extension_install_prompt.h"
#include "chrome/browser/extensions/theme_installed_infobar_delegate.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/browser.h"
@@ -42,6 +44,47 @@
bool disable_failure_ui_for_tests = false;
+// Helper class to put up an infobar when installation fails.
+class ErrorInfobarDelegate : public ConfirmInfoBarDelegate {
+ public:
+ ErrorInfobarDelegate(InfoBarTabHelper* infobar_helper,
+ Browser* browser,
+ const CrxInstallerError& error)
+ : ConfirmInfoBarDelegate(infobar_helper),
+ browser_(browser),
+ error_(error) {
+ }
+
+ private:
+ virtual string16 GetMessageText() const OVERRIDE {
+ return error_.message();
+ }
+
+ virtual int GetButtons() const OVERRIDE {
+ return BUTTON_OK;
+ }
+
+ virtual string16 GetLinkText() const OVERRIDE {
+ // TODO(aa): Return the learn more link once we have the help article
+ // posted.
+ // return error_.type() == CrxInstallerError::ERROR_OFF_STORE ?
+ // l10n_util::GetStringUTF16(IDS_LEARN_MORE) : ASCIIToUTF16("");
+ return ASCIIToUTF16("");
+ }
+
+ virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE {
+ browser::NavigateParams params(browser_,
+ GURL("http://www.google.com/"),
+ content::PAGE_TRANSITION_LINK);
+ params.disposition = NEW_FOREGROUND_TAB;
+ browser::Navigate(&params);
+ return false;
+ }
+
+ Browser* browser_;
+ CrxInstallerError error_;
+};
+
} // namespace
ExtensionInstallUIDefault::ExtensionInstallUIDefault(Browser* browser)
@@ -100,15 +143,19 @@
current_profile);
}
-void ExtensionInstallUIDefault::OnInstallFailure(const string16& error) {
+void ExtensionInstallUIDefault::OnInstallFailure(
+ const CrxInstallerError& error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (disable_failure_ui_for_tests || skip_post_install_ui_)
return;
Browser* browser = browser::FindLastActiveWithProfile(browser_->profile());
- browser::ShowMessageBox(browser ? browser->window()->GetNativeWindow() : NULL,
- l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_FAILURE_TITLE), error,
- browser::MESSAGE_BOX_TYPE_WARNING);
+ TabContents* tab_contents = browser->GetActiveTabContents();
+ if (!tab_contents)
+ return;
+ InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper();
+ infobar_helper->AddInfoBar(
+ new ErrorInfobarDelegate(infobar_helper, browser, error));
}
void ExtensionInstallUIDefault::SetSkipPostInstallUI(bool skip_ui) {
« no previous file with comments | « chrome/browser/extensions/extension_install_ui_default.h ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698