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

Side by Side Diff: android_webview/browser/aw_content_browser_client.cc

Issue 1172093002: Implement HttpUserAgentSettings delegate for Android WebView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: New plumbing Created 5 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "android_webview/browser/aw_content_browser_client.h" 5 #include "android_webview/browser/aw_content_browser_client.h"
6 6
7 #include "android_webview/browser/aw_browser_context.h" 7 #include "android_webview/browser/aw_browser_context.h"
8 #include "android_webview/browser/aw_browser_main_parts.h" 8 #include "android_webview/browser/aw_browser_main_parts.h"
9 #include "android_webview/browser/aw_contents_client_bridge_base.h" 9 #include "android_webview/browser/aw_contents_client_bridge_base.h"
10 #include "android_webview/browser/aw_contents_io_thread_client.h" 10 #include "android_webview/browser/aw_contents_io_thread_client.h"
11 #include "android_webview/browser/aw_cookie_access_policy.h" 11 #include "android_webview/browser/aw_cookie_access_policy.h"
12 #include "android_webview/browser/aw_locale_manager.h"
12 #include "android_webview/browser/aw_printing_message_filter.h" 13 #include "android_webview/browser/aw_printing_message_filter.h"
13 #include "android_webview/browser/aw_quota_permission_context.h" 14 #include "android_webview/browser/aw_quota_permission_context.h"
14 #include "android_webview/browser/aw_web_preferences_populater.h" 15 #include "android_webview/browser/aw_web_preferences_populater.h"
15 #include "android_webview/browser/jni_dependency_factory.h" 16 #include "android_webview/browser/jni_dependency_factory.h"
16 #include "android_webview/browser/net/aw_url_request_context_getter.h" 17 #include "android_webview/browser/net/aw_url_request_context_getter.h"
17 #include "android_webview/browser/net_disk_cache_remover.h" 18 #include "android_webview/browser/net_disk_cache_remover.h"
18 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" 19 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h"
19 #include "android_webview/common/render_view_messages.h" 20 #include "android_webview/common/render_view_messages.h"
20 #include "android_webview/common/url_constants.h" 21 #include "android_webview/common/url_constants.h"
21 #include "base/android/locale_utils.h" 22 #include "base/android/locale_utils.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 132 }
132 void SaveAccessToken(const GURL& server_url, 133 void SaveAccessToken(const GURL& server_url,
133 const base::string16& access_token) override {} 134 const base::string16& access_token) override {}
134 135
135 private: 136 private:
136 ~AwAccessTokenStore() override {} 137 ~AwAccessTokenStore() override {}
137 138
138 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); 139 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore);
139 }; 140 };
140 141
142 AwLocaleManager* g_locale_manager = NULL;
Torne 2015/07/17 13:33:18 This should be a scoped_ptr belonging to AwContent
ctserng 2015/07/17 16:51:14 Ok, the reason its global is to access it through
143
141 } // anonymous namespace 144 } // anonymous namespace
142 145
146 // static
143 std::string AwContentBrowserClient::GetAcceptLangsImpl() { 147 std::string AwContentBrowserClient::GetAcceptLangsImpl() {
144 // Start with the currnet locale. 148 // Start with the current locale.
145 std::string langs = base::android::GetDefaultLocale(); 149 std::string langs = g_locale_manager->GetLocale();
146 150
147 // If we're not en-US, add in en-US which will be 151 // If we're not en-US, add in en-US which will be
148 // used with a lower q-value. 152 // used with a lower q-value.
149 if (base::StringToLowerASCII(langs) != "en-us") { 153 if (base::StringToLowerASCII(langs) != "en-us") {
150 langs += ",en-US"; 154 langs += ",en-US";
151 } 155 }
152 return langs; 156 return langs;
153 } 157 }
154 158
159 // static
155 AwBrowserContext* AwContentBrowserClient::GetAwBrowserContext() { 160 AwBrowserContext* AwContentBrowserClient::GetAwBrowserContext() {
156 return AwBrowserContext::GetDefault(); 161 return AwBrowserContext::GetDefault();
157 } 162 }
158 163
159 AwContentBrowserClient::AwContentBrowserClient( 164 AwContentBrowserClient::AwContentBrowserClient(
160 JniDependencyFactory* native_factory) 165 JniDependencyFactory* native_factory)
161 : native_factory_(native_factory) { 166 : native_factory_(native_factory) {
162 base::FilePath user_data_dir; 167 base::FilePath user_data_dir;
163 if (!PathService::Get(base::DIR_ANDROID_APP_DATA, &user_data_dir)) { 168 if (!PathService::Get(base::DIR_ANDROID_APP_DATA, &user_data_dir)) {
164 NOTREACHED() << "Failed to get app data directory for Android WebView"; 169 NOTREACHED() << "Failed to get app data directory for Android WebView";
165 } 170 }
166 browser_context_.reset( 171 browser_context_.reset(
167 new AwBrowserContext(user_data_dir, native_factory_)); 172 new AwBrowserContext(user_data_dir, native_factory_));
173 g_locale_manager = native_factory->CreateAwLocaleManager();
168 } 174 }
169 175
170 AwContentBrowserClient::~AwContentBrowserClient() { 176 AwContentBrowserClient::~AwContentBrowserClient() {
177 delete g_locale_manager;
178 g_locale_manager = NULL;
171 } 179 }
172 180
173 void AwContentBrowserClient::AddCertificate(net::CertificateMimeType cert_type, 181 void AwContentBrowserClient::AddCertificate(net::CertificateMimeType cert_type,
174 const void* cert_data, 182 const void* cert_data,
175 size_t cert_size, 183 size_t cert_size,
176 int render_process_id, 184 int render_process_id,
177 int render_frame_id) { 185 int render_frame_id) {
178 if (cert_size > 0) 186 if (cert_size > 0)
179 net::android::StoreCertificate(cert_type, cert_data, cert_size); 187 net::android::StoreCertificate(cert_type, cert_data, cert_size);
180 } 188 }
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 475
468 #if defined(VIDEO_HOLE) 476 #if defined(VIDEO_HOLE)
469 content::ExternalVideoSurfaceContainer* 477 content::ExternalVideoSurfaceContainer*
470 AwContentBrowserClient::OverrideCreateExternalVideoSurfaceContainer( 478 AwContentBrowserClient::OverrideCreateExternalVideoSurfaceContainer(
471 content::WebContents* web_contents) { 479 content::WebContents* web_contents) {
472 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents); 480 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents);
473 } 481 }
474 #endif 482 #endif
475 483
476 } // namespace android_webview 484 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698