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 "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/environment.h" | 14 #include "base/environment.h" |
15 #include "base/event_recorder.h" | 15 #include "base/event_recorder.h" |
16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
19 #include "base/metrics/statistics_recorder.h" | 19 #include "base/metrics/statistics_recorder.h" |
20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
21 #include "base/string_number_conversions.h" | 21 #include "base/string_number_conversions.h" |
22 #include "base/string_split.h" | 22 #include "base/string_split.h" |
23 #include "base/threading/thread_restrictions.h" | 23 #include "base/threading/thread_restrictions.h" |
24 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
25 #include "chrome/browser/auto_launch_trial.h" | 25 #include "chrome/browser/auto_launch_trial.h" |
26 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
27 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 27 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
28 #include "chrome/browser/defaults.h" | 28 #include "chrome/browser/defaults.h" |
| 29 #include "chrome/browser/extensions/app_restore_service.h" |
| 30 #include "chrome/browser/extensions/app_restore_service_factory.h" |
29 #include "chrome/browser/extensions/extension_creator.h" | 31 #include "chrome/browser/extensions/extension_creator.h" |
30 #include "chrome/browser/extensions/extension_service.h" | 32 #include "chrome/browser/extensions/extension_service.h" |
31 #include "chrome/browser/extensions/pack_extension_job.h" | 33 #include "chrome/browser/extensions/pack_extension_job.h" |
32 #include "chrome/browser/first_run/first_run.h" | 34 #include "chrome/browser/first_run/first_run.h" |
33 #include "chrome/browser/google/google_util.h" | 35 #include "chrome/browser/google/google_util.h" |
34 #include "chrome/browser/net/predictor.h" | 36 #include "chrome/browser/net/predictor.h" |
35 #include "chrome/browser/net/url_fixer_upper.h" | 37 #include "chrome/browser/net/url_fixer_upper.h" |
36 #include "chrome/browser/notifications/desktop_notification_service.h" | 38 #include "chrome/browser/notifications/desktop_notification_service.h" |
37 #include "chrome/browser/performance_monitor/startup_timer.h" | 39 #include "chrome/browser/performance_monitor/startup_timer.h" |
38 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 40 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 VLOG(1) << "StartupBrowserCreatorImpl::ProcessStartupURLs"; | 635 VLOG(1) << "StartupBrowserCreatorImpl::ProcessStartupURLs"; |
634 SessionStartupPref pref = | 636 SessionStartupPref pref = |
635 StartupBrowserCreator::GetSessionStartupPref(command_line_, profile_); | 637 StartupBrowserCreator::GetSessionStartupPref(command_line_, profile_); |
636 if (pref.type == SessionStartupPref::LAST) | 638 if (pref.type == SessionStartupPref::LAST) |
637 VLOG(1) << "Pref: last"; | 639 VLOG(1) << "Pref: last"; |
638 else if (pref.type == SessionStartupPref::URLS) | 640 else if (pref.type == SessionStartupPref::URLS) |
639 VLOG(1) << "Pref: urls"; | 641 VLOG(1) << "Pref: urls"; |
640 else if (pref.type == SessionStartupPref::DEFAULT) | 642 else if (pref.type == SessionStartupPref::DEFAULT) |
641 VLOG(1) << "Pref: default"; | 643 VLOG(1) << "Pref: default"; |
642 | 644 |
| 645 // The only time apps get restored is when the browser process is restarted. |
| 646 if (StartupBrowserCreator::WasRestarted()) |
| 647 extensions::AppRestoreServiceFactory::GetForProfile(profile_)-> |
| 648 RestoreApps(); |
| 649 |
643 if (pref.type == SessionStartupPref::LAST) { | 650 if (pref.type == SessionStartupPref::LAST) { |
644 if (profile_->GetLastSessionExitType() == Profile::EXIT_CRASHED && | 651 if (profile_->GetLastSessionExitType() == Profile::EXIT_CRASHED && |
645 !command_line_.HasSwitch(switches::kRestoreLastSession)) { | 652 !command_line_.HasSwitch(switches::kRestoreLastSession)) { |
646 // The last session crashed. It's possible automatically loading the | 653 // The last session crashed. It's possible automatically loading the |
647 // page will trigger another crash, locking the user out of chrome. | 654 // page will trigger another crash, locking the user out of chrome. |
648 // To avoid this, don't restore on startup but instead show the crashed | 655 // To avoid this, don't restore on startup but instead show the crashed |
649 // infobar. | 656 // infobar. |
650 VLOG(1) << "Unclean exit; not processing"; | 657 VLOG(1) << "Unclean exit; not processing"; |
651 return false; | 658 return false; |
652 } | 659 } |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 // New: | 1026 // New: |
1020 prefs->GetString(prefs::kHomePage), | 1027 prefs->GetString(prefs::kHomePage), |
1021 prefs->GetBoolean(prefs::kHomePageIsNewTabPage), | 1028 prefs->GetBoolean(prefs::kHomePageIsNewTabPage), |
1022 prefs->GetBoolean(prefs::kShowHomeButton), | 1029 prefs->GetBoolean(prefs::kShowHomeButton), |
1023 // Backup: | 1030 // Backup: |
1024 backup_homepage, | 1031 backup_homepage, |
1025 backup_homepage_is_ntp, | 1032 backup_homepage_is_ntp, |
1026 backup_show_home_button)); | 1033 backup_show_home_button)); |
1027 } | 1034 } |
1028 } | 1035 } |
OLD | NEW |