Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: chrome/browser/sessions/chrome_tab_restore_service_client.cc

Issue 1342743002: Remove Profile and HostDesktopType dependencies from core TabRestore code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Mac Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/sessions/session_service.h" 8 #include "chrome/browser/sessions/session_service.h"
9 #include "chrome/browser/sessions/session_service_factory.h" 9 #include "chrome/browser/sessions/session_service_factory.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 12
13 #if defined(ENABLE_EXTENSIONS) 13 #if defined(ENABLE_EXTENSIONS)
14 #include "chrome/common/extensions/extension_constants.h" 14 #include "chrome/common/extensions/extension_constants.h"
15 #include "chrome/common/extensions/extension_metrics.h" 15 #include "chrome/common/extensions/extension_metrics.h"
16 #include "extensions/browser/extension_registry.h" 16 #include "extensions/browser/extension_registry.h"
17 #include "extensions/common/extension.h" 17 #include "extensions/common/extension.h"
18 #include "extensions/common/extension_set.h" 18 #include "extensions/common/extension_set.h"
19 #endif 19 #endif
20 20
21 #if !defined(OS_ANDROID)
22 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h"
23 #endif
24
21 namespace { 25 namespace {
22 26
23 void RecordAppLaunch(Profile* profile, const GURL& url) { 27 void RecordAppLaunch(Profile* profile, const GURL& url) {
24 #if defined(ENABLE_EXTENSIONS) 28 #if defined(ENABLE_EXTENSIONS)
25 const extensions::Extension* extension = 29 const extensions::Extension* extension =
26 extensions::ExtensionRegistry::Get(profile) 30 extensions::ExtensionRegistry::Get(profile)
27 ->enabled_extensions() 31 ->enabled_extensions()
28 .GetAppByURL(url); 32 .GetAppByURL(url);
29 if (!extension) 33 if (!extension)
30 return; 34 return;
31 35
32 extensions::RecordAppLaunchType( 36 extensions::RecordAppLaunchType(
33 extension_misc::APP_LAUNCH_NTP_RECENTLY_CLOSED, extension->GetType()); 37 extension_misc::APP_LAUNCH_NTP_RECENTLY_CLOSED, extension->GetType());
34 #endif // defined(ENABLE_EXTENSIONS) 38 #endif // defined(ENABLE_EXTENSIONS)
35 } 39 }
36 40
37 } // namespace 41 } // namespace
38 42
39 ChromeTabRestoreServiceClient::ChromeTabRestoreServiceClient(Profile* profile) 43 ChromeTabRestoreServiceClient::ChromeTabRestoreServiceClient(Profile* profile)
40 : profile_(profile) {} 44 : profile_(profile) {}
41 45
42 ChromeTabRestoreServiceClient::~ChromeTabRestoreServiceClient() {} 46 ChromeTabRestoreServiceClient::~ChromeTabRestoreServiceClient() {}
43 47
48 TabRestoreServiceDelegate*
49 ChromeTabRestoreServiceClient::CreateTabRestoreServiceDelegate(
50 int host_desktop_type,
51 const std::string& app_name) {
52 #if defined(OS_ANDROID)
53 // Android does not support TabRestoreServiceDelegate, as tab persistence
54 // is implemented on the Java side.
55 return nullptr;
56 #else
57 return BrowserTabRestoreServiceDelegate::Create(
58 profile_, static_cast<chrome::HostDesktopType>(host_desktop_type),
59 app_name);
60 #endif
61 }
62
63 TabRestoreServiceDelegate*
64 ChromeTabRestoreServiceClient::FindTabRestoreServiceDelegateForWebContents(
65 const content::WebContents* contents) {
66 #if defined(OS_ANDROID)
67 // Android does not support TabRestoreServiceDelegate, as tab persistence
68 // is implemented on the Java side.
69 return nullptr;
70 #else
71 return BrowserTabRestoreServiceDelegate::FindDelegateForWebContents(contents);
72 #endif
73 }
74
75 TabRestoreServiceDelegate*
76 ChromeTabRestoreServiceClient::FindTabRestoreServiceDelegateWithID(
77 SessionID::id_type desired_id,
78 int host_desktop_type) {
79 #if defined(OS_ANDROID)
80 // Android does not support TabRestoreServiceDelegate, as tab persistence
81 // is implemented on the Java side.
82 return nullptr;
83 #else
84 return BrowserTabRestoreServiceDelegate::FindDelegateWithID(
85 desired_id, static_cast<chrome::HostDesktopType>(host_desktop_type));
86 #endif
87 }
88
44 bool ChromeTabRestoreServiceClient::ShouldTrackURLForRestore(const GURL& url) { 89 bool ChromeTabRestoreServiceClient::ShouldTrackURLForRestore(const GURL& url) {
45 return ::ShouldTrackURLForRestore(url); 90 return ::ShouldTrackURLForRestore(url);
46 } 91 }
47 92
48 base::SequencedWorkerPool* ChromeTabRestoreServiceClient::GetBlockingPool() { 93 base::SequencedWorkerPool* ChromeTabRestoreServiceClient::GetBlockingPool() {
49 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 94 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
50 return content::BrowserThread::GetBlockingPool(); 95 return content::BrowserThread::GetBlockingPool();
51 } 96 }
52 97
53 base::FilePath ChromeTabRestoreServiceClient::GetPathToSaveTo() { 98 base::FilePath ChromeTabRestoreServiceClient::GetPathToSaveTo() {
(...skipping 27 matching lines...) Expand all
81 DCHECK(HasLastSession()); 126 DCHECK(HasLastSession());
82 #if defined(ENABLE_SESSION_SERVICE) 127 #if defined(ENABLE_SESSION_SERVICE)
83 SessionServiceFactory::GetForProfile(profile_) 128 SessionServiceFactory::GetForProfile(profile_)
84 ->GetLastSession(callback, tracker); 129 ->GetLastSession(callback, tracker);
85 #endif 130 #endif
86 } 131 }
87 132
88 void ChromeTabRestoreServiceClient::OnTabRestored(const GURL& url) { 133 void ChromeTabRestoreServiceClient::OnTabRestored(const GURL& url) {
89 RecordAppLaunch(profile_, url); 134 RecordAppLaunch(profile_, url);
90 } 135 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/chrome_tab_restore_service_client.h ('k') | chrome/browser/sessions/in_memory_tab_restore_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698