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/ui/extensions/extension_install_ui_default.h" | 5 #include "chrome/browser/ui/extensions/extension_install_ui_default.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" | |
13 #include "chrome/browser/infobars/infobar_service.h" | 12 #include "chrome/browser/infobars/infobar_service.h" |
14 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 13 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
15 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/themes/theme_service.h" | 15 #include "chrome/browser/themes/theme_service.h" |
17 #include "chrome/browser/themes/theme_service_factory.h" | 16 #include "chrome/browser/themes/theme_service_factory.h" |
18 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_finder.h" | 18 #include "chrome/browser/ui/browser_finder.h" |
20 #include "chrome/browser/ui/browser_navigator.h" | 19 #include "chrome/browser/ui/browser_navigator.h" |
21 #include "chrome/browser/ui/browser_navigator_params.h" | 20 #include "chrome/browser/ui/browser_navigator_params.h" |
22 #include "chrome/browser/ui/browser_tabstrip.h" | 21 #include "chrome/browser/ui/browser_tabstrip.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 GURL ErrorInfoBarDelegate::GetLinkURL() const { | 134 GURL ErrorInfoBarDelegate::GetLinkURL() const { |
136 return GURL("https://support.google.com/chrome_webstore/?p=crx_warning"); | 135 return GURL("https://support.google.com/chrome_webstore/?p=crx_warning"); |
137 } | 136 } |
138 | 137 |
139 } // namespace | 138 } // namespace |
140 | 139 |
141 ExtensionInstallUIDefault::ExtensionInstallUIDefault( | 140 ExtensionInstallUIDefault::ExtensionInstallUIDefault( |
142 content::BrowserContext* context) | 141 content::BrowserContext* context) |
143 : profile_(Profile::FromBrowserContext(context)), | 142 : profile_(Profile::FromBrowserContext(context)), |
144 skip_post_install_ui_(false), | 143 skip_post_install_ui_(false), |
145 previous_using_system_theme_(false), | 144 use_app_installed_bubble_(false) {} |
146 use_app_installed_bubble_(false) { | |
147 // |profile| can be NULL during tests. | |
148 if (profile_) { | |
149 // Remember the current theme in case the user presses undo. | |
150 const Extension* previous_theme = | |
151 ThemeServiceFactory::GetThemeForProfile(profile_); | |
152 if (previous_theme) | |
153 previous_theme_id_ = previous_theme->id(); | |
154 previous_using_system_theme_ = | |
155 ThemeServiceFactory::GetForProfile(profile_)->UsingSystemTheme(); | |
156 } | |
157 } | |
158 | 145 |
159 ExtensionInstallUIDefault::~ExtensionInstallUIDefault() {} | 146 ExtensionInstallUIDefault::~ExtensionInstallUIDefault() {} |
160 | 147 |
161 void ExtensionInstallUIDefault::OnInstallSuccess(const Extension* extension, | 148 void ExtensionInstallUIDefault::OnInstallSuccess(const Extension* extension, |
162 const SkBitmap* icon) { | 149 const SkBitmap* icon) { |
163 if (skip_post_install_ui_) | 150 if (skip_post_install_ui_ || extension->is_theme()) |
164 return; | 151 return; |
165 | 152 |
166 if (!profile_) { | 153 if (!profile_) { |
167 // TODO(zelidrag): Figure out what exact conditions cause crash | 154 // TODO(zelidrag): Figure out what exact conditions cause crash |
168 // http://crbug.com/159437 and write browser test to cover it. | 155 // http://crbug.com/159437 and write browser test to cover it. |
169 NOTREACHED(); | 156 NOTREACHED(); |
170 return; | 157 return; |
171 } | 158 } |
172 | 159 |
173 if (extension->is_theme()) { | |
174 ThemeInstalledInfoBarDelegate::Create( | |
Devlin
2017/06/01 00:28:09
Does moving this out of here and into ThemeService
Evan Stade
2017/06/01 17:43:02
Before, the browser would immediately hang for a s
Devlin
2017/06/01 18:19:58
Okay, cool. My concern was if before the flow was
| |
175 extension, profile_, previous_theme_id_, previous_using_system_theme_); | |
176 return; | |
177 } | |
178 | |
179 // Extensions aren't enabled by default in incognito so we confirm | 160 // Extensions aren't enabled by default in incognito so we confirm |
180 // the install in a normal window. | 161 // the install in a normal window. |
181 Profile* current_profile = profile_->GetOriginalProfile(); | 162 Profile* current_profile = profile_->GetOriginalProfile(); |
182 if (extension->is_app()) { | 163 if (extension->is_app()) { |
183 bool use_bubble = false; | 164 bool use_bubble = false; |
184 | 165 |
185 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) | 166 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) |
186 use_bubble = use_app_installed_bubble_; | 167 use_bubble = use_app_installed_bubble_; |
187 #endif | 168 #endif |
188 | 169 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 | 231 |
251 gfx::NativeWindow ExtensionInstallUIDefault::GetDefaultInstallDialogParent() { | 232 gfx::NativeWindow ExtensionInstallUIDefault::GetDefaultInstallDialogParent() { |
252 Browser* browser = chrome::FindLastActiveWithProfile(profile_); | 233 Browser* browser = chrome::FindLastActiveWithProfile(profile_); |
253 if (browser) { | 234 if (browser) { |
254 content::WebContents* contents = | 235 content::WebContents* contents = |
255 browser->tab_strip_model()->GetActiveWebContents(); | 236 browser->tab_strip_model()->GetActiveWebContents(); |
256 return contents->GetTopLevelNativeWindow(); | 237 return contents->GetTopLevelNativeWindow(); |
257 } | 238 } |
258 return NULL; | 239 return NULL; |
259 } | 240 } |
OLD | NEW |