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