OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/tab_restore_service_helper.h" | 5 #include "chrome/browser/sessions/tab_restore_service_helper.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/sessions/tab_restore_service_delegate.h" | 14 #include "chrome/browser/sessions/tab_restore_service_delegate.h" |
15 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 15 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
17 #include "components/sessions/content/content_serialized_navigation_builder.h" | 17 #include "components/sessions/content/content_serialized_navigation_builder.h" |
18 #include "components/sessions/session_types.h" | 18 #include "components/sessions/session_types.h" |
19 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
20 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
21 #include "content/public/browser/session_storage_namespace.h" | 21 #include "content/public/browser/session_storage_namespace.h" |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 | 23 |
24 #if defined(ENABLE_EXTENSIONS) | 24 #if defined(ENABLE_EXTENSIONS) |
25 #include "chrome/browser/extensions/tab_helper.h" | 25 #include "chrome/browser/extensions/tab_helper.h" |
26 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" | |
27 #include "chrome/common/extensions/extension_constants.h" | 26 #include "chrome/common/extensions/extension_constants.h" |
| 27 #include "chrome/common/extensions/extension_metrics.h" |
28 #include "extensions/browser/extension_registry.h" | 28 #include "extensions/browser/extension_registry.h" |
29 #include "extensions/common/extension.h" | 29 #include "extensions/common/extension.h" |
30 #include "extensions/common/extension_set.h" | 30 #include "extensions/common/extension_set.h" |
31 #endif | 31 #endif |
32 | 32 |
33 using content::NavigationController; | 33 using content::NavigationController; |
34 using content::NavigationEntry; | 34 using content::NavigationEntry; |
35 using content::WebContents; | 35 using content::WebContents; |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 void RecordAppLaunch(Profile* profile, const TabRestoreService::Tab& tab) { | 39 void RecordAppLaunch(Profile* profile, const TabRestoreService::Tab& tab) { |
40 #if defined(ENABLE_EXTENSIONS) | 40 #if defined(ENABLE_EXTENSIONS) |
41 GURL url = tab.navigations.at(tab.current_navigation_index).virtual_url(); | 41 GURL url = tab.navigations.at(tab.current_navigation_index).virtual_url(); |
42 const extensions::Extension* extension = | 42 const extensions::Extension* extension = |
43 extensions::ExtensionRegistry::Get(profile) | 43 extensions::ExtensionRegistry::Get(profile) |
44 ->enabled_extensions().GetAppByURL(url); | 44 ->enabled_extensions().GetAppByURL(url); |
45 if (!extension) | 45 if (!extension) |
46 return; | 46 return; |
47 | 47 |
48 CoreAppLauncherHandler::RecordAppLaunchType( | 48 extensions::RecordAppLaunchType( |
49 extension_misc::APP_LAUNCH_NTP_RECENTLY_CLOSED, | 49 extension_misc::APP_LAUNCH_NTP_RECENTLY_CLOSED, |
50 extension->GetType()); | 50 extension->GetType()); |
51 #endif // defined(ENABLE_EXTENSIONS) | 51 #endif // defined(ENABLE_EXTENSIONS) |
52 } | 52 } |
53 | 53 |
54 } // namespace | 54 } // namespace |
55 | 55 |
56 // TabRestoreServiceHelper::Observer ------------------------------------------- | 56 // TabRestoreServiceHelper::Observer ------------------------------------------- |
57 | 57 |
58 TabRestoreServiceHelper::Observer::~Observer() {} | 58 TabRestoreServiceHelper::Observer::~Observer() {} |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 Tab* tab = static_cast<Tab*>(entry); | 591 Tab* tab = static_cast<Tab*>(entry); |
592 if (tab->browser_id == old_id) | 592 if (tab->browser_id == old_id) |
593 tab->browser_id = new_id; | 593 tab->browser_id = new_id; |
594 } | 594 } |
595 } | 595 } |
596 } | 596 } |
597 | 597 |
598 base::Time TabRestoreServiceHelper::TimeNow() const { | 598 base::Time TabRestoreServiceHelper::TimeNow() const { |
599 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now(); | 599 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now(); |
600 } | 600 } |
OLD | NEW |