| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 default_apps->DidShowPromo(); | 183 default_apps->DidShowPromo(); |
| 184 promo_active_ = true; | 184 promo_active_ = true; |
| 185 } else { | 185 } else { |
| 186 dictionary->SetBoolean("showPromo", false); | 186 dictionary->SetBoolean("showPromo", false); |
| 187 promo_active_ = false; | 187 promo_active_ = false; |
| 188 } | 188 } |
| 189 | 189 |
| 190 bool showLauncher = | 190 bool showLauncher = |
| 191 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppLauncher); | 191 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppLauncher); |
| 192 dictionary->SetBoolean("showLauncher", showLauncher); | 192 dictionary->SetBoolean("showLauncher", showLauncher); |
| 193 |
| 194 #if defined(OS_MACOSX) |
| 195 // App windows are not yet implemented on mac. |
| 196 bool disable_app_window_launch = true; |
| 197 #else |
| 198 bool disable_app_window_launch = false; |
| 199 #endif |
| 200 dictionary->SetBoolean("disableAppWindowLaunch", disable_app_window_launch); |
| 193 } | 201 } |
| 194 | 202 |
| 195 void AppLauncherHandler::HandleGetApps(const ListValue* args) { | 203 void AppLauncherHandler::HandleGetApps(const ListValue* args) { |
| 196 DictionaryValue dictionary; | 204 DictionaryValue dictionary; |
| 197 FillAppDictionary(&dictionary); | 205 FillAppDictionary(&dictionary); |
| 198 dom_ui_->CallJavascriptFunction(L"getAppsCallback", dictionary); | 206 dom_ui_->CallJavascriptFunction(L"getAppsCallback", dictionary); |
| 199 | 207 |
| 200 // First time we get here we set up the observer so that we can tell update | 208 // First time we get here we set up the observer so that we can tell update |
| 201 // the apps as they change. | 209 // the apps as they change. |
| 202 if (registrar_.IsEmpty()) { | 210 if (registrar_.IsEmpty()) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 Profile* profile = extensions_service_->profile(); | 249 Profile* profile = extensions_service_->profile(); |
| 242 | 250 |
| 243 // To give a more "launchy" experience when using the NTP launcher, we close | 251 // To give a more "launchy" experience when using the NTP launcher, we close |
| 244 // it automatically. | 252 // it automatically. |
| 245 Browser* browser = BrowserList::GetLastActive(); | 253 Browser* browser = BrowserList::GetLastActive(); |
| 246 TabContents* old_contents = NULL; | 254 TabContents* old_contents = NULL; |
| 247 if (browser) | 255 if (browser) |
| 248 old_contents = browser->GetSelectedTabContents(); | 256 old_contents = browser->GetSelectedTabContents(); |
| 249 | 257 |
| 250 AnimateAppIcon(extension, rect); | 258 AnimateAppIcon(extension, rect); |
| 259 |
| 260 extension_misc::LaunchContainer launch_container = |
| 261 extension->launch_container(); |
| 262 ExtensionPrefs::LaunchType prefs_launch_type = |
| 263 extensions_service_->extension_prefs()->GetLaunchType(extension_id); |
| 264 |
| 265 // If the user chose to open in a window, change the container type. |
| 266 if (prefs_launch_type == ExtensionPrefs::LAUNCH_WINDOW) |
| 267 launch_container = extension_misc::LAUNCH_WINDOW; |
| 268 |
| 251 TabContents* new_contents = Browser::OpenApplication( | 269 TabContents* new_contents = Browser::OpenApplication( |
| 252 profile, extension, extension->launch_container(), old_contents); | 270 profile, extension, launch_container, old_contents); |
| 253 | 271 |
| 254 if (new_contents != old_contents && browser->tab_count() > 1) | 272 if (new_contents != old_contents && browser->tab_count() > 1) |
| 255 browser->CloseTabContents(old_contents); | 273 browser->CloseTabContents(old_contents); |
| 256 | 274 |
| 257 if (extension_id != extension_misc::kWebStoreAppId) | 275 if (extension_id != extension_misc::kWebStoreAppId) |
| 258 RecordAppLaunch(promo_active_); | 276 RecordAppLaunch(promo_active_); |
| 259 } | 277 } |
| 260 | 278 |
| 261 void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) { | 279 void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) { |
| 262 std::string extension_id; | 280 std::string extension_id; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 321 |
| 304 for (ExtensionIdSet::const_iterator iter = app_ids->begin(); | 322 for (ExtensionIdSet::const_iterator iter = app_ids->begin(); |
| 305 iter != app_ids->end(); ++iter) { | 323 iter != app_ids->end(); ++iter) { |
| 306 if (extensions_service_->GetExtensionById(*iter, true)) | 324 if (extensions_service_->GetExtensionById(*iter, true)) |
| 307 extensions_service_->UninstallExtension(*iter, false); | 325 extensions_service_->UninstallExtension(*iter, false); |
| 308 } | 326 } |
| 309 | 327 |
| 310 extensions_service_->default_apps()->SetPromoHidden(); | 328 extensions_service_->default_apps()->SetPromoHidden(); |
| 311 } | 329 } |
| 312 | 330 |
| 313 //static | 331 // static |
| 314 void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) { | 332 void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) { |
| 315 if (!promo_active) return; | 333 if (!promo_active) return; |
| 316 | 334 |
| 317 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, | 335 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, |
| 318 extension_misc::PROMO_LAUNCH_WEB_STORE, | 336 extension_misc::PROMO_LAUNCH_WEB_STORE, |
| 319 extension_misc::PROMO_BUCKET_BOUNDARY); | 337 extension_misc::PROMO_BUCKET_BOUNDARY); |
| 320 } | 338 } |
| 321 | 339 |
| 322 //static | 340 // static |
| 323 void AppLauncherHandler::RecordAppLaunch(bool promo_active) { | 341 void AppLauncherHandler::RecordAppLaunch(bool promo_active) { |
| 324 // TODO(jstritar): record app launches that occur when the promo is not | 342 // TODO(jstritar): record app launches that occur when the promo is not |
| 325 // active using a different histogram. | 343 // active using a different histogram. |
| 326 | 344 |
| 327 if (!promo_active) return; | 345 if (!promo_active) return; |
| 328 | 346 |
| 329 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, | 347 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, |
| 330 extension_misc::PROMO_LAUNCH_APP, | 348 extension_misc::PROMO_LAUNCH_APP, |
| 331 extension_misc::PROMO_BUCKET_BOUNDARY); | 349 extension_misc::PROMO_BUCKET_BOUNDARY); |
| 332 } | 350 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 361 // We make this check for the case of minimized windows, unit tests, etc. | 379 // We make this check for the case of minimized windows, unit tests, etc. |
| 362 if (platform_util::IsVisible(dom_ui_->tab_contents()->GetNativeView()) && | 380 if (platform_util::IsVisible(dom_ui_->tab_contents()->GetNativeView()) && |
| 363 Animation::ShouldRenderRichAnimation()) { | 381 Animation::ShouldRenderRichAnimation()) { |
| 364 #if defined(OS_WIN) | 382 #if defined(OS_WIN) |
| 365 AppLaunchedAnimation::Show(extension, rect); | 383 AppLaunchedAnimation::Show(extension, rect); |
| 366 #else | 384 #else |
| 367 NOTIMPLEMENTED(); | 385 NOTIMPLEMENTED(); |
| 368 #endif | 386 #endif |
| 369 } | 387 } |
| 370 } | 388 } |
| OLD | NEW |