OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 const std::string& previous_theme_id, | 34 const std::string& previous_theme_id, |
35 bool previous_using_system_theme) { | 35 bool previous_using_system_theme) { |
36 DCHECK(new_theme); | 36 DCHECK(new_theme); |
37 if (!new_theme->is_theme()) | 37 if (!new_theme->is_theme()) |
38 return; | 38 return; |
39 | 39 |
40 // Create the new infobar. | 40 // Create the new infobar. |
41 // FindTabbedBrowser() is called with |match_original_profiles| true because a | 41 // FindTabbedBrowser() is called with |match_original_profiles| true because a |
42 // theme install in either a normal or incognito window for a profile affects | 42 // theme install in either a normal or incognito window for a profile affects |
43 // all normal and incognito windows for that profile. | 43 // all normal and incognito windows for that profile. |
44 Browser* browser = | 44 Browser* browser = chrome::FindTabbedBrowser(profile, true); |
45 chrome::FindTabbedBrowser(profile, true, chrome::GetActiveDesktop()); | |
46 if (!browser) | 45 if (!browser) |
47 return; | 46 return; |
48 content::WebContents* web_contents = | 47 content::WebContents* web_contents = |
49 browser->tab_strip_model()->GetActiveWebContents(); | 48 browser->tab_strip_model()->GetActiveWebContents(); |
50 if (!web_contents) | 49 if (!web_contents) |
51 return; | 50 return; |
52 InfoBarService* infobar_service = | 51 InfoBarService* infobar_service = |
53 InfoBarService::FromWebContents(web_contents); | 52 InfoBarService::FromWebContents(web_contents); |
54 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); | 53 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); |
55 scoped_ptr<infobars::InfoBar> new_infobar( | 54 scoped_ptr<infobars::InfoBar> new_infobar( |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 void ThemeInstalledInfoBarDelegate::Observe( | 167 void ThemeInstalledInfoBarDelegate::Observe( |
169 int type, | 168 int type, |
170 const content::NotificationSource& source, | 169 const content::NotificationSource& source, |
171 const content::NotificationDetails& details) { | 170 const content::NotificationDetails& details) { |
172 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); | 171 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); |
173 // If the new theme is different from what this info bar is associated with, | 172 // If the new theme is different from what this info bar is associated with, |
174 // close this info bar since it is no longer relevant. | 173 // close this info bar since it is no longer relevant. |
175 if (theme_id_ != theme_service_->GetThemeID()) | 174 if (theme_id_ != theme_service_->GetThemeID()) |
176 infobar()->RemoveSelf(); | 175 infobar()->RemoveSelf(); |
177 } | 176 } |
OLD | NEW |