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/bookmarks/managed_bookmark_service_factory.h" | 5 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "chrome/browser/policy/profile_policy_connector.h" | 12 #include "chrome/browser/policy/profile_policy_connector.h" |
13 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 13 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
14 #include "chrome/browser/profiles/incognito_helpers.h" | 14 #include "chrome/browser/profiles/incognito_helpers.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "components/bookmarks/managed/managed_bookmark_service.h" | 16 #include "components/bookmarks/managed/managed_bookmark_service.h" |
17 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 17 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
18 #include "components/policy/policy_constants.h" | 18 #include "components/policy/policy_constants.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 std::string GetManagedBookmarksDomain(Profile* profile) { | 22 std::string GetManagedBookmarksDomain(Profile* profile) { |
23 policy::ProfilePolicyConnector* connector = | 23 policy::ProfilePolicyConnector* connector = |
24 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile); | 24 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile); |
25 if (connector->IsPolicyFromCloudPolicy(policy::key::kManagedBookmarks)) | 25 if (connector->IsProfilePolicy(policy::key::kManagedBookmarks)) |
26 return connector->GetManagementDomain(); | 26 return connector->GetManagementDomain(); |
27 return std::string(); | 27 return std::string(); |
28 } | 28 } |
29 | 29 |
30 std::unique_ptr<KeyedService> BuildManagedBookmarkService( | 30 std::unique_ptr<KeyedService> BuildManagedBookmarkService( |
31 content::BrowserContext* context) { | 31 content::BrowserContext* context) { |
32 Profile* profile = Profile::FromBrowserContext(context); | 32 Profile* profile = Profile::FromBrowserContext(context); |
33 return base::MakeUnique<bookmarks::ManagedBookmarkService>( | 33 return base::MakeUnique<bookmarks::ManagedBookmarkService>( |
34 profile->GetPrefs(), | 34 profile->GetPrefs(), |
35 base::Bind(&GetManagedBookmarksDomain, base::Unretained(profile))); | 35 base::Bind(&GetManagedBookmarksDomain, base::Unretained(profile))); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 | 71 |
72 content::BrowserContext* ManagedBookmarkServiceFactory::GetBrowserContextToUse( | 72 content::BrowserContext* ManagedBookmarkServiceFactory::GetBrowserContextToUse( |
73 content::BrowserContext* context) const { | 73 content::BrowserContext* context) const { |
74 return chrome::GetBrowserContextRedirectedInIncognito(context); | 74 return chrome::GetBrowserContextRedirectedInIncognito(context); |
75 } | 75 } |
76 | 76 |
77 bool ManagedBookmarkServiceFactory::ServiceIsNULLWhileTesting() const { | 77 bool ManagedBookmarkServiceFactory::ServiceIsNULLWhileTesting() const { |
78 return true; | 78 return true; |
79 } | 79 } |
OLD | NEW |