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/startup/startup_browser_creator_impl.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "apps/app_restore_service.h" | 10 #include "apps/app_restore_service.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 if (profile->IsOffTheRecord() && extension->is_platform_app()) | 202 if (profile->IsOffTheRecord() && extension->is_platform_app()) |
203 return false; | 203 return false; |
204 LOG(ERROR) << app_id; | 204 LOG(ERROR) << app_id; |
205 // Look at preferences to find the right launch container. If no | 205 // Look at preferences to find the right launch container. If no |
206 // preference is set, launch as a window. | 206 // preference is set, launch as a window. |
207 extensions::LaunchContainer launch_container = extensions::GetLaunchContainer( | 207 extensions::LaunchContainer launch_container = extensions::GetLaunchContainer( |
208 extensions_service->extension_prefs(), extension); | 208 extensions_service->extension_prefs(), extension); |
209 | 209 |
210 if (!extensions::HasPreferredLaunchContainer( | 210 if (!extensions::HasPreferredLaunchContainer( |
211 extensions_service->extension_prefs(), extension)) | 211 extensions_service->extension_prefs(), extension)) |
212 launch_container = extensions::LAUNCH_WINDOW; | 212 launch_container = extensions::LAUNCH_CONTAINER_WINDOW; |
213 | 213 |
214 *out_extension = extension; | 214 *out_extension = extension; |
215 *out_launch_container = launch_container; | 215 *out_launch_container = launch_container; |
216 return true; | 216 return true; |
217 } | 217 } |
218 | 218 |
219 // Parse two comma-separated integers from string. Return true on success. | 219 // Parse two comma-separated integers from string. Return true on success. |
220 bool ParseCommaSeparatedIntegers(const std::string& str, | 220 bool ParseCommaSeparatedIntegers(const std::string& str, |
221 int* ret_num1, | 221 int* ret_num1, |
222 int* ret_num2) { | 222 int* ret_num2) { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 364 |
365 AppListService::InitAll(profile); | 365 AppListService::InitAll(profile); |
366 if (command_line_.HasSwitch(switches::kAppId)) { | 366 if (command_line_.HasSwitch(switches::kAppId)) { |
367 std::string app_id = command_line_.GetSwitchValueASCII(switches::kAppId); | 367 std::string app_id = command_line_.GetSwitchValueASCII(switches::kAppId); |
368 const Extension* extension = GetDisabledPlatformApp(profile, app_id); | 368 const Extension* extension = GetDisabledPlatformApp(profile, app_id); |
369 // If |app_id| is a disabled platform app we handle it specially here, | 369 // If |app_id| is a disabled platform app we handle it specially here, |
370 // otherwise it will be handled below. | 370 // otherwise it will be handled below. |
371 if (extension) { | 371 if (extension) { |
372 RecordCmdLineAppHistogram(extensions::Manifest::TYPE_PLATFORM_APP); | 372 RecordCmdLineAppHistogram(extensions::Manifest::TYPE_PLATFORM_APP); |
373 AppLaunchParams params(profile, extension, | 373 AppLaunchParams params(profile, extension, |
374 extensions::LAUNCH_NONE, NEW_WINDOW); | 374 extensions::LAUNCH_CONTAINER_NONE, NEW_WINDOW); |
375 params.command_line = &command_line_; | 375 params.command_line = &command_line_; |
376 params.current_directory = cur_dir_; | 376 params.current_directory = cur_dir_; |
377 OpenApplicationWithReenablePrompt(params); | 377 OpenApplicationWithReenablePrompt(params); |
378 return true; | 378 return true; |
379 } | 379 } |
380 } else if (command_line_.HasSwitch(switches::kShowAppList)) { | 380 } else if (command_line_.HasSwitch(switches::kShowAppList)) { |
381 // This switch is used for shortcuts on the native desktop. | 381 // This switch is used for shortcuts on the native desktop. |
382 AppListService::RecordShowTimings(command_line_); | 382 AppListService::RecordShowTimings(command_line_); |
383 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> | 383 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> |
384 ShowForProfile(profile); | 384 ShowForProfile(profile); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 // shortcuts. | 475 // shortcuts. |
476 if (!IsAppLaunch(NULL, &app_id) || app_id.empty()) | 476 if (!IsAppLaunch(NULL, &app_id) || app_id.empty()) |
477 return false; | 477 return false; |
478 | 478 |
479 extensions::LaunchContainer launch_container; | 479 extensions::LaunchContainer launch_container; |
480 const Extension* extension; | 480 const Extension* extension; |
481 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) | 481 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) |
482 return false; | 482 return false; |
483 | 483 |
484 // If the user doesn't want to open a tab, fail. | 484 // If the user doesn't want to open a tab, fail. |
485 if (launch_container != extensions::LAUNCH_TAB) | 485 if (launch_container != extensions::LAUNCH_CONTAINER_TAB) |
486 return false; | 486 return false; |
487 | 487 |
488 RecordCmdLineAppHistogram(extension->GetType()); | 488 RecordCmdLineAppHistogram(extension->GetType()); |
489 | 489 |
490 WebContents* app_tab = OpenApplication(AppLaunchParams( | 490 WebContents* app_tab = OpenApplication(AppLaunchParams( |
491 profile, extension, extensions::LAUNCH_TAB, NEW_FOREGROUND_TAB)); | 491 profile, extension, extensions::LAUNCH_CONTAINER_TAB, |
| 492 NEW_FOREGROUND_TAB)); |
492 return (app_tab != NULL); | 493 return (app_tab != NULL); |
493 } | 494 } |
494 | 495 |
495 bool StartupBrowserCreatorImpl::OpenApplicationWindow( | 496 bool StartupBrowserCreatorImpl::OpenApplicationWindow( |
496 Profile* profile, | 497 Profile* profile, |
497 content::WebContents** out_app_contents) { | 498 content::WebContents** out_app_contents) { |
498 // Set |out_app_contents| to NULL early on (just in case). | 499 // Set |out_app_contents| to NULL early on (just in case). |
499 if (out_app_contents) | 500 if (out_app_contents) |
500 *out_app_contents = NULL; | 501 *out_app_contents = NULL; |
501 | 502 |
502 std::string url_string, app_id; | 503 std::string url_string, app_id; |
503 if (!IsAppLaunch(&url_string, &app_id)) | 504 if (!IsAppLaunch(&url_string, &app_id)) |
504 return false; | 505 return false; |
505 | 506 |
506 // This can fail if the app_id is invalid. It can also fail if the | 507 // This can fail if the app_id is invalid. It can also fail if the |
507 // extension is external, and has not yet been installed. | 508 // extension is external, and has not yet been installed. |
508 // TODO(skerner): Do something reasonable here. Pop up a warning panel? | 509 // TODO(skerner): Do something reasonable here. Pop up a warning panel? |
509 // Open an URL to the gallery page of the extension id? | 510 // Open an URL to the gallery page of the extension id? |
510 if (!app_id.empty()) { | 511 if (!app_id.empty()) { |
511 extensions::LaunchContainer launch_container; | 512 extensions::LaunchContainer launch_container; |
512 const Extension* extension; | 513 const Extension* extension; |
513 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) | 514 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) |
514 return false; | 515 return false; |
515 | 516 |
516 // TODO(skerner): Could pass in |extension| and |launch_container|, | 517 // TODO(skerner): Could pass in |extension| and |launch_container|, |
517 // and avoid calling GetAppLaunchContainer() both here and in | 518 // and avoid calling GetAppLaunchContainer() both here and in |
518 // OpenApplicationTab(). | 519 // OpenApplicationTab(). |
519 | 520 |
520 if (launch_container == extensions::LAUNCH_TAB) | 521 if (launch_container == extensions::LAUNCH_CONTAINER_TAB) |
521 return false; | 522 return false; |
522 | 523 |
523 RecordCmdLineAppHistogram(extension->GetType()); | 524 RecordCmdLineAppHistogram(extension->GetType()); |
524 | 525 |
525 AppLaunchParams params(profile, extension, launch_container, NEW_WINDOW); | 526 AppLaunchParams params(profile, extension, launch_container, NEW_WINDOW); |
526 params.command_line = &command_line_; | 527 params.command_line = &command_line_; |
527 params.current_directory = cur_dir_; | 528 params.current_directory = cur_dir_; |
528 WebContents* tab_in_app_window = OpenApplication(params); | 529 WebContents* tab_in_app_window = OpenApplication(params); |
529 | 530 |
530 if (out_app_contents) | 531 if (out_app_contents) |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 } | 992 } |
992 | 993 |
993 #if !defined(OS_WIN) | 994 #if !defined(OS_WIN) |
994 // static | 995 // static |
995 bool StartupBrowserCreatorImpl::OpenStartupURLsInExistingBrowser( | 996 bool StartupBrowserCreatorImpl::OpenStartupURLsInExistingBrowser( |
996 Profile* profile, | 997 Profile* profile, |
997 const std::vector<GURL>& startup_urls) { | 998 const std::vector<GURL>& startup_urls) { |
998 return false; | 999 return false; |
999 } | 1000 } |
1000 #endif | 1001 #endif |
OLD | NEW |