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

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

Issue 2496183002: Use GetDefaultLocaleListString for returning LocaleList (Closed)
Patch Set: extract setLocale method, since configuration.getLocales() returns the same as LocaleUtils.getDefau… Created 4 years, 1 month 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 <utility> 7 #include <utility>
8 8
9 #include "android_webview/browser/aw_browser_context.h" 9 #include "android_webview/browser/aw_browser_context.h"
10 #include "android_webview/browser/aw_browser_main_parts.h" 10 #include "android_webview/browser/aw_browser_main_parts.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 void AwContentsMessageFilter::OnSubFrameCreated(int parent_render_frame_id, 151 void AwContentsMessageFilter::OnSubFrameCreated(int parent_render_frame_id,
152 int child_render_frame_id) { 152 int child_render_frame_id) {
153 AwContentsIoThreadClient::SubFrameCreated( 153 AwContentsIoThreadClient::SubFrameCreated(
154 process_id_, parent_render_frame_id, child_render_frame_id); 154 process_id_, parent_render_frame_id, child_render_frame_id);
155 } 155 }
156 156
157 AwLocaleManager* g_locale_manager = NULL; 157 AwLocaleManager* g_locale_manager = NULL;
158 158
159 } // anonymous namespace 159 } // anonymous namespace
160 160
161 // TODO(yirui): could use similar logic as in
162 // PrependToAcceptLanguagesIfNecessary
163 // in chrome/browser/android/preferences/pref_service_bridge.cc
161 // static 164 // static
162 std::string AwContentBrowserClient::GetAcceptLangsImpl() { 165 std::string AwContentBrowserClient::GetAcceptLangsImpl() {
Seigo Nonaka 2016/11/15 05:15:59 Question: Is there no unit tests for this function
Yirui Huang 2016/11/16 00:23:45 Done.
163 // Start with the current locale. 166 // Start with the current locale(s).
164 std::string langs = g_locale_manager->GetLocale(); 167 std::string locales_string = g_locale_manager->GetLocales();
165 168
166 // If we're not en-US, add in en-US which will be 169 // If accept languages do not contain en-US, add in en-US which will be
167 // used with a lower q-value. 170 // used with a lower q-value.
168 if (base::ToLowerASCII(langs) != "en-us") { 171 size_t found_enUS = locales_string.find("en-US");
Seigo Nonaka 2016/11/15 05:15:59 Question: do we no longer need to compare in case
Yirui Huang 2016/11/16 00:23:45 I thought locales_string that we got from here is
Seigo Nonaka 2016/11/16 01:26:14 Please note that developer can set accept language
Yirui Huang 2016/11/16 01:49:12 I see. Thanks for pointing this out. I wasn't awar
169 langs += ",en-US"; 172 if (found_enUS == std::string::npos)
170 } 173 locales_string += ",en-US";
171 return langs; 174 return locales_string;
172 } 175 }
173 176
174 // static 177 // static
175 AwBrowserContext* AwContentBrowserClient::GetAwBrowserContext() { 178 AwBrowserContext* AwContentBrowserClient::GetAwBrowserContext() {
176 return AwBrowserContext::GetDefault(); 179 return AwBrowserContext::GetDefault();
177 } 180 }
178 181
179 AwContentBrowserClient::AwContentBrowserClient( 182 AwContentBrowserClient::AwContentBrowserClient(
180 JniDependencyFactory* native_factory) 183 JniDependencyFactory* native_factory)
181 : native_factory_(native_factory) { 184 : native_factory_(native_factory) {
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 if (id == -1) 537 if (id == -1)
535 return nullptr; 538 return nullptr;
536 539
537 base::StringPiece manifest_contents = 540 base::StringPiece manifest_contents =
538 ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( 541 ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
539 id, ui::ScaleFactor::SCALE_FACTOR_NONE); 542 id, ui::ScaleFactor::SCALE_FACTOR_NONE);
540 return base::JSONReader::Read(manifest_contents); 543 return base::JSONReader::Read(manifest_contents);
541 } 544 }
542 545
543 } // namespace android_webview 546 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698