OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/policy/chrome_browser_policy_connector.h" | 5 #include "chrome/browser/policy/chrome_browser_policy_connector.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
16 #include "chrome/browser/policy/configuration_policy_handler_list_factory.h" | 16 #include "chrome/browser/policy/configuration_policy_handler_list_factory.h" |
17 #include "chrome/browser/policy/device_management_service_configuration.h" | 17 #include "chrome/browser/policy/device_management_service_configuration.h" |
18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
19 #include "components/policy/core/common/async_policy_provider.h" | 19 #include "components/policy/core/common/async_policy_provider.h" |
20 #include "components/policy/core/common/cloud/device_management_service.h" | 20 #include "components/policy/core/common/cloud/device_management_service.h" |
21 #include "components/policy/core/common/configuration_policy_provider.h" | 21 #include "components/policy/core/common/configuration_policy_provider.h" |
22 #include "components/policy/core/common/policy_map.h" | 22 #include "components/policy/core/common/policy_map.h" |
23 #include "components/policy/core/common/policy_namespace.h" | 23 #include "components/policy/core/common/policy_namespace.h" |
24 #include "components/policy/core/common/policy_service.h" | 24 #include "components/policy/core/common/policy_service.h" |
25 #include "components/policy/core/common/policy_types.h" | 25 #include "components/policy/core/common/policy_types.h" |
26 #include "components/signin/core/common/signin_switches.h" | 26 #include "components/signin/core/common/signin_switches.h" |
27 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/common/content_switches.h" | |
28 #include "net/url_request/url_request_context_getter.h" | 29 #include "net/url_request/url_request_context_getter.h" |
29 #include "policy/policy_constants.h" | 30 #include "policy/policy_constants.h" |
30 | 31 |
31 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
32 #include "components/policy/core/common/policy_loader_win.h" | 33 #include "components/policy/core/common/policy_loader_win.h" |
33 #elif defined(OS_MACOSX) | 34 #elif defined(OS_MACOSX) |
34 #include <CoreFoundation/CoreFoundation.h> | 35 #include <CoreFoundation/CoreFoundation.h> |
35 #include "components/policy/core/common/policy_loader_mac.h" | 36 #include "components/policy/core/common/policy_loader_mac.h" |
36 #include "components/policy/core/common/preferences_mac.h" | 37 #include "components/policy/core/common/preferences_mac.h" |
37 #elif defined(OS_POSIX) && !defined(OS_ANDROID) | 38 #elif defined(OS_POSIX) && !defined(OS_ANDROID) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 new DeviceManagementServiceConfiguration( | 83 new DeviceManagementServiceConfiguration( |
83 BrowserPolicyConnector::GetDeviceManagementUrl())); | 84 BrowserPolicyConnector::GetDeviceManagementUrl())); |
84 scoped_ptr<DeviceManagementService> device_management_service( | 85 scoped_ptr<DeviceManagementService> device_management_service( |
85 new DeviceManagementService(configuration.Pass())); | 86 new DeviceManagementService(configuration.Pass())); |
86 device_management_service->ScheduleInitialization( | 87 device_management_service->ScheduleInitialization( |
87 kServiceInitializationStartupDelay); | 88 kServiceInitializationStartupDelay); |
88 | 89 |
89 BrowserPolicyConnector::Init( | 90 BrowserPolicyConnector::Init( |
90 local_state, request_context, device_management_service.Pass()); | 91 local_state, request_context, device_management_service.Pass()); |
91 | 92 |
92 AppendExtraFlagPerPolicy(); | 93 AppendExtraFlagsPerPolicy(); |
93 } | 94 } |
94 | 95 |
95 ConfigurationPolicyProvider* | 96 ConfigurationPolicyProvider* |
96 ChromeBrowserPolicyConnector::CreatePlatformProvider() { | 97 ChromeBrowserPolicyConnector::CreatePlatformProvider() { |
97 #if defined(OS_WIN) | 98 #if defined(OS_WIN) |
98 scoped_ptr<AsyncPolicyLoader> loader(PolicyLoaderWin::Create( | 99 scoped_ptr<AsyncPolicyLoader> loader(PolicyLoaderWin::Create( |
99 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 100 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
100 kRegistryChromePolicyKey)); | 101 kRegistryChromePolicyKey)); |
101 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); | 102 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); |
102 #elif defined(OS_MACOSX) | 103 #elif defined(OS_MACOSX) |
(...skipping 13 matching lines...) Expand all Loading... | |
116 } else { | 117 } else { |
117 return NULL; | 118 return NULL; |
118 } | 119 } |
119 #elif defined(OS_ANDROID) | 120 #elif defined(OS_ANDROID) |
120 return new PolicyProviderAndroid(); | 121 return new PolicyProviderAndroid(); |
121 #else | 122 #else |
122 return NULL; | 123 return NULL; |
123 #endif | 124 #endif |
124 } | 125 } |
125 | 126 |
126 void ChromeBrowserPolicyConnector::AppendExtraFlagPerPolicy() { | 127 void ChromeBrowserPolicyConnector::AppendExtraFlagsPerPolicy() { |
127 PolicyService* policy_service = GetPolicyService(); | 128 PolicyService* policy_service = GetPolicyService(); |
128 PolicyNamespace chrome_ns = PolicyNamespace(POLICY_DOMAIN_CHROME, ""); | 129 PolicyNamespace chrome_ns = PolicyNamespace(POLICY_DOMAIN_CHROME, ""); |
129 const PolicyMap& chrome_policy = policy_service->GetPolicies(chrome_ns); | 130 const PolicyMap& chrome_policy = policy_service->GetPolicies(chrome_ns); |
130 const base::Value* policy_value = | 131 const base::Value* policy_value = |
131 chrome_policy.GetValue(key::kEnableDeprecatedWebBasedSignin); | 132 chrome_policy.GetValue(key::kEnableDeprecatedWebBasedSignin); |
132 bool enabled = false; | 133 bool enabled = false; |
133 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 134 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
134 if (policy_value && policy_value->GetAsBoolean(&enabled) && enabled) { | 135 if (policy_value && policy_value->GetAsBoolean(&enabled) && enabled) { |
135 if (!command_line->HasSwitch(switches::kEnableWebBasedSignin)) | 136 if (!command_line->HasSwitch(switches::kEnableWebBasedSignin)) |
136 command_line->AppendSwitch(switches::kEnableWebBasedSignin); | 137 command_line->AppendSwitch(switches::kEnableWebBasedSignin); |
137 // In M41, to fully enable web-based sign in, the kEnableIframeBasedSignin | 138 // In M41, to fully enable web-based sign in, the kEnableIframeBasedSignin |
138 // must also be specified. | 139 // must also be specified. |
139 if (!command_line->HasSwitch(switches::kEnableIframeBasedSignin)) | 140 if (!command_line->HasSwitch(switches::kEnableIframeBasedSignin)) |
140 command_line->AppendSwitch(switches::kEnableIframeBasedSignin); | 141 command_line->AppendSwitch(switches::kEnableIframeBasedSignin); |
141 } | 142 } |
143 | |
144 if (command_line->HasSwitch(switches::kEnableNpapi)) | |
145 return; | |
146 | |
147 // The list of Plugin related policies that re-enable NPAPI. Remove once NPAPI | |
148 // is dead. | |
149 const std::string pluginPolicies[] = { key::kEnabledPlugins, | |
jam
2015/02/19 23:46:48
nit: plugin_policies
Will Harris
2015/02/20 03:55:49
Done.
| |
150 key::kPluginsAllowedForUrls, | |
151 key::kPluginsBlockedForUrls, | |
152 key::kDisabledPluginsExceptions, | |
153 key::kDisabledPlugins }; | |
154 for (auto policy : pluginPolicies) { | |
155 if (chrome_policy.GetValue(policy)) { | |
156 command_line->AppendSwitch(switches::kEnableNpapi); | |
157 break; | |
158 } | |
159 } | |
142 } | 160 } |
143 | 161 |
144 } // namespace policy | 162 } // namespace policy |
OLD | NEW |