| 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 "apps/app_launcher.h" | 7 #include "apps/app_launcher.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 return browser; | 63 return browser; |
| 64 } | 64 } |
| 65 | 65 |
| 66 void ShowExtensionInstalledBubble(const extensions::Extension* extension, | 66 void ShowExtensionInstalledBubble(const extensions::Extension* extension, |
| 67 Profile* profile, | 67 Profile* profile, |
| 68 const SkBitmap& icon) { | 68 const SkBitmap& icon) { |
| 69 Browser* browser = FindOrCreateVisibleBrowser(profile); | 69 Browser* browser = FindOrCreateVisibleBrowser(profile); |
| 70 chrome::ShowExtensionInstalledBubble(extension, browser, icon); | 70 chrome::ShowExtensionInstalledBubble(extension, browser, icon); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void OnAppLauncherEnabledCompleted(const extensions::Extension* extension, | |
| 74 Profile* profile, | |
| 75 SkBitmap* icon, | |
| 76 bool use_bubble, | |
| 77 bool use_launcher) { | |
| 78 if (use_launcher) { | |
| 79 AppListService::Get()->ShowAppList(profile); | |
| 80 | |
| 81 content::NotificationService::current()->Notify( | |
| 82 chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST, | |
| 83 content::Source<Profile>(profile), | |
| 84 content::Details<const std::string>(&extension->id())); | |
| 85 return; | |
| 86 } | |
| 87 | |
| 88 if (use_bubble) { | |
| 89 ShowExtensionInstalledBubble(extension, profile, *icon); | |
| 90 return; | |
| 91 } | |
| 92 | |
| 93 ExtensionInstallUI::OpenAppInstalledUI(profile, extension->id()); | |
| 94 } | |
| 95 | |
| 96 | |
| 97 // ErrorInfobarDelegate ------------------------------------------------------- | 73 // ErrorInfobarDelegate ------------------------------------------------------- |
| 98 | 74 |
| 99 // Helper class to put up an infobar when installation fails. | 75 // Helper class to put up an infobar when installation fails. |
| 100 class ErrorInfobarDelegate : public ConfirmInfoBarDelegate { | 76 class ErrorInfobarDelegate : public ConfirmInfoBarDelegate { |
| 101 public: | 77 public: |
| 102 // Creates an error delegate and adds it to |infobar_service|. | 78 // Creates an error delegate and adds it to |infobar_service|. |
| 103 static void Create(InfoBarService* infobar_service, | 79 static void Create(InfoBarService* infobar_service, |
| 104 const extensions::CrxInstallerError& error); | 80 const extensions::CrxInstallerError& error); |
| 105 | 81 |
| 106 private: | 82 private: |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 Profile* current_profile = profile_->GetOriginalProfile(); | 234 Profile* current_profile = profile_->GetOriginalProfile(); |
| 259 if (extension->is_app()) { | 235 if (extension->is_app()) { |
| 260 bool use_bubble = false; | 236 bool use_bubble = false; |
| 261 | 237 |
| 262 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) | 238 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) |
| 263 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 239 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
| 264 use_bubble = (use_app_installed_bubble_ || | 240 use_bubble = (use_app_installed_bubble_ || |
| 265 cmdline->HasSwitch(switches::kAppsNewInstallBubble)); | 241 cmdline->HasSwitch(switches::kAppsNewInstallBubble)); |
| 266 #endif | 242 #endif |
| 267 | 243 |
| 268 apps::GetIsAppLauncherEnabled( | 244 if (apps::IsAppLauncherEnabled()) { |
| 269 base::Bind(&OnAppLauncherEnabledCompleted, extension, current_profile, | 245 AppListService::Get()->ShowAppList(current_profile); |
| 270 icon, use_bubble)); | 246 |
| 247 content::NotificationService::current()->Notify( |
| 248 chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST, |
| 249 content::Source<Profile>(current_profile), |
| 250 content::Details<const std::string>(&extension->id())); |
| 251 return; |
| 252 } |
| 253 |
| 254 if (use_bubble) { |
| 255 ShowExtensionInstalledBubble(extension, current_profile, *icon); |
| 256 return; |
| 257 } |
| 258 |
| 259 ExtensionInstallUI::OpenAppInstalledUI(current_profile, extension->id()); |
| 271 return; | 260 return; |
| 272 } | 261 } |
| 273 | 262 |
| 274 ShowExtensionInstalledBubble(extension, current_profile, *icon); | 263 ShowExtensionInstalledBubble(extension, current_profile, *icon); |
| 275 } | 264 } |
| 276 | 265 |
| 277 void ExtensionInstallUIDefault::OnInstallFailure( | 266 void ExtensionInstallUIDefault::OnInstallFailure( |
| 278 const extensions::CrxInstallerError& error) { | 267 const extensions::CrxInstallerError& error) { |
| 279 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 280 if (disable_failure_ui_for_tests || skip_post_install_ui_) | 269 if (disable_failure_ui_for_tests || skip_post_install_ui_) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 292 error); | 281 error); |
| 293 } | 282 } |
| 294 | 283 |
| 295 void ExtensionInstallUIDefault::SetSkipPostInstallUI(bool skip_ui) { | 284 void ExtensionInstallUIDefault::SetSkipPostInstallUI(bool skip_ui) { |
| 296 skip_post_install_ui_ = skip_ui; | 285 skip_post_install_ui_ = skip_ui; |
| 297 } | 286 } |
| 298 | 287 |
| 299 void ExtensionInstallUIDefault::SetUseAppInstalledBubble(bool use_bubble) { | 288 void ExtensionInstallUIDefault::SetUseAppInstalledBubble(bool use_bubble) { |
| 300 use_app_installed_bubble_ = use_bubble; | 289 use_app_installed_bubble_ = use_bubble; |
| 301 } | 290 } |
| OLD | NEW |