OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chrome_tab_restore_service_client.h" | 5 #include "chrome/browser/sessions/chrome_tab_restore_service_client.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/sessions/session_service.h" | 9 #include "chrome/browser/sessions/session_service.h" |
10 #include "chrome/browser/sessions/session_service_factory.h" | 10 #include "chrome/browser/sessions/session_service_factory.h" |
11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
12 #include "components/sessions/content/content_live_tab.h" | 12 #include "components/sessions/content/content_live_tab.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 | 14 |
15 #if defined(ENABLE_EXTENSIONS) | 15 #if defined(ENABLE_EXTENSIONS) |
16 #include "chrome/browser/extensions/tab_helper.h" | 16 #include "chrome/browser/extensions/tab_helper.h" |
17 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
18 #include "chrome/common/extensions/extension_metrics.h" | 18 #include "chrome/common/extensions/extension_metrics.h" |
19 #include "extensions/browser/extension_registry.h" | 19 #include "extensions/browser/extension_registry.h" |
20 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
21 #include "extensions/common/extension_set.h" | 21 #include "extensions/common/extension_set.h" |
22 #endif | 22 #endif |
23 | 23 |
24 #if !defined(OS_ANDROID) | 24 #if !defined(OS_ANDROID) |
25 #include "chrome/browser/ui/browser_live_tab_context.h" | 25 #include "chrome/browser/ui/browser_live_tab_context.h" |
26 #else | |
27 #include "chrome/browser/ui/android/tab_model/android_live_tab_context.h" | |
26 #endif | 28 #endif |
27 | 29 |
28 namespace { | 30 namespace { |
29 | 31 |
30 void RecordAppLaunch(Profile* profile, const GURL& url) { | 32 void RecordAppLaunch(Profile* profile, const GURL& url) { |
31 #if defined(ENABLE_EXTENSIONS) | 33 #if defined(ENABLE_EXTENSIONS) |
32 const extensions::Extension* extension = | 34 const extensions::Extension* extension = |
33 extensions::ExtensionRegistry::Get(profile) | 35 extensions::ExtensionRegistry::Get(profile) |
34 ->enabled_extensions() | 36 ->enabled_extensions() |
35 .GetAppByURL(url); | 37 .GetAppByURL(url); |
36 if (!extension) | 38 if (!extension) |
37 return; | 39 return; |
38 | 40 |
39 extensions::RecordAppLaunchType( | 41 extensions::RecordAppLaunchType( |
40 extension_misc::APP_LAUNCH_NTP_RECENTLY_CLOSED, extension->GetType()); | 42 extension_misc::APP_LAUNCH_NTP_RECENTLY_CLOSED, extension->GetType()); |
41 #endif // defined(ENABLE_EXTENSIONS) | 43 #endif // defined(ENABLE_EXTENSIONS) |
42 } | 44 } |
43 | 45 |
44 } // namespace | 46 } // namespace |
45 | 47 |
46 ChromeTabRestoreServiceClient::ChromeTabRestoreServiceClient(Profile* profile) | 48 ChromeTabRestoreServiceClient::ChromeTabRestoreServiceClient(Profile* profile) |
47 : profile_(profile) {} | 49 : profile_(profile) {} |
48 | 50 |
49 ChromeTabRestoreServiceClient::~ChromeTabRestoreServiceClient() {} | 51 ChromeTabRestoreServiceClient::~ChromeTabRestoreServiceClient() {} |
50 | 52 |
51 sessions::LiveTabContext* ChromeTabRestoreServiceClient::CreateLiveTabContext( | 53 sessions::LiveTabContext* ChromeTabRestoreServiceClient::CreateLiveTabContext( |
52 const std::string& app_name) { | 54 const std::string& app_name) { |
53 #if defined(OS_ANDROID) | 55 #if defined(OS_ANDROID) |
54 // Android does not support LiveTabContext, as tab persistence | 56 // Android does not initialize LiveTabContext here, and tab persistence is |
55 // is implemented on the Java side. | 57 // implemented in java. |
58 NOTREACHED(); | |
56 return nullptr; | 59 return nullptr; |
Theresa
2016/07/02 01:00:37
This needs to be implemented to use TabRestoreServ
| |
57 #else | 60 #else |
58 return BrowserLiveTabContext::Create(profile_, app_name); | 61 return BrowserLiveTabContext::Create(profile_, app_name); |
59 #endif | 62 #endif |
60 } | 63 } |
61 | 64 |
62 sessions::LiveTabContext* | 65 sessions::LiveTabContext* |
63 ChromeTabRestoreServiceClient::FindLiveTabContextForTab( | 66 ChromeTabRestoreServiceClient::FindLiveTabContextForTab( |
64 const sessions::LiveTab* tab) { | 67 const sessions::LiveTab* tab) { |
65 #if defined(OS_ANDROID) | 68 #if defined(OS_ANDROID) |
66 // Android does not support LiveTabContext, as tab persistence | 69 return AndroidLiveTabContext::FindContextForWebContents( |
67 // is implemented on the Java side. | 70 static_cast<const sessions::ContentLiveTab*>(tab)->web_contents()); |
68 return nullptr; | |
69 #else | 71 #else |
70 return BrowserLiveTabContext::FindContextForWebContents( | 72 return BrowserLiveTabContext::FindContextForWebContents( |
71 static_cast<const sessions::ContentLiveTab*>(tab)->web_contents()); | 73 static_cast<const sessions::ContentLiveTab*>(tab)->web_contents()); |
72 #endif | 74 #endif |
73 } | 75 } |
74 | 76 |
75 sessions::LiveTabContext* | 77 sessions::LiveTabContext* |
76 ChromeTabRestoreServiceClient::FindLiveTabContextWithID( | 78 ChromeTabRestoreServiceClient::FindLiveTabContextWithID( |
77 SessionID::id_type desired_id) { | 79 SessionID::id_type desired_id) { |
78 #if defined(OS_ANDROID) | 80 #if defined(OS_ANDROID) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 DCHECK(HasLastSession()); | 146 DCHECK(HasLastSession()); |
145 #if defined(ENABLE_SESSION_SERVICE) | 147 #if defined(ENABLE_SESSION_SERVICE) |
146 SessionServiceFactory::GetForProfile(profile_) | 148 SessionServiceFactory::GetForProfile(profile_) |
147 ->GetLastSession(callback, tracker); | 149 ->GetLastSession(callback, tracker); |
148 #endif | 150 #endif |
149 } | 151 } |
150 | 152 |
151 void ChromeTabRestoreServiceClient::OnTabRestored(const GURL& url) { | 153 void ChromeTabRestoreServiceClient::OnTabRestored(const GURL& url) { |
152 RecordAppLaunch(profile_, url); | 154 RecordAppLaunch(profile_, url); |
153 } | 155 } |
OLD | NEW |