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

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

Issue 2884353003: [WebView] Remove more redundant classes (Closed)
Patch Set: add missing header Created 3 years, 7 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 <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"
11 #include "android_webview/browser/aw_contents.h"
11 #include "android_webview/browser/aw_contents_client_bridge.h" 12 #include "android_webview/browser/aw_contents_client_bridge.h"
12 #include "android_webview/browser/aw_contents_io_thread_client.h" 13 #include "android_webview/browser/aw_contents_io_thread_client.h"
13 #include "android_webview/browser/aw_cookie_access_policy.h" 14 #include "android_webview/browser/aw_cookie_access_policy.h"
14 #include "android_webview/browser/aw_devtools_manager_delegate.h" 15 #include "android_webview/browser/aw_devtools_manager_delegate.h"
15 #include "android_webview/browser/aw_locale_manager.h"
16 #include "android_webview/browser/aw_printing_message_filter.h" 16 #include "android_webview/browser/aw_printing_message_filter.h"
17 #include "android_webview/browser/aw_quota_permission_context.h" 17 #include "android_webview/browser/aw_quota_permission_context.h"
18 #include "android_webview/browser/aw_web_preferences_populater.h" 18 #include "android_webview/browser/aw_settings.h"
19 #include "android_webview/browser/jni_dependency_factory.h" 19 #include "android_webview/browser/jni_dependency_factory.h"
20 #include "android_webview/browser/net/aw_url_request_context_getter.h" 20 #include "android_webview/browser/net/aw_url_request_context_getter.h"
21 #include "android_webview/browser/net_disk_cache_remover.h" 21 #include "android_webview/browser/net_disk_cache_remover.h"
22 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" 22 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h"
23 #include "android_webview/browser/tracing/aw_tracing_delegate.h" 23 #include "android_webview/browser/tracing/aw_tracing_delegate.h"
24 #include "android_webview/common/aw_descriptors.h" 24 #include "android_webview/common/aw_descriptors.h"
25 #include "android_webview/common/aw_switches.h" 25 #include "android_webview/common/aw_switches.h"
26 #include "android_webview/common/crash_reporter/aw_microdump_crash_reporter.h" 26 #include "android_webview/common/crash_reporter/aw_microdump_crash_reporter.h"
27 #include "android_webview/common/render_view_messages.h" 27 #include "android_webview/common/render_view_messages.h"
28 #include "android_webview/common/url_constants.h" 28 #include "android_webview/common/url_constants.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 << url; 157 << url;
158 } 158 }
159 } 159 }
160 160
161 void AwContentsMessageFilter::OnSubFrameCreated(int parent_render_frame_id, 161 void AwContentsMessageFilter::OnSubFrameCreated(int parent_render_frame_id,
162 int child_render_frame_id) { 162 int child_render_frame_id) {
163 AwContentsIoThreadClient::SubFrameCreated( 163 AwContentsIoThreadClient::SubFrameCreated(
164 process_id_, parent_render_frame_id, child_render_frame_id); 164 process_id_, parent_render_frame_id, child_render_frame_id);
165 } 165 }
166 166
167 AwLocaleManager* g_locale_manager = NULL;
168
169 // A dummy binder for mojo interface autofill::mojom::PasswordManagerDriver. 167 // A dummy binder for mojo interface autofill::mojom::PasswordManagerDriver.
170 void DummyBindPasswordManagerDriver( 168 void DummyBindPasswordManagerDriver(
171 const service_manager::BindSourceInfo& source_info, 169 const service_manager::BindSourceInfo& source_info,
172 autofill::mojom::PasswordManagerDriverRequest request) {} 170 autofill::mojom::PasswordManagerDriverRequest request) {}
173 171
174 } // anonymous namespace 172 } // anonymous namespace
175 173
176 // TODO(yirui): can use similar logic as in PrependToAcceptLanguagesIfNecessary 174 // TODO(yirui): can use similar logic as in PrependToAcceptLanguagesIfNecessary
177 // in chrome/browser/android/preferences/pref_service_bridge.cc 175 // in chrome/browser/android/preferences/pref_service_bridge.cc
178 // static 176 // static
179 std::string AwContentBrowserClient::GetAcceptLangsImpl() { 177 std::string AwContentBrowserClient::GetAcceptLangsImpl() {
180 // Start with the current locale(s) in BCP47 format. 178 // Start with the current locale(s) in BCP47 format.
181 std::string locales_string = g_locale_manager->GetLocaleList(); 179 std::string locales_string = AwContents::GetLocaleList();
182 180
183 // If accept languages do not contain en-US, add in en-US which will be 181 // If accept languages do not contain en-US, add in en-US which will be
184 // used with a lower q-value. 182 // used with a lower q-value.
185 if (locales_string.find("en-US") == std::string::npos) 183 if (locales_string.find("en-US") == std::string::npos)
186 locales_string += ",en-US"; 184 locales_string += ",en-US";
187 return locales_string; 185 return locales_string;
188 } 186 }
189 187
190 // static 188 // static
191 AwBrowserContext* AwContentBrowserClient::GetAwBrowserContext() { 189 AwBrowserContext* AwContentBrowserClient::GetAwBrowserContext() {
192 return AwBrowserContext::GetDefault(); 190 return AwBrowserContext::GetDefault();
193 } 191 }
194 192
195 AwContentBrowserClient::AwContentBrowserClient( 193 AwContentBrowserClient::AwContentBrowserClient(
196 JniDependencyFactory* native_factory) 194 JniDependencyFactory* native_factory)
197 : native_factory_(native_factory) { 195 : native_factory_(native_factory) {
198 g_locale_manager = native_factory->CreateAwLocaleManager();
199 } 196 }
200 197
201 AwContentBrowserClient::~AwContentBrowserClient() { 198 AwContentBrowserClient::~AwContentBrowserClient() {}
202 delete g_locale_manager;
203 g_locale_manager = NULL;
204 }
205 199
206 AwBrowserContext* AwContentBrowserClient::InitBrowserContext() { 200 AwBrowserContext* AwContentBrowserClient::InitBrowserContext() {
207 base::FilePath user_data_dir; 201 base::FilePath user_data_dir;
208 if (!PathService::Get(base::DIR_ANDROID_APP_DATA, &user_data_dir)) { 202 if (!PathService::Get(base::DIR_ANDROID_APP_DATA, &user_data_dir)) {
209 NOTREACHED() << "Failed to get app data directory for Android WebView"; 203 NOTREACHED() << "Failed to get app data directory for Android WebView";
210 } 204 }
211 browser_context_.reset( 205 browser_context_.reset(
212 new AwBrowserContext(user_data_dir, native_factory_)); 206 new AwBrowserContext(user_data_dir, native_factory_));
213 return browser_context_.get(); 207 return browser_context_.get();
214 } 208 }
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 fd = ui::GetLocalePackFd(&region); 500 fd = ui::GetLocalePackFd(&region);
507 mappings->ShareWithRegion(kAndroidWebViewLocalePakDescriptor, fd, region); 501 mappings->ShareWithRegion(kAndroidWebViewLocalePakDescriptor, fd, region);
508 502
509 breakpad::CrashDumpObserver::GetInstance()->BrowserChildProcessStarted( 503 breakpad::CrashDumpObserver::GetInstance()->BrowserChildProcessStarted(
510 child_process_id, mappings); 504 child_process_id, mappings);
511 } 505 }
512 506
513 void AwContentBrowserClient::OverrideWebkitPrefs( 507 void AwContentBrowserClient::OverrideWebkitPrefs(
514 content::RenderViewHost* rvh, 508 content::RenderViewHost* rvh,
515 content::WebPreferences* web_prefs) { 509 content::WebPreferences* web_prefs) {
516 if (!preferences_populater_.get()) { 510 AwSettings* aw_settings = AwSettings::FromWebContents(
517 preferences_populater_ = 511 content::WebContents::FromRenderViewHost(rvh));
518 base::WrapUnique(native_factory_->CreateWebPreferencesPopulater()); 512 if (aw_settings) {
513 aw_settings->PopulateWebPreferences(web_prefs);
519 } 514 }
520 preferences_populater_->PopulateFor(
521 content::WebContents::FromRenderViewHost(rvh), web_prefs);
522 } 515 }
523 516
524 std::vector<std::unique_ptr<content::NavigationThrottle>> 517 std::vector<std::unique_ptr<content::NavigationThrottle>>
525 AwContentBrowserClient::CreateThrottlesForNavigation( 518 AwContentBrowserClient::CreateThrottlesForNavigation(
526 content::NavigationHandle* navigation_handle) { 519 content::NavigationHandle* navigation_handle) {
527 std::vector<std::unique_ptr<content::NavigationThrottle>> throttles; 520 std::vector<std::unique_ptr<content::NavigationThrottle>> throttles;
528 // We allow intercepting only navigations within main frames. This 521 // We allow intercepting only navigations within main frames. This
529 // is used to post onPageStarted. We handle shouldOverrideUrlLoading 522 // is used to post onPageStarted. We handle shouldOverrideUrlLoading
530 // via a sync IPC. 523 // via a sync IPC.
531 if (navigation_handle->IsInMainFrame()) { 524 if (navigation_handle->IsInMainFrame()) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 render_frame_host)); 558 render_frame_host));
566 559
567 // Although WebView does not support password manager feature, renderer code 560 // Although WebView does not support password manager feature, renderer code
568 // could still request this interface, so we register a dummy binder which 561 // could still request this interface, so we register a dummy binder which
569 // just drops the incoming request, to avoid the 'Failed to locate a binder 562 // just drops the incoming request, to avoid the 'Failed to locate a binder
570 // for interface' error log.. 563 // for interface' error log..
571 registry->AddInterface(base::Bind(&DummyBindPasswordManagerDriver)); 564 registry->AddInterface(base::Bind(&DummyBindPasswordManagerDriver));
572 } 565 }
573 566
574 } // namespace android_webview 567 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/aw_content_browser_client.h ('k') | android_webview/browser/aw_http_auth_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698