| 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" |
| 12 #include "chrome/browser/infobars/infobar_service.h" | 13 #include "chrome/browser/infobars/infobar_service.h" |
| 13 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 14 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/themes/theme_service.h" | 16 #include "chrome/browser/themes/theme_service.h" |
| 16 #include "chrome/browser/themes/theme_service_factory.h" | 17 #include "chrome/browser/themes/theme_service_factory.h" |
| 17 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
| 19 #include "chrome/browser/ui/browser_navigator.h" | 20 #include "chrome/browser/ui/browser_navigator.h" |
| 20 #include "chrome/browser/ui/browser_navigator_params.h" | 21 #include "chrome/browser/ui/browser_navigator_params.h" |
| 21 #include "chrome/browser/ui/browser_tabstrip.h" | 22 #include "chrome/browser/ui/browser_tabstrip.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 GURL ErrorInfoBarDelegate::GetLinkURL() const { | 134 GURL ErrorInfoBarDelegate::GetLinkURL() const { |
| 134 return GURL("https://support.google.com/chrome_webstore/?p=crx_warning"); | 135 return GURL("https://support.google.com/chrome_webstore/?p=crx_warning"); |
| 135 } | 136 } |
| 136 | 137 |
| 137 } // namespace | 138 } // namespace |
| 138 | 139 |
| 139 ExtensionInstallUIDefault::ExtensionInstallUIDefault( | 140 ExtensionInstallUIDefault::ExtensionInstallUIDefault( |
| 140 content::BrowserContext* context) | 141 content::BrowserContext* context) |
| 141 : profile_(Profile::FromBrowserContext(context)), | 142 : profile_(Profile::FromBrowserContext(context)), |
| 142 skip_post_install_ui_(false), | 143 skip_post_install_ui_(false), |
| 143 use_app_installed_bubble_(false) {} | 144 previous_using_system_theme_(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 } |
| 144 | 157 |
| 145 ExtensionInstallUIDefault::~ExtensionInstallUIDefault() {} | 158 ExtensionInstallUIDefault::~ExtensionInstallUIDefault() {} |
| 146 | 159 |
| 147 void ExtensionInstallUIDefault::OnInstallSuccess(const Extension* extension, | 160 void ExtensionInstallUIDefault::OnInstallSuccess(const Extension* extension, |
| 148 const SkBitmap* icon) { | 161 const SkBitmap* icon) { |
| 149 if (skip_post_install_ui_ || extension->is_theme()) | 162 if (skip_post_install_ui_) |
| 150 return; | 163 return; |
| 151 | 164 |
| 152 if (!profile_) { | 165 if (!profile_) { |
| 153 // TODO(zelidrag): Figure out what exact conditions cause crash | 166 // TODO(zelidrag): Figure out what exact conditions cause crash |
| 154 // http://crbug.com/159437 and write browser test to cover it. | 167 // http://crbug.com/159437 and write browser test to cover it. |
| 155 NOTREACHED(); | 168 NOTREACHED(); |
| 156 return; | 169 return; |
| 157 } | 170 } |
| 158 | 171 |
| 172 if (extension->is_theme()) { |
| 173 ThemeInstalledInfoBarDelegate::Create( |
| 174 extension, profile_, previous_theme_id_, previous_using_system_theme_); |
| 175 return; |
| 176 } |
| 177 |
| 159 // Extensions aren't enabled by default in incognito so we confirm | 178 // Extensions aren't enabled by default in incognito so we confirm |
| 160 // the install in a normal window. | 179 // the install in a normal window. |
| 161 Profile* current_profile = profile_->GetOriginalProfile(); | 180 Profile* current_profile = profile_->GetOriginalProfile(); |
| 162 if (extension->is_app()) { | 181 if (extension->is_app()) { |
| 163 bool use_bubble = false; | 182 bool use_bubble = false; |
| 164 | 183 |
| 165 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) | 184 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) |
| 166 use_bubble = use_app_installed_bubble_; | 185 use_bubble = use_app_installed_bubble_; |
| 167 #endif | 186 #endif |
| 168 | 187 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 249 |
| 231 gfx::NativeWindow ExtensionInstallUIDefault::GetDefaultInstallDialogParent() { | 250 gfx::NativeWindow ExtensionInstallUIDefault::GetDefaultInstallDialogParent() { |
| 232 Browser* browser = chrome::FindLastActiveWithProfile(profile_); | 251 Browser* browser = chrome::FindLastActiveWithProfile(profile_); |
| 233 if (browser) { | 252 if (browser) { |
| 234 content::WebContents* contents = | 253 content::WebContents* contents = |
| 235 browser->tab_strip_model()->GetActiveWebContents(); | 254 browser->tab_strip_model()->GetActiveWebContents(); |
| 236 return contents->GetTopLevelNativeWindow(); | 255 return contents->GetTopLevelNativeWindow(); |
| 237 } | 256 } |
| 238 return NULL; | 257 return NULL; |
| 239 } | 258 } |
| OLD | NEW |