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

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

Issue 25414005: Clear session-only data when all browser windows are closed. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 2 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
« no previous file with comments | « chrome/browser/sessions/session_service.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/session_service_factory.h" 5 #include "chrome/browser/sessions/session_service_factory.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/sessions/session_data_deleter.h"
8 #include "chrome/browser/sessions/session_service.h" 9 #include "chrome/browser/sessions/session_service.h"
9 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 10 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
10 11
11 // static 12 // static
12 SessionService* SessionServiceFactory::GetForProfile(Profile* profile) { 13 SessionService* SessionServiceFactory::GetForProfile(Profile* profile) {
13 #if defined(OS_ANDROID) 14 #if defined(OS_ANDROID)
14 // For Android we do not store sessions in the SessionService. 15 // For Android we do not store sessions in the SessionService.
15 return NULL; 16 return NULL;
16 #else 17 #else
17 return static_cast<SessionService*>( 18 return static_cast<SessionService*>(
18 GetInstance()->GetServiceForBrowserContext(profile, true)); 19 GetInstance()->GetServiceForBrowserContext(profile, true));
19 #endif 20 #endif
20 } 21 }
21 22
22 // static 23 // static
23 SessionService* SessionServiceFactory::GetForProfileIfExisting( 24 SessionService* SessionServiceFactory::GetForProfileIfExisting(
24 Profile* profile) { 25 Profile* profile) {
25 #if defined(OS_ANDROID) 26 #if defined(OS_ANDROID)
26 // For Android we do not store sessions in the SessionService. 27 // For Android we do not store sessions in the SessionService.
27 return NULL; 28 return NULL;
28 #else 29 #else
29 return static_cast<SessionService*>( 30 return static_cast<SessionService*>(
30 GetInstance()->GetServiceForBrowserContext(profile, false)); 31 GetInstance()->GetServiceForBrowserContext(profile, false));
31 #endif 32 #endif
32 } 33 }
33 34
34 // static 35 // static
35 void SessionServiceFactory::ShutdownForProfile(Profile* profile) { 36 void SessionServiceFactory::ShutdownForProfile(Profile* profile) {
37 DeleteSessionOnlyData(profile);
38
36 // We're about to exit, force creation of the session service if it hasn't 39 // We're about to exit, force creation of the session service if it hasn't
37 // been created yet. We do this to ensure session state matches the point in 40 // been created yet. We do this to ensure session state matches the point in
38 // time the user exited. 41 // time the user exited.
39 SessionServiceFactory* factory = GetInstance(); 42 SessionServiceFactory* factory = GetInstance();
40 factory->GetServiceForBrowserContext(profile, true); 43 factory->GetServiceForBrowserContext(profile, true);
41 44
42 // Shut down and remove the reference to the session service, and replace it 45 // Shut down and remove the reference to the session service, and replace it
43 // with an explicit NULL to prevent it being recreated on the next access. 46 // with an explicit NULL to prevent it being recreated on the next access.
44 factory->BrowserContextShutdown(profile); 47 factory->BrowserContextShutdown(profile);
45 factory->BrowserContextDestroyed(profile); 48 factory->BrowserContextDestroyed(profile);
(...skipping 21 matching lines...) Expand all
67 return service; 70 return service;
68 } 71 }
69 72
70 bool SessionServiceFactory::ServiceIsCreatedWithBrowserContext() const { 73 bool SessionServiceFactory::ServiceIsCreatedWithBrowserContext() const {
71 return true; 74 return true;
72 } 75 }
73 76
74 bool SessionServiceFactory::ServiceIsNULLWhileTesting() const { 77 bool SessionServiceFactory::ServiceIsNULLWhileTesting() const {
75 return true; 78 return true;
76 } 79 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_service.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698