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.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
6 | 6 |
7 #include <algorithm> // For max(). | 7 #include <algorithm> // For max(). |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "apps/app_load_service.h" | |
11 #include "apps/switches.h" | |
10 #include "base/bind.h" | 12 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
12 #include "base/command_line.h" | 14 #include "base/command_line.h" |
13 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
14 #include "base/environment.h" | 16 #include "base/environment.h" |
15 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
16 #include "base/lazy_instance.h" | 18 #include "base/lazy_instance.h" |
17 #include "base/logging.h" | 19 #include "base/logging.h" |
18 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
19 #include "base/metrics/histogram.h" | 21 #include "base/metrics/histogram.h" |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
608 #if defined(TOOLKIT_VIEWS) && defined(USE_X11) | 610 #if defined(TOOLKIT_VIEWS) && defined(USE_X11) |
609 ui::TouchFactory::SetTouchDeviceListFromCommandLine(); | 611 ui::TouchFactory::SetTouchDeviceListFromCommandLine(); |
610 #endif | 612 #endif |
611 | 613 |
612 // If we don't want to launch a new browser window or tab (in the case | 614 // If we don't want to launch a new browser window or tab (in the case |
613 // of an automation request), we are done here. | 615 // of an automation request), we are done here. |
614 if (silent_launch) | 616 if (silent_launch) |
615 return true; | 617 return true; |
616 | 618 |
617 // Check for --load-and-launch-app. | 619 // Check for --load-and-launch-app. |
618 if (command_line.HasSwitch(switches::kLoadAndLaunchApp) && | 620 if (command_line.HasSwitch(apps::kLoadAndLaunchApp) && |
619 !IncognitoModePrefs::ShouldLaunchIncognito( | 621 !IncognitoModePrefs::ShouldLaunchIncognito( |
620 command_line, last_used_profile->GetPrefs())) { | 622 command_line, last_used_profile->GetPrefs())) { |
621 CommandLine::StringType path = command_line.GetSwitchValueNative( | 623 CommandLine::StringType path = command_line.GetSwitchValueNative( |
622 switches::kLoadAndLaunchApp); | 624 apps::kLoadAndLaunchApp); |
623 extensions::UnpackedInstaller::Create( | 625 std::string extension_id; |
624 last_used_profile->GetExtensionService())-> | 626 if (!extensions::UnpackedInstaller::Create( |
625 LoadFromCommandLine(base::FilePath(path), true); | 627 last_used_profile->GetExtensionService())-> |
628 LoadFromCommandLine(base::FilePath(path), &extension_id)) { | |
629 return false; | |
630 } | |
631 | |
632 // Schedule the app to be launched once loaded. | |
633 apps::AppLoadService::Get(last_used_profile)->ScheduleLaunchOnLoad( | |
634 extension_id); | |
sky
2013/05/30 15:33:32
nit: indent 2 more spaces.
benwells
2013/05/31 01:13:04
Done.
| |
635 | |
626 // Return early here since we don't want to open a browser window. | 636 // Return early here since we don't want to open a browser window. |
627 // The exception is when there are no browser windows, since we don't want | 637 // The exception is when there are no browser windows, since we don't want |
628 // chrome to shut down. | 638 // chrome to shut down. |
629 // TODO(jackhou): Do this properly once keep-alive is handled by the | 639 // TODO(jackhou): Do this properly once keep-alive is handled by the |
630 // background page of apps. Tracked at http://crbug.com/175381 | 640 // background page of apps. Tracked at http://crbug.com/175381 |
631 if (chrome::GetTotalBrowserCountForProfile(last_used_profile) != 0) | 641 if (chrome::GetTotalBrowserCountForProfile(last_used_profile) != 0) |
632 return true; | 642 return true; |
633 } | 643 } |
634 | 644 |
635 chrome::startup::IsProcessStartup is_process_startup = process_startup ? | 645 chrome::startup::IsProcessStartup is_process_startup = process_startup ? |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
740 | 750 |
741 // static | 751 // static |
742 bool StartupBrowserCreator::ActivatedProfile() { | 752 bool StartupBrowserCreator::ActivatedProfile() { |
743 return profile_launch_observer.Get().activated_profile(); | 753 return profile_launch_observer.Get().activated_profile(); |
744 } | 754 } |
745 | 755 |
746 bool HasPendingUncleanExit(Profile* profile) { | 756 bool HasPendingUncleanExit(Profile* profile) { |
747 return profile->GetLastSessionExitType() == Profile::EXIT_CRASHED && | 757 return profile->GetLastSessionExitType() == Profile::EXIT_CRASHED && |
748 !profile_launch_observer.Get().HasBeenLaunched(profile); | 758 !profile_launch_observer.Get().HasBeenLaunched(profile); |
749 } | 759 } |
OLD | NEW |