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

Unified Diff: chrome/browser/ui/cocoa/keystone_infobar_delegate.mm

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/ui/cocoa/keystone_infobar_delegate.mm
===================================================================
--- chrome/browser/ui/cocoa/keystone_infobar_delegate.mm (revision 175396)
+++ chrome/browser/ui/cocoa/keystone_infobar_delegate.mm (working copy)
@@ -38,10 +38,13 @@
class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
+ // If there's an active tab, creates a keystone promotion delegate and adds it
+ // to the InfoBarService associated with that tab.
+ static void Create();
+
+ private:
KeystonePromotionInfoBarDelegate(InfoBarService* infobar_service,
PrefService* prefs);
-
- private:
virtual ~KeystonePromotionInfoBarDelegate();
// Sets this info bar to be able to expire. Called a predetermined amount
@@ -69,6 +72,24 @@
DISALLOW_COPY_AND_ASSIGN(KeystonePromotionInfoBarDelegate);
};
+// static
+void KeystonePromotionInfoBarDelegate::Create() {
+ Browser* browser = chrome::GetLastActiveBrowser();
+ if (browser) {
+ content::WebContents* webContents = chrome::GetActiveWebContents(browser);
+
+ if (webContents) {
+ InfoBarService* infobar_service =
+ InfoBarService::FromWebContents(webContents);
+ infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
+ new KeystonePromotionInfoBarDelegate(
+ infobar_service,
+ Profile::FromBrowserContext(
+ webContents->GetBrowserContext())->GetPrefs())));
+ }
+ }
+}
+
KeystonePromotionInfoBarDelegate::KeystonePromotionInfoBarDelegate(
InfoBarService* infobar_service,
PrefService* prefs)
@@ -189,24 +210,7 @@
if (status != kAutoupdateRegisterFailed &&
[[KeystoneGlue defaultKeystoneGlue] needsPromotion]) {
- Browser* browser = chrome::GetLastActiveBrowser();
- if (browser) {
- content::WebContents* webContents = chrome::GetActiveWebContents(browser);
-
- // Only show if no other info bars are showing, because that's how the
- // default browser info bar works.
- if (webContents) {
- InfoBarService* infobarService =
- InfoBarService::FromWebContents(webContents);
- if (infobarService->GetInfoBarCount() == 0) {
- infobarService->AddInfoBar(
- new KeystonePromotionInfoBarDelegate(
- infobarService,
- Profile::FromBrowserContext(
- webContents->GetBrowserContext())->GetPrefs()));
- }
- }
- }
+ KeystonePromotionInfoBarDelegate::Create();
}
[self release];
« no previous file with comments | « chrome/browser/ui/cocoa/infobars/infobar_controller.mm ('k') | chrome/browser/ui/collected_cookies_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698