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/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/extensions/extension_service.h" | |
14 #include "chrome/browser/extensions/tab_helper.h" | 13 #include "chrome/browser/extensions/tab_helper.h" |
15 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/sessions/session_types.h" | 15 #include "chrome/browser/sessions/session_types.h" |
17 #include "chrome/browser/sessions/tab_restore_service_delegate.h" | 16 #include "chrome/browser/sessions/tab_restore_service_delegate.h" |
18 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 17 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
19 #include "chrome/common/extensions/extension_constants.h" | 18 #include "chrome/common/extensions/extension_constants.h" |
20 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
21 #include "content/public/browser/navigation_controller.h" | 20 #include "content/public/browser/navigation_controller.h" |
22 #include "content/public/browser/navigation_entry.h" | 21 #include "content/public/browser/navigation_entry.h" |
23 #include "content/public/browser/session_storage_namespace.h" | 22 #include "content/public/browser/session_storage_namespace.h" |
24 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 24 #include "extensions/browser/extension_registry.h" |
25 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
| 26 #include "extensions/common/extension_set.h" |
26 | 27 |
27 #if !defined(OS_ANDROID) | 28 #if !defined(OS_ANDROID) |
28 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" | 29 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" |
29 #endif | 30 #endif |
30 | 31 |
31 using content::NavigationController; | 32 using content::NavigationController; |
32 using content::NavigationEntry; | 33 using content::NavigationEntry; |
33 using content::WebContents; | 34 using content::WebContents; |
34 | 35 |
35 namespace { | 36 namespace { |
36 | 37 |
37 void RecordAppLaunch(Profile* profile, const TabRestoreService::Tab& tab) { | 38 void RecordAppLaunch(Profile* profile, const TabRestoreService::Tab& tab) { |
38 #if !defined(OS_ANDROID) | 39 #if !defined(OS_ANDROID) |
39 GURL url = tab.navigations.at(tab.current_navigation_index).virtual_url(); | 40 GURL url = tab.navigations.at(tab.current_navigation_index).virtual_url(); |
40 DCHECK(profile->GetExtensionService()); | |
41 const extensions::Extension* extension = | 41 const extensions::Extension* extension = |
42 profile->GetExtensionService()->GetInstalledApp(url); | 42 extensions::ExtensionRegistry::Get(profile) |
| 43 ->enabled_extensions().GetAppByURL(url); |
43 if (!extension) | 44 if (!extension) |
44 return; | 45 return; |
45 | 46 |
46 CoreAppLauncherHandler::RecordAppLaunchType( | 47 CoreAppLauncherHandler::RecordAppLaunchType( |
47 extension_misc::APP_LAUNCH_NTP_RECENTLY_CLOSED, | 48 extension_misc::APP_LAUNCH_NTP_RECENTLY_CLOSED, |
48 extension->GetType()); | 49 extension->GetType()); |
49 #endif // !defined(OS_ANDROID) | 50 #endif // !defined(OS_ANDROID) |
50 } | 51 } |
51 | 52 |
52 } // namespace | 53 } // namespace |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 Tab* tab = static_cast<Tab*>(entry); | 587 Tab* tab = static_cast<Tab*>(entry); |
587 if (tab->browser_id == old_id) | 588 if (tab->browser_id == old_id) |
588 tab->browser_id = new_id; | 589 tab->browser_id = new_id; |
589 } | 590 } |
590 } | 591 } |
591 } | 592 } |
592 | 593 |
593 base::Time TabRestoreServiceHelper::TimeNow() const { | 594 base::Time TabRestoreServiceHelper::TimeNow() const { |
594 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now(); | 595 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now(); |
595 } | 596 } |
OLD | NEW |