| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/dom_ui/app_launcher_handler.h" | 5 #include "chrome/browser/dom_ui/app_launcher_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/string_split.h" | 12 #include "base/string_split.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/app_launched_animation.h" | |
| 17 #include "chrome/browser/dom_ui/shown_sections_handler.h" | 16 #include "chrome/browser/dom_ui/shown_sections_handler.h" |
| 18 #include "chrome/browser/extensions/default_apps.h" | 17 #include "chrome/browser/extensions/default_apps.h" |
| 19 #include "chrome/browser/extensions/extension_prefs.h" | 18 #include "chrome/browser/extensions/extension_prefs.h" |
| 20 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
| 21 #include "chrome/browser/platform_util.h" | 20 #include "chrome/browser/platform_util.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/tab_contents/tab_contents.h" | 22 #include "chrome/browser/tab_contents/tab_contents.h" |
| 24 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 25 #include "chrome/browser/ui/browser_list.h" | 24 #include "chrome/browser/ui/browser_list.h" |
| 26 #include "chrome/browser/ui/browser_window.h" | 25 #include "chrome/browser/ui/browser_window.h" |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 DCHECK(extension); | 297 DCHECK(extension); |
| 299 Profile* profile = extensions_service_->profile(); | 298 Profile* profile = extensions_service_->profile(); |
| 300 | 299 |
| 301 // To give a more "launchy" experience when using the NTP launcher, we close | 300 // To give a more "launchy" experience when using the NTP launcher, we close |
| 302 // it automatically. | 301 // it automatically. |
| 303 Browser* browser = BrowserList::GetLastActive(); | 302 Browser* browser = BrowserList::GetLastActive(); |
| 304 TabContents* old_contents = NULL; | 303 TabContents* old_contents = NULL; |
| 305 if (browser) | 304 if (browser) |
| 306 old_contents = browser->GetSelectedTabContents(); | 305 old_contents = browser->GetSelectedTabContents(); |
| 307 | 306 |
| 308 AnimateAppIcon(extension, rect); | |
| 309 | |
| 310 // Look at preference to find the right launch container. If no preference | 307 // Look at preference to find the right launch container. If no preference |
| 311 // is set, launch as a regular tab. | 308 // is set, launch as a regular tab. |
| 312 extension_misc::LaunchContainer launch_container = | 309 extension_misc::LaunchContainer launch_container = |
| 313 extensions_service_->extension_prefs()->GetLaunchContainer( | 310 extensions_service_->extension_prefs()->GetLaunchContainer( |
| 314 extension, ExtensionPrefs::LAUNCH_REGULAR); | 311 extension, ExtensionPrefs::LAUNCH_REGULAR); |
| 315 | 312 |
| 316 TabContents* new_contents = Browser::OpenApplication( | 313 TabContents* new_contents = Browser::OpenApplication( |
| 317 profile, extension, launch_container, old_contents); | 314 profile, extension, launch_container, old_contents); |
| 318 | 315 |
| 319 if (new_contents != old_contents && browser->tab_count() > 1) | 316 if (new_contents != old_contents && browser->tab_count() > 1) |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 void AppLauncherHandler::InstallUIAbort() { | 439 void AppLauncherHandler::InstallUIAbort() { |
| 443 extension_id_prompting_ = ""; | 440 extension_id_prompting_ = ""; |
| 444 } | 441 } |
| 445 | 442 |
| 446 ExtensionInstallUI* AppLauncherHandler::GetExtensionInstallUI() { | 443 ExtensionInstallUI* AppLauncherHandler::GetExtensionInstallUI() { |
| 447 if (!install_ui_.get()) | 444 if (!install_ui_.get()) |
| 448 install_ui_.reset(new ExtensionInstallUI(dom_ui_->GetProfile())); | 445 install_ui_.reset(new ExtensionInstallUI(dom_ui_->GetProfile())); |
| 449 return install_ui_.get(); | 446 return install_ui_.get(); |
| 450 } | 447 } |
| 451 | 448 |
| 452 void AppLauncherHandler::AnimateAppIcon(const Extension* extension, | |
| 453 const gfx::Rect& rect) { | |
| 454 // We make this check for the case of minimized windows, unit tests, etc. | |
| 455 if (platform_util::IsVisible(dom_ui_->tab_contents()->GetNativeView()) && | |
| 456 ui::Animation::ShouldRenderRichAnimation()) { | |
| 457 #if defined(OS_WIN) | |
| 458 AppLaunchedAnimation::Show(extension, rect); | |
| 459 #else | |
| 460 NOTIMPLEMENTED(); | |
| 461 #endif | |
| 462 } | |
| 463 } | |
| 464 | |
| 465 void AppLauncherHandler::UninstallDefaultApps() { | 449 void AppLauncherHandler::UninstallDefaultApps() { |
| 466 DefaultApps* default_apps = extensions_service_->default_apps(); | 450 DefaultApps* default_apps = extensions_service_->default_apps(); |
| 467 const ExtensionIdSet& app_ids = default_apps->default_apps(); | 451 const ExtensionIdSet& app_ids = default_apps->default_apps(); |
| 468 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); | 452 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); |
| 469 iter != app_ids.end(); ++iter) { | 453 iter != app_ids.end(); ++iter) { |
| 470 if (extensions_service_->GetExtensionById(*iter, true)) | 454 if (extensions_service_->GetExtensionById(*iter, true)) |
| 471 extensions_service_->UninstallExtension(*iter, false); | 455 extensions_service_->UninstallExtension(*iter, false); |
| 472 } | 456 } |
| 473 } | 457 } |
| OLD | NEW |