| 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 return connector->GetDisplayDomainForManagedBookmarks(); |
| 26 return connector->GetManagementDomain(); | |
| 27 return std::string(); | |
| 28 } | 26 } |
| 29 | 27 |
| 30 std::unique_ptr<KeyedService> BuildManagedBookmarkService( | 28 std::unique_ptr<KeyedService> BuildManagedBookmarkService( |
| 31 content::BrowserContext* context) { | 29 content::BrowserContext* context) { |
| 32 Profile* profile = Profile::FromBrowserContext(context); | 30 Profile* profile = Profile::FromBrowserContext(context); |
| 33 return base::MakeUnique<bookmarks::ManagedBookmarkService>( | 31 return base::MakeUnique<bookmarks::ManagedBookmarkService>( |
| 34 profile->GetPrefs(), | 32 profile->GetPrefs(), |
| 35 base::Bind(&GetManagedBookmarksDomain, base::Unretained(profile))); | 33 base::Bind(&GetManagedBookmarksDomain, base::Unretained(profile))); |
| 36 } | 34 } |
| 37 | 35 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 68 } |
| 71 | 69 |
| 72 content::BrowserContext* ManagedBookmarkServiceFactory::GetBrowserContextToUse( | 70 content::BrowserContext* ManagedBookmarkServiceFactory::GetBrowserContextToUse( |
| 73 content::BrowserContext* context) const { | 71 content::BrowserContext* context) const { |
| 74 return chrome::GetBrowserContextRedirectedInIncognito(context); | 72 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 75 } | 73 } |
| 76 | 74 |
| 77 bool ManagedBookmarkServiceFactory::ServiceIsNULLWhileTesting() const { | 75 bool ManagedBookmarkServiceFactory::ServiceIsNULLWhileTesting() const { |
| 78 return true; | 76 return true; |
| 79 } | 77 } |
| OLD | NEW |