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

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

Issue 13409003: Hide ContentClient getters from embedders so that they they don't reuse content's embedder API. The… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 7 years, 8 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 | Annotate | Revision Log
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_cookie_access_policy.h" 10 #include "android_webview/browser/aw_cookie_access_policy.h"
11 #include "android_webview/browser/aw_quota_permission_context.h" 11 #include "android_webview/browser/aw_quota_permission_context.h"
12 #include "android_webview/browser/jni_dependency_factory.h" 12 #include "android_webview/browser/jni_dependency_factory.h"
13 #include "android_webview/browser/net_disk_cache_remover.h" 13 #include "android_webview/browser/net_disk_cache_remover.h"
14 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" 14 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h"
15 #include "android_webview/common/url_constants.h" 15 #include "android_webview/common/url_constants.h"
16 #include "base/android/locale_utils.h" 16 #include "base/android/locale_utils.h"
17 #include "base/base_paths_android.h" 17 #include "base/base_paths_android.h"
18 #include "base/path_service.h" 18 #include "base/path_service.h"
19 #include "content/public/browser/access_token_store.h" 19 #include "content/public/browser/access_token_store.h"
20 #include "content/public/browser/child_process_security_policy.h" 20 #include "content/public/browser/child_process_security_policy.h"
21 #include "content/public/browser/render_process_host.h" 21 #include "content/public/browser/render_process_host.h"
22 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
23 #include "content/public/common/url_constants.h" 23 #include "content/public/common/url_constants.h"
24 #include "grit/ui_resources.h" 24 #include "grit/ui_resources.h"
25 #include "net/android/network_library.h" 25 #include "net/android/network_library.h"
26 #include "net/ssl/ssl_info.h" 26 #include "net/ssl/ssl_info.h"
27 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
28 28
29 namespace android_webview {
29 namespace { 30 namespace {
30 31
32 AwBrowserContext* g_browser_context;
33
31 class AwAccessTokenStore : public content::AccessTokenStore { 34 class AwAccessTokenStore : public content::AccessTokenStore {
32 public: 35 public:
33 AwAccessTokenStore() { } 36 AwAccessTokenStore() { }
34 37
35 // content::AccessTokenStore implementation 38 // content::AccessTokenStore implementation
36 virtual void LoadAccessTokens( 39 virtual void LoadAccessTokens(
37 const LoadAccessTokensCallbackType& request) OVERRIDE { 40 const LoadAccessTokensCallbackType& request) OVERRIDE {
38 AccessTokenStore::AccessTokenSet access_token_set; 41 AccessTokenStore::AccessTokenSet access_token_set;
39 // AccessTokenSet and net::URLRequestContextGetter not used on Android, 42 // AccessTokenSet and net::URLRequestContextGetter not used on Android,
40 // but Run needs to be called to finish the geolocation setup. 43 // but Run needs to be called to finish the geolocation setup.
41 request.Run(access_token_set, NULL); 44 request.Run(access_token_set, NULL);
42 } 45 }
43 virtual void SaveAccessToken(const GURL& server_url, 46 virtual void SaveAccessToken(const GURL& server_url,
44 const string16& access_token) OVERRIDE { } 47 const string16& access_token) OVERRIDE { }
45 48
46 private: 49 private:
47 virtual ~AwAccessTokenStore() { } 50 virtual ~AwAccessTokenStore() { }
48 51
49 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); 52 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore);
50 }; 53 };
51 54
52 } 55 }
53 56
54 namespace android_webview { 57 std::string AwContentBrowserClient::GetAcceptLangsImpl() {
58 // Start with the currnet locale.
59 std::string langs = base::android::GetDefaultLocale();
55 60
56 // static 61 // If we're not en-US, add in en-US which will be
57 AwContentBrowserClient* AwContentBrowserClient::FromContentBrowserClient( 62 // used with a lower q-value.
58 content::ContentBrowserClient* client) { 63 if (StringToLowerASCII(langs) != "en-us") {
59 return static_cast<AwContentBrowserClient*>(client); 64 langs += ",en-US";
65 }
66 return langs;
67 }
68
69 AwBrowserContext* AwContentBrowserClient::GetAwBrowserContext() {
70 return g_browser_context;
60 } 71 }
61 72
62 AwContentBrowserClient::AwContentBrowserClient( 73 AwContentBrowserClient::AwContentBrowserClient(
63 JniDependencyFactory* native_factory) 74 JniDependencyFactory* native_factory)
64 : native_factory_(native_factory) { 75 : native_factory_(native_factory) {
65 base::FilePath user_data_dir; 76 base::FilePath user_data_dir;
66 if (!PathService::Get(base::DIR_ANDROID_APP_DATA, &user_data_dir)) { 77 if (!PathService::Get(base::DIR_ANDROID_APP_DATA, &user_data_dir)) {
67 NOTREACHED() << "Failed to get app data directory for Android WebView"; 78 NOTREACHED() << "Failed to get app data directory for Android WebView";
68 } 79 }
69 browser_context_.reset( 80 browser_context_.reset(
70 new AwBrowserContext(user_data_dir, native_factory_)); 81 new AwBrowserContext(user_data_dir, native_factory_));
82 g_browser_context = browser_context_.get();
71 } 83 }
72 84
73 AwContentBrowserClient::~AwContentBrowserClient() { 85 AwContentBrowserClient::~AwContentBrowserClient() {
86 g_browser_context = NULL;
74 } 87 }
75 88
76 void AwContentBrowserClient::AddCertificate(net::URLRequest* request, 89 void AwContentBrowserClient::AddCertificate(net::URLRequest* request,
77 net::CertificateMimeType cert_type, 90 net::CertificateMimeType cert_type,
78 const void* cert_data, 91 const void* cert_data,
79 size_t cert_size, 92 size_t cert_size,
80 int render_process_id, 93 int render_process_id,
81 int render_view_id) { 94 int render_view_id) {
82 if (cert_size > 0) 95 if (cert_size > 0)
83 net::android::StoreCertificate(cert_type, cert_data, cert_size); 96 net::android::StoreCertificate(cert_type, cert_data, cert_size);
84 } 97 }
85 98
86 AwBrowserContext* AwContentBrowserClient::GetAwBrowserContext() {
87 return browser_context_.get();
88 }
89
90 content::BrowserMainParts* AwContentBrowserClient::CreateBrowserMainParts( 99 content::BrowserMainParts* AwContentBrowserClient::CreateBrowserMainParts(
91 const content::MainFunctionParams& parameters) { 100 const content::MainFunctionParams& parameters) {
92 return new AwBrowserMainParts(browser_context_.get()); 101 return new AwBrowserMainParts(browser_context_.get());
93 } 102 }
94 103
95 content::WebContentsViewDelegate* 104 content::WebContentsViewDelegate*
96 AwContentBrowserClient::GetWebContentsViewDelegate( 105 AwContentBrowserClient::GetWebContentsViewDelegate(
97 content::WebContents* web_contents) { 106 content::WebContents* web_contents) {
98 return native_factory_->CreateViewDelegate(web_contents); 107 return native_factory_->CreateViewDelegate(web_contents);
99 } 108 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 int child_process_id) { 153 int child_process_id) {
145 NOTREACHED() << "Android WebView does not support multi-process yet"; 154 NOTREACHED() << "Android WebView does not support multi-process yet";
146 } 155 }
147 156
148 std::string AwContentBrowserClient::GetApplicationLocale() { 157 std::string AwContentBrowserClient::GetApplicationLocale() {
149 return base::android::GetDefaultLocale(); 158 return base::android::GetDefaultLocale();
150 } 159 }
151 160
152 std::string AwContentBrowserClient::GetAcceptLangs( 161 std::string AwContentBrowserClient::GetAcceptLangs(
153 content::BrowserContext* context) { 162 content::BrowserContext* context) {
154 // Start with the currnet locale. 163 return GetAcceptLangsImpl();
155 std::string langs = GetApplicationLocale();
156
157 // If we're not en-US, add in en-US which will be
158 // used with a lower q-value.
159 if (StringToLowerASCII(langs) != "en-us") {
160 langs += ",en-US";
161 }
162 return langs;
163 } 164 }
164 165
165 gfx::ImageSkia* AwContentBrowserClient::GetDefaultFavicon() { 166 gfx::ImageSkia* AwContentBrowserClient::GetDefaultFavicon() {
166 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 167 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
167 // TODO(boliu): Bundle our own default favicon? 168 // TODO(boliu): Bundle our own default favicon?
168 return rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON); 169 return rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON);
169 } 170 }
170 171
171 bool AwContentBrowserClient::AllowAppCache(const GURL& manifest_url, 172 bool AwContentBrowserClient::AllowAppCache(const GURL& manifest_url,
172 const GURL& first_party, 173 const GURL& first_party,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 } 334 }
334 335
335 void AwContentBrowserClient::UpdateInspectorSetting( 336 void AwContentBrowserClient::UpdateInspectorSetting(
336 content::RenderViewHost* rvh, 337 content::RenderViewHost* rvh,
337 const std::string& key, 338 const std::string& key,
338 const std::string& value) { 339 const std::string& value) {
339 // TODO(boliu): Implement persisting inspector settings. 340 // TODO(boliu): Implement persisting inspector settings.
340 NOTIMPLEMENTED(); 341 NOTIMPLEMENTED();
341 } 342 }
342 343
343 void AwContentBrowserClient::ClearInspectorSettings(
344 content::RenderViewHost* rvh) {
345 // TODO(boliu): Implement persisting inspector settings.
346 NOTIMPLEMENTED();
347 }
348
349 void AwContentBrowserClient::ClearCache(content::RenderViewHost* rvh) { 344 void AwContentBrowserClient::ClearCache(content::RenderViewHost* rvh) {
350 RemoveHttpDiskCache(rvh->GetProcess()->GetBrowserContext(), 345 RemoveHttpDiskCache(rvh->GetProcess()->GetBrowserContext(),
351 rvh->GetProcess()->GetID()); 346 rvh->GetProcess()->GetID());
352 } 347 }
353 348
354 void AwContentBrowserClient::ClearCookies(content::RenderViewHost* rvh) { 349 void AwContentBrowserClient::ClearCookies(content::RenderViewHost* rvh) {
355 // TODO(boliu): Implement. 350 // TODO(boliu): Implement.
356 NOTIMPLEMENTED(); 351 NOTIMPLEMENTED();
357 } 352 }
358 353
(...skipping 18 matching lines...) Expand all
377 372
378 bool AwContentBrowserClient::AllowPepperSocketAPI( 373 bool AwContentBrowserClient::AllowPepperSocketAPI(
379 content::BrowserContext* browser_context, 374 content::BrowserContext* browser_context,
380 const GURL& url, 375 const GURL& url,
381 const content::SocketPermissionRequest& params) { 376 const content::SocketPermissionRequest& params) {
382 NOTREACHED() << "Android WebView does not support plugins"; 377 NOTREACHED() << "Android WebView does not support plugins";
383 return false; 378 return false;
384 } 379 }
385 380
386 } // namespace android_webview 381 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/aw_content_browser_client.h ('k') | android_webview/browser/net/aw_url_request_context_getter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698