| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/animation.h" | 7 #include "app/animation.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 Profile* profile = extensions_service_->profile(); | 241 Profile* profile = extensions_service_->profile(); |
| 242 | 242 |
| 243 // To give a more "launchy" experience when using the NTP launcher, we close | 243 // To give a more "launchy" experience when using the NTP launcher, we close |
| 244 // it automatically. | 244 // it automatically. |
| 245 Browser* browser = BrowserList::GetLastActive(); | 245 Browser* browser = BrowserList::GetLastActive(); |
| 246 TabContents* old_contents = NULL; | 246 TabContents* old_contents = NULL; |
| 247 if (browser) | 247 if (browser) |
| 248 old_contents = browser->GetSelectedTabContents(); | 248 old_contents = browser->GetSelectedTabContents(); |
| 249 | 249 |
| 250 AnimateAppIcon(extension, rect); | 250 AnimateAppIcon(extension, rect); |
| 251 |
| 252 extension_misc::LaunchContainer launch_container = |
| 253 extension->launch_container(); |
| 254 ExtensionPrefs::LaunchType prefs_launch_type = |
| 255 extensions_service_->extension_prefs()->GetLaunchType(extension_id); |
| 256 |
| 257 // If the user chose to open in a window, change the container type. |
| 258 if (prefs_launch_type == ExtensionPrefs::LAUNCH_WINDOW) { |
| 259 launch_container = extension_misc::LAUNCH_WINDOW; |
| 260 } |
| 261 |
| 251 TabContents* new_contents = Browser::OpenApplication( | 262 TabContents* new_contents = Browser::OpenApplication( |
| 252 profile, extension, extension->launch_container(), old_contents); | 263 profile, extension, launch_container, old_contents); |
| 253 | 264 |
| 254 if (new_contents != old_contents && browser->tab_count() > 1) | 265 if (new_contents != old_contents && browser->tab_count() > 1) |
| 255 browser->CloseTabContents(old_contents); | 266 browser->CloseTabContents(old_contents); |
| 256 | 267 |
| 257 if (extension_id != extension_misc::kWebStoreAppId) | 268 if (extension_id != extension_misc::kWebStoreAppId) |
| 258 RecordAppLaunch(promo_active_); | 269 RecordAppLaunch(promo_active_); |
| 259 } | 270 } |
| 260 | 271 |
| 261 void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) { | 272 void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) { |
| 262 std::string extension_id; | 273 std::string extension_id; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 314 |
| 304 for (ExtensionIdSet::const_iterator iter = app_ids->begin(); | 315 for (ExtensionIdSet::const_iterator iter = app_ids->begin(); |
| 305 iter != app_ids->end(); ++iter) { | 316 iter != app_ids->end(); ++iter) { |
| 306 if (extensions_service_->GetExtensionById(*iter, true)) | 317 if (extensions_service_->GetExtensionById(*iter, true)) |
| 307 extensions_service_->UninstallExtension(*iter, false); | 318 extensions_service_->UninstallExtension(*iter, false); |
| 308 } | 319 } |
| 309 | 320 |
| 310 extensions_service_->default_apps()->SetPromoHidden(); | 321 extensions_service_->default_apps()->SetPromoHidden(); |
| 311 } | 322 } |
| 312 | 323 |
| 313 //static | 324 // static |
| 314 void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) { | 325 void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) { |
| 315 if (!promo_active) return; | 326 if (!promo_active) return; |
| 316 | 327 |
| 317 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, | 328 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, |
| 318 extension_misc::PROMO_LAUNCH_WEB_STORE, | 329 extension_misc::PROMO_LAUNCH_WEB_STORE, |
| 319 extension_misc::PROMO_BUCKET_BOUNDARY); | 330 extension_misc::PROMO_BUCKET_BOUNDARY); |
| 320 } | 331 } |
| 321 | 332 |
| 322 //static | 333 // static |
| 323 void AppLauncherHandler::RecordAppLaunch(bool promo_active) { | 334 void AppLauncherHandler::RecordAppLaunch(bool promo_active) { |
| 324 // TODO(jstritar): record app launches that occur when the promo is not | 335 // TODO(jstritar): record app launches that occur when the promo is not |
| 325 // active using a different histogram. | 336 // active using a different histogram. |
| 326 | 337 |
| 327 if (!promo_active) return; | 338 if (!promo_active) return; |
| 328 | 339 |
| 329 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, | 340 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, |
| 330 extension_misc::PROMO_LAUNCH_APP, | 341 extension_misc::PROMO_LAUNCH_APP, |
| 331 extension_misc::PROMO_BUCKET_BOUNDARY); | 342 extension_misc::PROMO_BUCKET_BOUNDARY); |
| 332 } | 343 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 361 // We make this check for the case of minimized windows, unit tests, etc. | 372 // We make this check for the case of minimized windows, unit tests, etc. |
| 362 if (platform_util::IsVisible(dom_ui_->tab_contents()->GetNativeView()) && | 373 if (platform_util::IsVisible(dom_ui_->tab_contents()->GetNativeView()) && |
| 363 Animation::ShouldRenderRichAnimation()) { | 374 Animation::ShouldRenderRichAnimation()) { |
| 364 #if defined(OS_WIN) | 375 #if defined(OS_WIN) |
| 365 AppLaunchedAnimation::Show(extension, rect); | 376 AppLaunchedAnimation::Show(extension, rect); |
| 366 #else | 377 #else |
| 367 NOTIMPLEMENTED(); | 378 NOTIMPLEMENTED(); |
| 368 #endif | 379 #endif |
| 369 } | 380 } |
| 370 } | 381 } |
| OLD | NEW |