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

Side by Side Diff: chrome/browser/extensions/api/settings_private/settings_private_delegate_factory.cc

Issue 2499093002: Fix Guest Mode errors in MD Settings by using the incognito context. (Closed)
Patch Set: Created 4 years, 1 month 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/extensions/api/settings_private/settings_private_delegate_factory.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/extensions/api/settings_private/settings_private_delega te_factory.h" 5 #include "chrome/browser/extensions/api/settings_private/settings_private_delega te_factory.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/extensions/api/settings_private/settings_private_delega te.h" 8 #include "chrome/browser/extensions/api/settings_private/settings_private_delega te.h"
9 #include "chrome/browser/profiles/incognito_helpers.h"
9 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
10 #include "components/keyed_service/content/browser_context_dependency_manager.h" 11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
11 #include "extensions/browser/extension_system_provider.h" 12 #include "extensions/browser/extension_system_provider.h"
12 13
13 namespace extensions { 14 namespace extensions {
14 15
15 using content::BrowserContext; 16 using content::BrowserContext;
16 17
17 // static 18 // static
18 SettingsPrivateDelegate* SettingsPrivateDelegateFactory::GetForBrowserContext( 19 SettingsPrivateDelegate* SettingsPrivateDelegateFactory::GetForBrowserContext(
19 BrowserContext* browser_context) { 20 BrowserContext* browser_context) {
20 return static_cast<SettingsPrivateDelegate*>( 21 return static_cast<SettingsPrivateDelegate*>(
21 GetInstance()->GetServiceForBrowserContext(browser_context, true)); 22 GetInstance()->GetServiceForBrowserContext(browser_context, true));
22 } 23 }
23 24
24 // static 25 // static
25 SettingsPrivateDelegateFactory* SettingsPrivateDelegateFactory::GetInstance() { 26 SettingsPrivateDelegateFactory* SettingsPrivateDelegateFactory::GetInstance() {
26 return base::Singleton<SettingsPrivateDelegateFactory>::get(); 27 return base::Singleton<SettingsPrivateDelegateFactory>::get();
27 } 28 }
28 29
29 SettingsPrivateDelegateFactory::SettingsPrivateDelegateFactory() 30 SettingsPrivateDelegateFactory::SettingsPrivateDelegateFactory()
30 : BrowserContextKeyedServiceFactory( 31 : BrowserContextKeyedServiceFactory(
31 "SettingsPrivateDelegate", 32 "SettingsPrivateDelegate",
32 BrowserContextDependencyManager::GetInstance()) { 33 BrowserContextDependencyManager::GetInstance()) {
33 } 34 }
34 35
35 SettingsPrivateDelegateFactory::~SettingsPrivateDelegateFactory() { 36 SettingsPrivateDelegateFactory::~SettingsPrivateDelegateFactory() {
36 } 37 }
37 38
39 content::BrowserContext* SettingsPrivateDelegateFactory::GetBrowserContextToUse(
40 content::BrowserContext* context) const {
41 // Use the incognito profile when in Guest mode.
42 if (context->IsOffTheRecord())
43 return chrome::GetBrowserContextRedirectedInIncognito(context);
44 return context;
45 }
46
38 KeyedService* SettingsPrivateDelegateFactory::BuildServiceInstanceFor( 47 KeyedService* SettingsPrivateDelegateFactory::BuildServiceInstanceFor(
39 content::BrowserContext* profile) const { 48 content::BrowserContext* profile) const {
40 return new SettingsPrivateDelegate(static_cast<Profile*>(profile)); 49 return new SettingsPrivateDelegate(static_cast<Profile*>(profile));
41 } 50 }
42 51
43 } // namespace extensions 52 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/settings_private/settings_private_delegate_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698