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

Side by Side Diff: chrome/browser/ui/extensions/extension_install_ui_default.cc

Issue 2799003002: Unpack theme data from extensions off of UI thread. (Closed)
Patch Set: fix gtk case Created 3 years, 6 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 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/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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 GURL ErrorInfoBarDelegate::GetLinkURL() const { 133 GURL ErrorInfoBarDelegate::GetLinkURL() const {
135 return GURL("https://support.google.com/chrome_webstore/?p=crx_warning"); 134 return GURL("https://support.google.com/chrome_webstore/?p=crx_warning");
136 } 135 }
137 136
138 } // namespace 137 } // namespace
139 138
140 ExtensionInstallUIDefault::ExtensionInstallUIDefault( 139 ExtensionInstallUIDefault::ExtensionInstallUIDefault(
141 content::BrowserContext* context) 140 content::BrowserContext* context)
142 : profile_(Profile::FromBrowserContext(context)), 141 : profile_(Profile::FromBrowserContext(context)),
143 skip_post_install_ui_(false), 142 skip_post_install_ui_(false),
144 previous_using_system_theme_(false), 143 use_app_installed_bubble_(false) {}
145 use_app_installed_bubble_(false) {
146 // |profile| can be NULL during tests.
147 if (profile_) {
148 // Remember the current theme in case the user presses undo.
149 const Extension* previous_theme =
150 ThemeServiceFactory::GetThemeForProfile(profile_);
151 if (previous_theme)
152 previous_theme_id_ = previous_theme->id();
153 previous_using_system_theme_ =
154 ThemeServiceFactory::GetForProfile(profile_)->UsingSystemTheme();
155 }
156 }
157 144
158 ExtensionInstallUIDefault::~ExtensionInstallUIDefault() {} 145 ExtensionInstallUIDefault::~ExtensionInstallUIDefault() {}
159 146
160 void ExtensionInstallUIDefault::OnInstallSuccess(const Extension* extension, 147 void ExtensionInstallUIDefault::OnInstallSuccess(const Extension* extension,
161 const SkBitmap* icon) { 148 const SkBitmap* icon) {
162 if (skip_post_install_ui_) 149 if (skip_post_install_ui_ || extension->is_theme())
163 return; 150 return;
164 151
165 if (!profile_) { 152 if (!profile_) {
166 // TODO(zelidrag): Figure out what exact conditions cause crash 153 // TODO(zelidrag): Figure out what exact conditions cause crash
167 // http://crbug.com/159437 and write browser test to cover it. 154 // http://crbug.com/159437 and write browser test to cover it.
168 NOTREACHED(); 155 NOTREACHED();
169 return; 156 return;
170 } 157 }
171 158
172 if (extension->is_theme()) {
173 ThemeInstalledInfoBarDelegate::Create(
174 extension, profile_, previous_theme_id_, previous_using_system_theme_);
175 return;
176 }
177
178 // Extensions aren't enabled by default in incognito so we confirm 159 // Extensions aren't enabled by default in incognito so we confirm
179 // the install in a normal window. 160 // the install in a normal window.
180 Profile* current_profile = profile_->GetOriginalProfile(); 161 Profile* current_profile = profile_->GetOriginalProfile();
181 if (extension->is_app()) { 162 if (extension->is_app()) {
182 bool use_bubble = false; 163 bool use_bubble = false;
183 164
184 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) 165 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX)
185 use_bubble = use_app_installed_bubble_; 166 use_bubble = use_app_installed_bubble_;
186 #endif 167 #endif
187 168
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 230
250 gfx::NativeWindow ExtensionInstallUIDefault::GetDefaultInstallDialogParent() { 231 gfx::NativeWindow ExtensionInstallUIDefault::GetDefaultInstallDialogParent() {
251 Browser* browser = chrome::FindLastActiveWithProfile(profile_); 232 Browser* browser = chrome::FindLastActiveWithProfile(profile_);
252 if (browser) { 233 if (browser) {
253 content::WebContents* contents = 234 content::WebContents* contents =
254 browser->tab_strip_model()->GetActiveWebContents(); 235 browser->tab_strip_model()->GetActiveWebContents();
255 return contents->GetTopLevelNativeWindow(); 236 return contents->GetTopLevelNativeWindow();
256 } 237 }
257 return NULL; 238 return NULL;
258 } 239 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698