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

Side by Side Diff: chrome/browser/extensions/theme_installed_infobar_delegate.cc

Issue 812823002: Remove dependency of infobars component on the embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation on Android Created 6 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" 5 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 if (!browser) 43 if (!browser)
44 return; 44 return;
45 content::WebContents* web_contents = 45 content::WebContents* web_contents =
46 browser->tab_strip_model()->GetActiveWebContents(); 46 browser->tab_strip_model()->GetActiveWebContents();
47 if (!web_contents) 47 if (!web_contents)
48 return; 48 return;
49 InfoBarService* infobar_service = 49 InfoBarService* infobar_service =
50 InfoBarService::FromWebContents(web_contents); 50 InfoBarService::FromWebContents(web_contents);
51 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); 51 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile);
52 scoped_ptr<infobars::InfoBar> new_infobar( 52 scoped_ptr<infobars::InfoBar> new_infobar(
53 ConfirmInfoBarDelegate::CreateInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( 53 infobar_service->CreateConfirmInfoBar(
54 new ThemeInstalledInfoBarDelegate( 54 scoped_ptr<ConfirmInfoBarDelegate>(new ThemeInstalledInfoBarDelegate(
55 extensions::ExtensionSystem::Get(profile)->extension_service(), 55 extensions::ExtensionSystem::Get(profile)->extension_service(),
56 theme_service, new_theme, 56 theme_service, new_theme, previous_theme_id,
57 previous_theme_id, previous_using_system_theme)))); 57 previous_using_system_theme))));
58 58
59 // If there's a previous theme infobar, just replace that instead of adding a 59 // If there's a previous theme infobar, just replace that instead of adding a
60 // new one. 60 // new one.
61 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { 61 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
62 infobars::InfoBar* old_infobar = infobar_service->infobar_at(i); 62 infobars::InfoBar* old_infobar = infobar_service->infobar_at(i);
63 ThemeInstalledInfoBarDelegate* theme_infobar = 63 ThemeInstalledInfoBarDelegate* theme_infobar =
64 old_infobar->delegate()->AsThemePreviewInfobarDelegate(); 64 old_infobar->delegate()->AsThemePreviewInfobarDelegate();
65 if (theme_infobar) { 65 if (theme_infobar) {
66 // If the user installed the same theme twice, ignore the second install 66 // If the user installed the same theme twice, ignore the second install
67 // and keep the first install info bar, so that they can easily undo to 67 // and keep the first install info bar, so that they can easily undo to
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 void ThemeInstalledInfoBarDelegate::Observe( 154 void ThemeInstalledInfoBarDelegate::Observe(
155 int type, 155 int type,
156 const content::NotificationSource& source, 156 const content::NotificationSource& source,
157 const content::NotificationDetails& details) { 157 const content::NotificationDetails& details) {
158 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); 158 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type);
159 // If the new theme is different from what this info bar is associated with, 159 // If the new theme is different from what this info bar is associated with,
160 // close this info bar since it is no longer relevant. 160 // close this info bar since it is no longer relevant.
161 if (theme_id_ != theme_service_->GetThemeID()) 161 if (theme_id_ != theme_service_->GetThemeID())
162 infobar()->RemoveSelf(); 162 infobar()->RemoveSelf();
163 } 163 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698