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 "base/prefs/pref_service.h" | 5 #include "base/prefs/pref_service.h" |
6 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
7 #include "chrome/browser/extensions/api/settings_private/prefs_util.h" | 7 #include "chrome/browser/extensions/api/settings_private/prefs_util.h" |
8 #include "chrome/browser/extensions/chrome_extension_function.h" | 8 #include "chrome/browser/extensions/chrome_extension_function.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 11 #include "components/proxy_config/proxy_config_pref_names.h" |
11 #include "components/url_formatter/url_fixer.h" | 12 #include "components/url_formatter/url_fixer.h" |
12 | 13 |
13 #if defined(OS_CHROMEOS) | 14 #if defined(OS_CHROMEOS) |
14 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" | 15 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" |
15 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" | 16 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" |
16 #include "chrome/browser/chromeos/settings/cros_settings.h" | 17 #include "chrome/browser/chromeos/settings/cros_settings.h" |
17 #endif | 18 #endif |
18 | 19 |
19 namespace extensions { | 20 namespace extensions { |
20 | 21 |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 315 } |
315 | 316 |
316 PrefService* PrefsUtil::FindServiceForPref(const std::string& pref_name) { | 317 PrefService* PrefsUtil::FindServiceForPref(const std::string& pref_name) { |
317 PrefService* user_prefs = profile_->GetPrefs(); | 318 PrefService* user_prefs = profile_->GetPrefs(); |
318 | 319 |
319 // Proxy is a peculiar case: on ChromeOS, settings exist in both user | 320 // Proxy is a peculiar case: on ChromeOS, settings exist in both user |
320 // prefs and local state, but chrome://settings should affect only user prefs. | 321 // prefs and local state, but chrome://settings should affect only user prefs. |
321 // Elsewhere the proxy settings are stored in local state. | 322 // Elsewhere the proxy settings are stored in local state. |
322 // See http://crbug.com/157147 | 323 // See http://crbug.com/157147 |
323 | 324 |
324 if (pref_name == prefs::kProxy) { | 325 if (pref_name == proxy_config::prefs::kProxy) { |
325 #if defined(OS_CHROMEOS) | 326 #if defined(OS_CHROMEOS) |
326 return user_prefs; | 327 return user_prefs; |
327 #else | 328 #else |
328 return g_browser_process->local_state(); | 329 return g_browser_process->local_state(); |
329 #endif | 330 #endif |
330 } | 331 } |
331 | 332 |
332 // Find which PrefService contains the given pref. Pref names should not | 333 // Find which PrefService contains the given pref. Pref names should not |
333 // be duplicated across services, however if they are, prefer the user's | 334 // be duplicated across services, however if they are, prefer the user's |
334 // prefs. | 335 // prefs. |
335 if (user_prefs->FindPreference(pref_name)) | 336 if (user_prefs->FindPreference(pref_name)) |
336 return user_prefs; | 337 return user_prefs; |
337 | 338 |
338 if (g_browser_process->local_state()->FindPreference(pref_name)) | 339 if (g_browser_process->local_state()->FindPreference(pref_name)) |
339 return g_browser_process->local_state(); | 340 return g_browser_process->local_state(); |
340 | 341 |
341 return user_prefs; | 342 return user_prefs; |
342 } | 343 } |
343 | 344 |
344 bool PrefsUtil::IsCrosSetting(const std::string& pref_name) { | 345 bool PrefsUtil::IsCrosSetting(const std::string& pref_name) { |
345 #if defined(OS_CHROMEOS) | 346 #if defined(OS_CHROMEOS) |
346 return CrosSettings::Get()->IsCrosSettings(pref_name); | 347 return CrosSettings::Get()->IsCrosSettings(pref_name); |
347 #else | 348 #else |
348 return false; | 349 return false; |
349 #endif | 350 #endif |
350 } | 351 } |
351 | 352 |
352 } // namespace extensions | 353 } // namespace extensions |
OLD | NEW |