| 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/application_launch.h" | 5 #include "chrome/browser/ui/extensions/application_launch.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "apps/launcher.h" | 9 #include "apps/launcher.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" |
| 11 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/browser/app_mode/app_mode_utils.h" | 14 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 14 #include "chrome/browser/apps/per_app_settings_service.h" | 15 #include "chrome/browser/apps/per_app_settings_service.h" |
| 15 #include "chrome/browser/apps/per_app_settings_service_factory.h" | 16 #include "chrome/browser/apps/per_app_settings_service_factory.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/launch_util.h" | 18 #include "chrome/browser/extensions/launch_util.h" |
| 18 #include "chrome/browser/extensions/tab_helper.h" | 19 #include "chrome/browser/extensions/tab_helper.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/app_list/app_list_service.h" | 21 #include "chrome/browser/ui/app_list/app_list_service.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 | 296 |
| 296 UMA_HISTOGRAM_ENUMERATION( | 297 UMA_HISTOGRAM_ENUMERATION( |
| 297 "Extensions.AppLaunchContainer", params.container, 100); | 298 "Extensions.AppLaunchContainer", params.container, 100); |
| 298 | 299 |
| 299 if (CanLaunchViaEvent(extension)) { | 300 if (CanLaunchViaEvent(extension)) { |
| 300 // Remember what desktop the launch happened on so that when the app opens a | 301 // Remember what desktop the launch happened on so that when the app opens a |
| 301 // window we can open them on the right desktop. | 302 // window we can open them on the right desktop. |
| 302 PerAppSettingsServiceFactory::GetForBrowserContext(profile)-> | 303 PerAppSettingsServiceFactory::GetForBrowserContext(profile)-> |
| 303 SetDesktopLastLaunchedFrom(extension->id(), params.desktop_type); | 304 SetDesktopLastLaunchedFrom(extension->id(), params.desktop_type); |
| 304 | 305 |
| 305 apps::LaunchPlatformAppWithCommandLine( | 306 VLOG(2) << "Launch source: " << params.source; |
| 306 profile, extension, params.command_line, params.current_directory); | 307 |
| 308 apps::LaunchPlatformAppWithCommandLine(profile, |
| 309 extension, |
| 310 params.command_line, |
| 311 params.current_directory, |
| 312 params.source); |
| 307 return NULL; | 313 return NULL; |
| 308 } | 314 } |
| 309 | 315 |
| 310 // Record v1 app launch. Platform app launch is recorded when dispatching | 316 // Record v1 app launch. Platform app launch is recorded when dispatching |
| 311 // the onLaunched event. | 317 // the onLaunched event. |
| 312 prefs->SetLastLaunchTime(extension->id(), base::Time::Now()); | 318 prefs->SetLastLaunchTime(extension->id(), base::Time::Now()); |
| 313 | 319 |
| 314 switch (params.container) { | 320 switch (params.container) { |
| 315 case extensions::LAUNCH_CONTAINER_NONE: { | 321 case extensions::LAUNCH_CONTAINER_NONE: { |
| 316 NOTREACHED(); | 322 NOTREACHED(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 337 const extensions::Extension* extension, | 343 const extensions::Extension* extension, |
| 338 extensions::LaunchContainer container, | 344 extensions::LaunchContainer container, |
| 339 WindowOpenDisposition disposition) | 345 WindowOpenDisposition disposition) |
| 340 : profile(profile), | 346 : profile(profile), |
| 341 extension_id(extension ? extension->id() : std::string()), | 347 extension_id(extension ? extension->id() : std::string()), |
| 342 container(container), | 348 container(container), |
| 343 disposition(disposition), | 349 disposition(disposition), |
| 344 desktop_type(chrome::GetActiveDesktop()), | 350 desktop_type(chrome::GetActiveDesktop()), |
| 345 override_url(), | 351 override_url(), |
| 346 override_bounds(), | 352 override_bounds(), |
| 347 command_line(CommandLine::NO_PROGRAM) {} | 353 command_line(CommandLine::NO_PROGRAM), |
| 354 source(extensions::SOURCE_UNKNOWN) { |
| 355 } |
| 348 | 356 |
| 349 AppLaunchParams::AppLaunchParams(Profile* profile, | 357 AppLaunchParams::AppLaunchParams(Profile* profile, |
| 350 const extensions::Extension* extension, | 358 const extensions::Extension* extension, |
| 351 WindowOpenDisposition disposition) | 359 WindowOpenDisposition disposition) |
| 352 : profile(profile), | 360 : profile(profile), |
| 353 extension_id(extension ? extension->id() : std::string()), | 361 extension_id(extension ? extension->id() : std::string()), |
| 354 container(extensions::LAUNCH_CONTAINER_NONE), | 362 container(extensions::LAUNCH_CONTAINER_NONE), |
| 355 disposition(disposition), | 363 disposition(disposition), |
| 356 desktop_type(chrome::GetActiveDesktop()), | 364 desktop_type(chrome::GetActiveDesktop()), |
| 357 override_url(), | 365 override_url(), |
| 358 override_bounds(), | 366 override_bounds(), |
| 359 command_line(CommandLine::NO_PROGRAM) { | 367 command_line(CommandLine::NO_PROGRAM), |
| 368 source(extensions::SOURCE_UNKNOWN) { |
| 360 // Look up the app preference to find out the right launch container. Default | 369 // Look up the app preference to find out the right launch container. Default |
| 361 // is to launch as a regular tab. | 370 // is to launch as a regular tab. |
| 362 container = | 371 container = |
| 363 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension); | 372 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension); |
| 364 } | 373 } |
| 365 | 374 |
| 366 AppLaunchParams::AppLaunchParams(Profile* profile, | 375 AppLaunchParams::AppLaunchParams(Profile* profile, |
| 367 const extensions::Extension* extension, | 376 const extensions::Extension* extension, |
| 368 int event_flags, | 377 int event_flags, |
| 369 chrome::HostDesktopType desktop_type) | 378 chrome::HostDesktopType desktop_type) |
| 370 : profile(profile), | 379 : profile(profile), |
| 371 extension_id(extension ? extension->id() : std::string()), | 380 extension_id(extension ? extension->id() : std::string()), |
| 372 container(extensions::LAUNCH_CONTAINER_NONE), | 381 container(extensions::LAUNCH_CONTAINER_NONE), |
| 373 disposition(ui::DispositionFromEventFlags(event_flags)), | 382 disposition(ui::DispositionFromEventFlags(event_flags)), |
| 374 desktop_type(desktop_type), | 383 desktop_type(desktop_type), |
| 375 override_url(), | 384 override_url(), |
| 376 override_bounds(), | 385 override_bounds(), |
| 377 command_line(CommandLine::NO_PROGRAM) { | 386 command_line(CommandLine::NO_PROGRAM), |
| 387 source(extensions::SOURCE_UNKNOWN) { |
| 378 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) { | 388 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) { |
| 379 container = extensions::LAUNCH_CONTAINER_TAB; | 389 container = extensions::LAUNCH_CONTAINER_TAB; |
| 380 } else if (disposition == NEW_WINDOW) { | 390 } else if (disposition == NEW_WINDOW) { |
| 381 container = extensions::LAUNCH_CONTAINER_WINDOW; | 391 container = extensions::LAUNCH_CONTAINER_WINDOW; |
| 382 } else { | 392 } else { |
| 383 // Look at preference to find the right launch container. If no preference | 393 // Look at preference to find the right launch container. If no preference |
| 384 // is set, launch as a regular tab. | 394 // is set, launch as a regular tab. |
| 385 container = | 395 container = |
| 386 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension); | 396 extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension); |
| 387 disposition = NEW_FOREGROUND_TAB; | 397 disposition = NEW_FOREGROUND_TAB; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 | 466 |
| 457 // For extensions lacking launch urls, determine a reasonable fallback. | 467 // For extensions lacking launch urls, determine a reasonable fallback. |
| 458 if (!url.is_valid()) { | 468 if (!url.is_valid()) { |
| 459 url = extensions::OptionsPageInfo::GetOptionsPage(extension); | 469 url = extensions::OptionsPageInfo::GetOptionsPage(extension); |
| 460 if (!url.is_valid()) | 470 if (!url.is_valid()) |
| 461 url = GURL(chrome::kChromeUIExtensionsURL); | 471 url = GURL(chrome::kChromeUIExtensionsURL); |
| 462 } | 472 } |
| 463 | 473 |
| 464 return url; | 474 return url; |
| 465 } | 475 } |
| OLD | NEW |