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

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: Add locale check on attach 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 137 }
137 void SaveAccessToken(const GURL& server_url, 138 void SaveAccessToken(const GURL& server_url,
138 const base::string16& access_token) override {} 139 const base::string16& access_token) override {}
139 140
140 private: 141 private:
141 ~AwAccessTokenStore() override {} 142 ~AwAccessTokenStore() override {}
142 143
143 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); 144 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore);
144 }; 145 };
145 146
147 AwLocaleManager* g_locale_manager = NULL;
148
146 } // anonymous namespace 149 } // anonymous namespace
147 150
151 // static
148 std::string AwContentBrowserClient::GetAcceptLangsImpl() { 152 std::string AwContentBrowserClient::GetAcceptLangsImpl() {
149 // Start with the currnet locale. 153 // Start with the current locale.
150 std::string langs = base::android::GetDefaultLocale(); 154 std::string langs = g_locale_manager->GetLocale();
151 155
152 // If we're not en-US, add in en-US which will be 156 // If we're not en-US, add in en-US which will be
153 // used with a lower q-value. 157 // used with a lower q-value.
154 if (base::StringToLowerASCII(langs) != "en-us") { 158 if (base::StringToLowerASCII(langs) != "en-us") {
155 langs += ",en-US"; 159 langs += ",en-US";
156 } 160 }
157 return langs; 161 return langs;
158 } 162 }
159 163
164 // static
160 AwBrowserContext* AwContentBrowserClient::GetAwBrowserContext() { 165 AwBrowserContext* AwContentBrowserClient::GetAwBrowserContext() {
161 return AwBrowserContext::GetDefault(); 166 return AwBrowserContext::GetDefault();
162 } 167 }
163 168
164 AwContentBrowserClient::AwContentBrowserClient( 169 AwContentBrowserClient::AwContentBrowserClient(
165 JniDependencyFactory* native_factory) 170 JniDependencyFactory* native_factory)
166 : native_factory_(native_factory) { 171 : native_factory_(native_factory) {
167 base::FilePath user_data_dir; 172 base::FilePath user_data_dir;
168 if (!PathService::Get(base::DIR_ANDROID_APP_DATA, &user_data_dir)) { 173 if (!PathService::Get(base::DIR_ANDROID_APP_DATA, &user_data_dir)) {
169 NOTREACHED() << "Failed to get app data directory for Android WebView"; 174 NOTREACHED() << "Failed to get app data directory for Android WebView";
170 } 175 }
171 browser_context_.reset( 176 browser_context_.reset(
172 new AwBrowserContext(user_data_dir, native_factory_)); 177 new AwBrowserContext(user_data_dir, native_factory_));
178 g_locale_manager = native_factory->CreateAwLocaleManager();
173 } 179 }
174 180
175 AwContentBrowserClient::~AwContentBrowserClient() { 181 AwContentBrowserClient::~AwContentBrowserClient() {
182 delete g_locale_manager;
183 g_locale_manager = NULL;
176 } 184 }
177 185
178 void AwContentBrowserClient::AddCertificate(net::CertificateMimeType cert_type, 186 void AwContentBrowserClient::AddCertificate(net::CertificateMimeType cert_type,
179 const void* cert_data, 187 const void* cert_data,
180 size_t cert_size, 188 size_t cert_size,
181 int render_process_id, 189 int render_process_id,
182 int render_frame_id) { 190 int render_frame_id) {
183 if (cert_size > 0) 191 if (cert_size > 0)
184 net::android::StoreCertificate(cert_type, cert_data, cert_size); 192 net::android::StoreCertificate(cert_type, cert_data, cert_size);
185 } 193 }
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 480
473 #if defined(VIDEO_HOLE) 481 #if defined(VIDEO_HOLE)
474 content::ExternalVideoSurfaceContainer* 482 content::ExternalVideoSurfaceContainer*
475 AwContentBrowserClient::OverrideCreateExternalVideoSurfaceContainer( 483 AwContentBrowserClient::OverrideCreateExternalVideoSurfaceContainer(
476 content::WebContents* web_contents) { 484 content::WebContents* web_contents) {
477 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents); 485 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents);
478 } 486 }
479 #endif 487 #endif
480 488
481 } // namespace android_webview 489 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698