From 6d02162df630de4ba5ff234ab6124dbb09a0c45c Mon Sep 17 00:00:00 2001
From: fujunwei <junwei.fu@intel.com>
Date: Mon, 27 Jun 2016 13:56:08 +0800
Subject: [PATCH] [Android] Support the feature of proxy in Crosswalk
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Crosswalk for android will update proxy when a PROXY_CHANGE intent is received,
but it’s need system permission to send the broadcast, there is also a workaround with
reflecting the incompatible api, but it’s too complex to maintain those codes, so
implement the new API in XWalkView to set proxy for images/text resources.

BUG=XWALK-6769
---
 net/proxy/proxy_config_service_android.cc |  8 ++++++++
 net/proxy/proxy_config_service_android.h  | 11 ++++++++---
 net/proxy/proxy_service.cc                |  5 +++++
 net/proxy/proxy_service.h                 |  1 +
 4 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/net/proxy/proxy_config_service_android.cc b/net/proxy/proxy_config_service_android.cc
index 990b614fb8bfa..1ce3fa38f9d55 100644
--- a/net/proxy/proxy_config_service_android.cc
+++ b/net/proxy/proxy_config_service_android.cc
@@ -411,4 +411,12 @@ void ProxyConfigServiceAndroid::ProxySettingsChanged() {
   delegate_->ProxySettingsChanged();
 }
 
+void ProxyConfigServiceAndroid::ProxySettingsChangedTo(
+    const std::string& host,
+    int port,
+    const std::string& pac_url,
+    const std::vector<std::string>& exclusion_list) {
+  delegate_->ProxySettingsChangedTo(host, port, pac_url, exclusion_list);
+}
+
 } // namespace net
diff --git a/net/proxy/proxy_config_service_android.h b/net/proxy/proxy_config_service_android.h
index 1b45eb102deb8..4706004cbca17 100644
--- a/net/proxy/proxy_config_service_android.h
+++ b/net/proxy/proxy_config_service_android.h
@@ -6,6 +6,7 @@
 #define NET_PROXY_PROXY_CONFIG_SERVICE_ANDROID_H_
 
 #include <string>
+#include <vector>
 
 #include "base/android/jni_android.h"
 #include "base/callback_forward.h"
@@ -78,6 +79,13 @@ class NET_EXPORT ProxyConfigServiceAndroid : public ProxyConfigService {
   void RemoveObserver(Observer* observer) override;
   ConfigAvailability GetLatestProxyConfig(ProxyConfig* config) override;
 
+  void ProxySettingsChanged();
+  void ProxySettingsChangedTo(
+      const std::string& host,
+      int port,
+      const std::string& pac_url,
+      const std::vector<std::string>& exclusion_list);
+
  private:
   friend class ProxyConfigServiceAndroidTestBase;
   class Delegate;
@@ -88,9 +96,6 @@ class NET_EXPORT ProxyConfigServiceAndroid : public ProxyConfigService {
       const scoped_refptr<base::SequencedTaskRunner>& jni_task_runner,
       GetPropertyCallback get_property_callback);
 
-  // For tests.
-  void ProxySettingsChanged();
-
   scoped_refptr<Delegate> delegate_;
 
   DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceAndroid);
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index 01bc3bb25db26..9a9185300cd75 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -1475,6 +1475,11 @@ ProxyService::State ProxyService::ResetProxyConfig(bool reset_fetched_config) {
   return previous_state;
 }
 
+ProxyConfigService* ProxyService::GetProxyConfigService() const {
+  DCHECK(CalledOnValidThread());
+  return config_service_.get();
+}
+
 void ProxyService::ResetConfigService(
     scoped_ptr<ProxyConfigService> new_proxy_config_service) {
   DCHECK(CalledOnValidThread());
diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h
index 8cd707144ddfd..351ccec7744cb 100644
--- a/net/proxy/proxy_service.h
+++ b/net/proxy/proxy_service.h
@@ -215,6 +215,7 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
   // ResolveProxy calls.
   void ResetConfigService(
       scoped_ptr<ProxyConfigService> new_proxy_config_service);
+  ProxyConfigService* GetProxyConfigService() const;
 
   // Returns the last configuration fetched from ProxyConfigService.
   const ProxyConfig& fetched_config() {