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/sessions/session_restore.h" | 5 #include "chrome/browser/sessions/session_restore.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <list> | 8 #include <list> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
19 #include "base/platform_file.h" | 19 #include "base/platform_file.h" |
20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
21 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
22 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
23 #include "base/task/cancelable_task_tracker.h" | 23 #include "base/task/cancelable_task_tracker.h" |
24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/chrome_notification_types.h" | 25 #include "chrome/browser/chrome_notification_types.h" |
26 #include "chrome/browser/extensions/extension_service.h" | |
27 #include "chrome/browser/performance_monitor/startup_timer.h" | 26 #include "chrome/browser/performance_monitor/startup_timer.h" |
28 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/sessions/session_service.h" | 28 #include "chrome/browser/sessions/session_service.h" |
30 #include "chrome/browser/sessions/session_service_factory.h" | 29 #include "chrome/browser/sessions/session_service_factory.h" |
31 #include "chrome/browser/sessions/session_types.h" | 30 #include "chrome/browser/sessions/session_types.h" |
32 #include "chrome/browser/ui/browser.h" | 31 #include "chrome/browser/ui/browser.h" |
33 #include "chrome/browser/ui/browser_finder.h" | 32 #include "chrome/browser/ui/browser_finder.h" |
34 #include "chrome/browser/ui/browser_navigator.h" | 33 #include "chrome/browser/ui/browser_navigator.h" |
35 #include "chrome/browser/ui/browser_tabrestore.h" | 34 #include "chrome/browser/ui/browser_tabrestore.h" |
36 #include "chrome/browser/ui/browser_tabstrip.h" | 35 #include "chrome/browser/ui/browser_tabstrip.h" |
37 #include "chrome/browser/ui/browser_window.h" | 36 #include "chrome/browser/ui/browser_window.h" |
38 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 37 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
39 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" | 38 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" |
40 #include "content/public/browser/child_process_security_policy.h" | 39 #include "content/public/browser/child_process_security_policy.h" |
41 #include "content/public/browser/dom_storage_context.h" | 40 #include "content/public/browser/dom_storage_context.h" |
42 #include "content/public/browser/navigation_controller.h" | 41 #include "content/public/browser/navigation_controller.h" |
43 #include "content/public/browser/notification_registrar.h" | 42 #include "content/public/browser/notification_registrar.h" |
44 #include "content/public/browser/notification_service.h" | 43 #include "content/public/browser/notification_service.h" |
45 #include "content/public/browser/render_process_host.h" | 44 #include "content/public/browser/render_process_host.h" |
46 #include "content/public/browser/render_widget_host.h" | 45 #include "content/public/browser/render_widget_host.h" |
47 #include "content/public/browser/render_widget_host_view.h" | 46 #include "content/public/browser/render_widget_host_view.h" |
48 #include "content/public/browser/session_storage_namespace.h" | 47 #include "content/public/browser/session_storage_namespace.h" |
49 #include "content/public/browser/storage_partition.h" | 48 #include "content/public/browser/storage_partition.h" |
50 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
51 #include "content/public/browser/web_contents_view.h" | 50 #include "content/public/browser/web_contents_view.h" |
| 51 #include "extensions/browser/extension_registry.h" |
| 52 #include "extensions/common/extension_set.h" |
52 #include "net/base/network_change_notifier.h" | 53 #include "net/base/network_change_notifier.h" |
53 | 54 |
54 #if defined(OS_CHROMEOS) | 55 #if defined(OS_CHROMEOS) |
55 #include "chrome/browser/chromeos/boot_times_loader.h" | 56 #include "chrome/browser/chromeos/boot_times_loader.h" |
56 #endif | 57 #endif |
57 | 58 |
58 #if defined(OS_WIN) | 59 #if defined(OS_WIN) |
59 #include "win8/util/win8_util.h" | 60 #include "win8/util/win8_util.h" |
60 #endif | 61 #endif |
61 | 62 |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 | 949 |
949 // Record an app launch event (if appropriate) for a tab which is about to | 950 // Record an app launch event (if appropriate) for a tab which is about to |
950 // be restored. Callers should ensure that selected_index is within the | 951 // be restored. Callers should ensure that selected_index is within the |
951 // bounds of tab.navigations before calling. | 952 // bounds of tab.navigations before calling. |
952 void RecordAppLaunchForTab(Browser* browser, | 953 void RecordAppLaunchForTab(Browser* browser, |
953 const SessionTab& tab, | 954 const SessionTab& tab, |
954 int selected_index) { | 955 int selected_index) { |
955 DCHECK(selected_index >= 0 && | 956 DCHECK(selected_index >= 0 && |
956 selected_index < static_cast<int>(tab.navigations.size())); | 957 selected_index < static_cast<int>(tab.navigations.size())); |
957 GURL url = tab.navigations[selected_index].virtual_url(); | 958 GURL url = tab.navigations[selected_index].virtual_url(); |
958 if (browser->profile()->GetExtensionService()) { | 959 const extensions::Extension* extension = |
959 const extensions::Extension* extension = | 960 extensions::ExtensionRegistry::Get(profile()) |
960 browser->profile()->GetExtensionService()->GetInstalledApp(url); | 961 ->enabled_extensions().GetAppByURL(url); |
961 if (extension) { | 962 if (extension) { |
962 CoreAppLauncherHandler::RecordAppLaunchType( | 963 CoreAppLauncherHandler::RecordAppLaunchType( |
963 extension_misc::APP_LAUNCH_SESSION_RESTORE, | 964 extension_misc::APP_LAUNCH_SESSION_RESTORE, |
964 extension->GetType()); | 965 extension->GetType()); |
965 } | |
966 } | 966 } |
967 } | 967 } |
968 | 968 |
969 // Adds the tabs from |window| to |browser|. Normal tabs go after the existing | 969 // Adds the tabs from |window| to |browser|. Normal tabs go after the existing |
970 // tabs but pinned tabs will be pushed in front. | 970 // tabs but pinned tabs will be pushed in front. |
971 // If there are no existing tabs, the tab at |selected_tab_index| will be | 971 // If there are no existing tabs, the tab at |selected_tab_index| will be |
972 // selected. Otherwise, the tab selection will remain untouched. | 972 // selected. Otherwise, the tab selection will remain untouched. |
973 void RestoreTabsToBrowser(const SessionWindow& window, | 973 void RestoreTabsToBrowser(const SessionWindow& window, |
974 Browser* browser, | 974 Browser* browser, |
975 int initial_tab_count, | 975 int initial_tab_count, |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 if (!active_session_restorers) | 1264 if (!active_session_restorers) |
1265 return false; | 1265 return false; |
1266 for (std::set<SessionRestoreImpl*>::const_iterator it = | 1266 for (std::set<SessionRestoreImpl*>::const_iterator it = |
1267 active_session_restorers->begin(); | 1267 active_session_restorers->begin(); |
1268 it != active_session_restorers->end(); ++it) { | 1268 it != active_session_restorers->end(); ++it) { |
1269 if ((*it)->synchronous()) | 1269 if ((*it)->synchronous()) |
1270 return true; | 1270 return true; |
1271 } | 1271 } |
1272 return false; | 1272 return false; |
1273 } | 1273 } |
OLD | NEW |