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

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

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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
Index: chrome/browser/extensions/extension_install_ui_default.cc
===================================================================
--- chrome/browser/extensions/extension_install_ui_default.cc (revision 175396)
+++ chrome/browser/extensions/extension_install_ui_default.cc (working copy)
@@ -52,6 +52,12 @@
// Helper class to put up an infobar when installation fails.
class ErrorInfobarDelegate : public ConfirmInfoBarDelegate {
public:
+ // Creates an error delegate and adds it to |infobar_service|.
+ static void Create(InfoBarService* infobar_service,
+ Browser* browser,
+ const extensions::CrxInstallerError& error);
+
+ private:
ErrorInfobarDelegate(InfoBarService* infobar_service,
Browser* browser,
const extensions::CrxInstallerError& error)
@@ -60,7 +66,6 @@
error_(error) {
}
- private:
virtual string16 GetMessageText() const OVERRIDE {
return error_.message();
}
@@ -88,6 +93,14 @@
extensions::CrxInstallerError error_;
};
+// static
+void ErrorInfobarDelegate::Create(InfoBarService* infobar_service,
+ Browser* browser,
+ const extensions::CrxInstallerError& error) {
+ infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
+ new ErrorInfobarDelegate(infobar_service, browser, error)));
+}
+
} // namespace
ExtensionInstallUIDefault::ExtensionInstallUIDefault(Profile* profile)
@@ -124,8 +137,8 @@
}
if (extension->is_theme()) {
- ShowThemeInfoBar(previous_theme_id_, previous_using_native_theme_,
- extension, profile_);
+ ThemeInstalledInfoBarDelegate::Create(
+ extension, profile_, previous_theme_id_, previous_using_native_theme_);
return;
}
@@ -166,10 +179,8 @@
WebContents* web_contents = chrome::GetActiveWebContents(browser);
if (!web_contents)
return;
- InfoBarService* infobar_service =
- InfoBarService::FromWebContents(web_contents);
- infobar_service->AddInfoBar(
- new ErrorInfobarDelegate(infobar_service, browser, error));
+ ErrorInfobarDelegate::Create(InfoBarService::FromWebContents(web_contents),
+ browser, error);
}
void ExtensionInstallUIDefault::SetSkipPostInstallUI(bool skip_ui) {
@@ -181,69 +192,6 @@
}
// static
-void ExtensionInstallUIDefault::ShowThemeInfoBar(
- const std::string& previous_theme_id, bool previous_using_native_theme,
- const Extension* new_theme, Profile* profile) {
- if (!new_theme->is_theme())
- return;
-
- // Get last active tabbed browser of profile.
- Browser* browser = browser::FindTabbedBrowser(profile,
- true,
- chrome::GetActiveDesktop());
- if (!browser)
- return;
-
- WebContents* web_contents = chrome::GetActiveWebContents(browser);
- if (!web_contents)
- return;
- InfoBarService* infobar_service =
- InfoBarService::FromWebContents(web_contents);
-
- // First find any previous theme preview infobars.
- InfoBarDelegate* old_delegate = NULL;
- for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) {
- InfoBarDelegate* delegate = infobar_service->GetInfoBarDelegateAt(i);
- ThemeInstalledInfoBarDelegate* theme_infobar =
- delegate->AsThemePreviewInfobarDelegate();
- if (theme_infobar) {
- // If the user installed the same theme twice, ignore the second install
- // and keep the first install info bar, so that they can easily undo to
- // get back the previous theme.
- if (theme_infobar->MatchesTheme(new_theme))
- return;
- old_delegate = delegate;
- break;
- }
- }
-
- // Then either replace that old one or add a new one.
- InfoBarDelegate* new_delegate = GetNewThemeInstalledInfoBarDelegate(
- web_contents, new_theme, previous_theme_id, previous_using_native_theme);
-
- if (old_delegate)
- infobar_service->ReplaceInfoBar(old_delegate, new_delegate);
- else
- infobar_service->AddInfoBar(new_delegate);
-}
-
-InfoBarDelegate* ExtensionInstallUIDefault::GetNewThemeInstalledInfoBarDelegate(
- WebContents* web_contents,
- const Extension* new_theme,
- const std::string& previous_theme_id,
- bool previous_using_native_theme) {
- Profile* profile =
- Profile::FromBrowserContext(web_contents->GetBrowserContext());
- return new ThemeInstalledInfoBarDelegate(
- InfoBarService::FromWebContents(web_contents),
- profile->GetExtensionService(),
- ThemeServiceFactory::GetForProfile(profile),
- new_theme,
- previous_theme_id,
- previous_using_native_theme);
-}
-
-// static
ExtensionInstallUI* ExtensionInstallUI::Create(Profile* profile) {
return new ExtensionInstallUIDefault(profile);
}
« no previous file with comments | « chrome/browser/extensions/extension_install_ui_default.h ('k') | chrome/browser/extensions/theme_installed_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698