| 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/command_line.h" | 8 #include "base/command_line.h" |
| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // No browser window is open yet. Create a free-standing dialog associated | 197 // No browser window is open yet. Create a free-standing dialog associated |
| 198 // with |profile|. | 198 // with |profile|. |
| 199 return new ExtensionInstallPrompt(profile, NULL, NULL); | 199 return new ExtensionInstallPrompt(profile, NULL, NULL); |
| 200 } | 200 } |
| 201 | 201 |
| 202 | 202 |
| 203 // ExtensionInstallUIDefault -------------------------------------------------- | 203 // ExtensionInstallUIDefault -------------------------------------------------- |
| 204 | 204 |
| 205 ExtensionInstallUIDefault::ExtensionInstallUIDefault(Profile* profile) | 205 ExtensionInstallUIDefault::ExtensionInstallUIDefault(Profile* profile) |
| 206 : ExtensionInstallUI(profile), | 206 : ExtensionInstallUI(profile), |
| 207 previous_using_native_theme_(false), | 207 previous_using_system_theme_(false), |
| 208 use_app_installed_bubble_(false) { | 208 use_app_installed_bubble_(false) { |
| 209 // |profile| can be NULL during tests. | 209 // |profile| can be NULL during tests. |
| 210 if (profile) { | 210 if (profile) { |
| 211 // Remember the current theme in case the user presses undo. | 211 // Remember the current theme in case the user presses undo. |
| 212 const Extension* previous_theme = | 212 const Extension* previous_theme = |
| 213 ThemeServiceFactory::GetThemeForProfile(profile); | 213 ThemeServiceFactory::GetThemeForProfile(profile); |
| 214 if (previous_theme) | 214 if (previous_theme) |
| 215 previous_theme_id_ = previous_theme->id(); | 215 previous_theme_id_ = previous_theme->id(); |
| 216 previous_using_native_theme_ = | 216 previous_using_system_theme_ = |
| 217 ThemeServiceFactory::GetForProfile(profile)->UsingNativeTheme(); | 217 ThemeServiceFactory::GetForProfile(profile)->UsingSystemTheme(); |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 ExtensionInstallUIDefault::~ExtensionInstallUIDefault() {} | 221 ExtensionInstallUIDefault::~ExtensionInstallUIDefault() {} |
| 222 | 222 |
| 223 void ExtensionInstallUIDefault::OnInstallSuccess(const Extension* extension, | 223 void ExtensionInstallUIDefault::OnInstallSuccess(const Extension* extension, |
| 224 SkBitmap* icon) { | 224 SkBitmap* icon) { |
| 225 if (skip_post_install_ui()) | 225 if (skip_post_install_ui()) |
| 226 return; | 226 return; |
| 227 | 227 |
| 228 if (!profile()) { | 228 if (!profile()) { |
| 229 // TODO(zelidrag): Figure out what exact conditions cause crash | 229 // TODO(zelidrag): Figure out what exact conditions cause crash |
| 230 // http://crbug.com/159437 and write browser test to cover it. | 230 // http://crbug.com/159437 and write browser test to cover it. |
| 231 NOTREACHED(); | 231 NOTREACHED(); |
| 232 return; | 232 return; |
| 233 } | 233 } |
| 234 | 234 |
| 235 if (extension->is_theme()) { | 235 if (extension->is_theme()) { |
| 236 ThemeInstalledInfoBarDelegate::Create( | 236 ThemeInstalledInfoBarDelegate::Create( |
| 237 extension, profile(), previous_theme_id_, previous_using_native_theme_); | 237 extension, profile(), previous_theme_id_, previous_using_system_theme_); |
| 238 return; | 238 return; |
| 239 } | 239 } |
| 240 | 240 |
| 241 // Extensions aren't enabled by default in incognito so we confirm | 241 // Extensions aren't enabled by default in incognito so we confirm |
| 242 // the install in a normal window. | 242 // the install in a normal window. |
| 243 Profile* current_profile = profile()->GetOriginalProfile(); | 243 Profile* current_profile = profile()->GetOriginalProfile(); |
| 244 if (extension->is_app()) { | 244 if (extension->is_app()) { |
| 245 bool use_bubble = false; | 245 bool use_bubble = false; |
| 246 | 246 |
| 247 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) | 247 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 browser->tab_strip_model()->GetActiveWebContents(); | 289 browser->tab_strip_model()->GetActiveWebContents(); |
| 290 if (!web_contents) | 290 if (!web_contents) |
| 291 return; | 291 return; |
| 292 ErrorInfoBarDelegate::Create(InfoBarService::FromWebContents(web_contents), | 292 ErrorInfoBarDelegate::Create(InfoBarService::FromWebContents(web_contents), |
| 293 error); | 293 error); |
| 294 } | 294 } |
| 295 | 295 |
| 296 void ExtensionInstallUIDefault::SetUseAppInstalledBubble(bool use_bubble) { | 296 void ExtensionInstallUIDefault::SetUseAppInstalledBubble(bool use_bubble) { |
| 297 use_app_installed_bubble_ = use_bubble; | 297 use_app_installed_bubble_ = use_bubble; |
| 298 } | 298 } |
| OLD | NEW |