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

Unified Diff: chrome/browser/chromeos/proxy_config_service_impl.cc

Issue 2306673002: arc: update proxy settings from UI and ONC policy. (Closed)
Patch Set: Fixed comments Created 4 years, 3 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/proxy_config_service_impl.cc
diff --git a/chrome/browser/chromeos/proxy_config_service_impl.cc b/chrome/browser/chromeos/proxy_config_service_impl.cc
index ce977fee3daed5876c7e796f91d9dc31050df8c3..2df7e27d658c7e1142e81e2179d08a4eb78e4d98 100644
--- a/chrome/browser/chromeos/proxy_config_service_impl.cc
+++ b/chrome/browser/chromeos/proxy_config_service_impl.cc
@@ -9,6 +9,7 @@
#include "base/callback.h"
#include "base/location.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/net/proxy_config_handler.h"
@@ -22,6 +23,7 @@
#include "components/prefs/pref_service.h"
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
#include "components/proxy_config/proxy_config_dictionary.h"
+#include "components/proxy_config/proxy_config_pref_names.h"
#include "components/proxy_config/proxy_prefs.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_thread.h"
@@ -173,6 +175,46 @@ bool ProxyConfigServiceImpl::IgnoreProxy(const PrefService* profile_prefs,
return !use_shared_proxies;
}
+// static
+std::unique_ptr<ProxyConfigDictionary>
+ProxyConfigServiceImpl::GetDefaultProxyConfigDictionary(
+ const PrefService* profile_prefs) {
+ // Apply Pref Proxy configuration if available.
+ net::ProxyConfig pref_proxy_config;
+ ProxyPrefs::ConfigState pref_state =
+ PrefProxyConfigTrackerImpl::ReadPrefConfig(profile_prefs,
+ &pref_proxy_config);
+ if (PrefProxyConfigTrackerImpl::PrefPrecedes(pref_state)) {
+ const PrefService::Preference* const pref =
+ profile_prefs->FindPreference(::proxy_config::prefs::kProxy);
+ const base::DictionaryValue* proxy_config_value;
+ bool value_exists = pref->GetValue()->GetAsDictionary(&proxy_config_value);
+ DCHECK(value_exists);
+
+ return base::MakeUnique<ProxyConfigDictionary>(proxy_config_value);
+ }
+
+ const chromeos::NetworkState* network = chromeos::NetworkHandler::Get()
+ ->network_state_handler()
+ ->DefaultNetwork();
+ // No connected network.
+ if (!network)
+ return nullptr;
+
+ // Apply network proxy configuration.
+ ::onc::ONCSource onc_source;
+ std::unique_ptr<ProxyConfigDictionary> proxy_config =
+ chromeos::proxy_config::GetProxyConfigForNetwork(
+ profile_prefs, g_browser_process->local_state(), *network,
+ &onc_source);
+ if (!chromeos::ProxyConfigServiceImpl::IgnoreProxy(
+ profile_prefs, network->profile_path(), onc_source))
+ return proxy_config;
+
+ return base::MakeUnique<ProxyConfigDictionary>(
+ ProxyConfigDictionary::CreateDirect());
+}
+
void ProxyConfigServiceImpl::DetermineEffectiveConfigFromDefaultNetwork() {
if (!NetworkHandler::IsInitialized())
return;

Powered by Google App Engine
This is Rietveld 408576698