summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/sessions/sessions_api.cc
diff options
context:
space:
mode:
authorbenwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-28 21:19:23 +0000
committerbenwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-28 21:19:23 +0000
commit21a40087a57e13cc9b81cb7e8064f74587dfa8a1 (patch)
treee88d44c64fcaa47a5b45533a4d6c993de770757c /chrome/browser/extensions/api/sessions/sessions_api.cc
parent0f75118d4799a7c5421150826eaccd1dfd253f8e (diff)
downloadchromium_src-21a40087a57e13cc9b81cb7e8064f74587dfa8a1.zip
chromium_src-21a40087a57e13cc9b81cb7e8064f74587dfa8a1.tar.gz
chromium_src-21a40087a57e13cc9b81cb7e8064f74587dfa8a1.tar.bz2
Remove Profile dependency from ExtensionFunction
This instead creates new variants of ExtensionFunction for Chrome APIs, which need Profile, and uses them for any API that needs to access Profiles. TBR=sky@chromium.org BUG=297942 Review URL: https://codereview.chromium.org/35893010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231406 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api/sessions/sessions_api.cc')
-rw-r--r--chrome/browser/extensions/api/sessions/sessions_api.cc26
1 files changed, 12 insertions, 14 deletions
diff --git a/chrome/browser/extensions/api/sessions/sessions_api.cc b/chrome/browser/extensions/api/sessions/sessions_api.cc
index 7115dcb..013afa3 100644
--- a/chrome/browser/extensions/api/sessions/sessions_api.cc
+++ b/chrome/browser/extensions/api/sessions/sessions_api.cc
@@ -141,7 +141,7 @@ bool is_window_entry(const TabRestoreService::Entry* entry) {
scoped_ptr<tabs::Tab> SessionsGetRecentlyClosedFunction::CreateTabModel(
const TabRestoreService::Tab& tab, int session_id, int selected_index) {
- return CreateTabModelHelper(profile(),
+ return CreateTabModelHelper(GetProfile(),
tab.navigations[tab.current_navigation_index],
base::IntToString(session_id),
tab.tabstrip_index,
@@ -204,7 +204,7 @@ bool SessionsGetRecentlyClosedFunction::RunImpl() {
std::vector<linked_ptr<api::sessions::Session> > result;
TabRestoreService* tab_restore_service =
- TabRestoreServiceFactory::GetForProfile(profile());
+ TabRestoreServiceFactory::GetForProfile(GetProfile());
DCHECK(tab_restore_service);
// List of entries. They are ordered from most to least recent.
@@ -228,7 +228,7 @@ scoped_ptr<tabs::Tab> SessionsGetDevicesFunction::CreateTabModel(
int tab_index,
int selected_index) {
std::string session_id = SessionId(session_tag, tab.tab_id.id()).ToString();
- return CreateTabModelHelper(profile(),
+ return CreateTabModelHelper(GetProfile(),
tab.navigations[tab.current_navigation_index],
session_id,
tab_index,
@@ -250,7 +250,7 @@ scoped_ptr<windows::Window> SessionsGetDevicesFunction::CreateWindowModel(
continue;
const sessions::SerializedNavigationEntry& current_navigation =
tab->navigations.at(tab->normalized_navigation_index());
- if (chrome::IsNTPURL(current_navigation.virtual_url(), profile())) {
+ if (chrome::IsNTPURL(current_navigation.virtual_url(), GetProfile())) {
continue;
}
tabs_in_window.push_back(tab);
@@ -351,7 +351,7 @@ scoped_ptr<api::sessions::Device> SessionsGetDevicesFunction::CreateDeviceModel(
bool SessionsGetDevicesFunction::RunImpl() {
ProfileSyncService* service =
- ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile());
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(GetProfile());
if (!(service && service->GetPreferredDataTypes().Has(syncer::SESSIONS))) {
// Sync not enabled.
results_ = GetDevices::Results::Create(
@@ -419,7 +419,7 @@ bool SessionsRestoreFunction::SetResultRestoredWindow(int window_id) {
bool SessionsRestoreFunction::RestoreMostRecentlyClosed(Browser* browser) {
TabRestoreService* tab_restore_service =
- TabRestoreServiceFactory::GetForProfile(profile());
+ TabRestoreServiceFactory::GetForProfile(GetProfile());
chrome::HostDesktopType host_desktop_type = browser->host_desktop_type();
TabRestoreService::Entries entries = tab_restore_service->entries();
@@ -448,7 +448,7 @@ bool SessionsRestoreFunction::RestoreMostRecentlyClosed(Browser* browser) {
bool SessionsRestoreFunction::RestoreLocalSession(const SessionId& session_id,
Browser* browser) {
TabRestoreService* tab_restore_service =
- TabRestoreServiceFactory::GetForProfile(profile());
+ TabRestoreServiceFactory::GetForProfile(GetProfile());
chrome::HostDesktopType host_desktop_type = browser->host_desktop_type();
TabRestoreService::Entries entries = tab_restore_service->entries();
@@ -496,7 +496,7 @@ bool SessionsRestoreFunction::RestoreLocalSession(const SessionId& session_id,
bool SessionsRestoreFunction::RestoreForeignSession(const SessionId& session_id,
Browser* browser) {
ProfileSyncService* service =
- ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile());
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(GetProfile());
if (!(service && service->GetPreferredDataTypes().Has(syncer::SESSIONS))) {
SetError(kSessionSyncError);
return false;
@@ -541,9 +541,8 @@ bool SessionsRestoreFunction::RestoreForeignSession(const SessionId& session_id,
chrome::HostDesktopType host_desktop_type = browser->host_desktop_type();
// Only restore one window at a time.
- std::vector<Browser*> browsers =
- SessionRestore::RestoreForeignSessionWindows(profile(), host_desktop_type,
- window, window + 1);
+ std::vector<Browser*> browsers = SessionRestore::RestoreForeignSessionWindows(
+ GetProfile(), host_desktop_type, window, window + 1);
// Will always create one browser because we only restore one window per call.
DCHECK_EQ(1u, browsers.size());
return SetResultRestoredWindow(ExtensionTabUtil::GetWindowId(browsers[0]));
@@ -553,9 +552,8 @@ bool SessionsRestoreFunction::RunImpl() {
scoped_ptr<Restore::Params> params(Restore::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
- Browser* browser =
- chrome::FindBrowserWithProfile(profile(),
- chrome::HOST_DESKTOP_TYPE_NATIVE);
+ Browser* browser = chrome::FindBrowserWithProfile(
+ GetProfile(), chrome::HOST_DESKTOP_TYPE_NATIVE);
if (!browser) {
SetError(kNoBrowserToRestoreSession);
return false;