OLD | NEW |
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_main_parts.h" | 8 #include "android_webview/browser/aw_browser_main_parts.h" |
8 #include "android_webview/browser/aw_cookie_access_policy.h" | 9 #include "android_webview/browser/aw_cookie_access_policy.h" |
9 #include "android_webview/browser/aw_quota_permission_context.h" | 10 #include "android_webview/browser/aw_quota_permission_context.h" |
| 11 #include "android_webview/browser/native_factory.h" |
10 #include "android_webview/browser/net_disk_cache_remover.h" | 12 #include "android_webview/browser/net_disk_cache_remover.h" |
11 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele
gate.h" | 13 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele
gate.h" |
12 #include "android_webview/common/url_constants.h" | 14 #include "android_webview/common/url_constants.h" |
13 #include "base/android/locale_utils.h" | 15 #include "base/android/locale_utils.h" |
14 #include "base/base_paths_android.h" | 16 #include "base/base_paths_android.h" |
15 #include "base/path_service.h" | 17 #include "base/path_service.h" |
16 #include "content/public/browser/access_token_store.h" | 18 #include "content/public/browser/access_token_store.h" |
17 #include "content/public/browser/child_process_security_policy.h" | 19 #include "content/public/browser/child_process_security_policy.h" |
18 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
19 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
(...skipping 22 matching lines...) Expand all Loading... |
42 private: | 44 private: |
43 virtual ~AwAccessTokenStore() { } | 45 virtual ~AwAccessTokenStore() { } |
44 | 46 |
45 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); | 47 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); |
46 }; | 48 }; |
47 | 49 |
48 } | 50 } |
49 | 51 |
50 namespace android_webview { | 52 namespace android_webview { |
51 | 53 |
52 AwContentBrowserClient::AwContentBrowserClient( | 54 // static |
53 ViewDelegateFactoryFn* view_delegate_factory, | 55 AwContentBrowserClient* AwContentBrowserClient::FromContentBrowserClient( |
54 GeolocationPermissionFactoryFn* geolocation_permission_factory) | 56 content::ContentBrowserClient* client) { |
55 : view_delegate_factory_(view_delegate_factory) { | 57 return static_cast<AwContentBrowserClient*>(client); |
| 58 } |
| 59 |
| 60 AwContentBrowserClient::AwContentBrowserClient(NativeFactory* native_factory) |
| 61 : native_factory_(native_factory) { |
56 base::FilePath user_data_dir; | 62 base::FilePath user_data_dir; |
57 if (!PathService::Get(base::DIR_ANDROID_APP_DATA, &user_data_dir)) { | 63 if (!PathService::Get(base::DIR_ANDROID_APP_DATA, &user_data_dir)) { |
58 NOTREACHED() << "Failed to get app data directory for Android WebView"; | 64 NOTREACHED() << "Failed to get app data directory for Android WebView"; |
59 } | 65 } |
60 browser_context_.reset( | 66 browser_context_.reset( |
61 new AwBrowserContext(user_data_dir, geolocation_permission_factory)); | 67 new AwBrowserContext(user_data_dir, native_factory_)); |
62 } | 68 } |
63 | 69 |
64 AwContentBrowserClient::~AwContentBrowserClient() { | 70 AwContentBrowserClient::~AwContentBrowserClient() { |
65 } | 71 } |
66 | 72 |
67 void AwContentBrowserClient::AddCertificate(net::URLRequest* request, | 73 void AwContentBrowserClient::AddCertificate(net::URLRequest* request, |
68 net::CertificateMimeType cert_type, | 74 net::CertificateMimeType cert_type, |
69 const void* cert_data, | 75 const void* cert_data, |
70 size_t cert_size, | 76 size_t cert_size, |
71 int render_process_id, | 77 int render_process_id, |
72 int render_view_id) { | 78 int render_view_id) { |
73 if (cert_size > 0) | 79 if (cert_size > 0) |
74 net::android::StoreCertificate(cert_type, cert_data, cert_size); | 80 net::android::StoreCertificate(cert_type, cert_data, cert_size); |
75 } | 81 } |
76 | 82 |
77 AwBrowserContext* AwContentBrowserClient::GetAwBrowserContext() { | 83 AwBrowserContext* AwContentBrowserClient::GetAwBrowserContext() { |
78 return browser_context_.get(); | 84 return browser_context_.get(); |
79 } | 85 } |
80 | 86 |
81 content::BrowserMainParts* AwContentBrowserClient::CreateBrowserMainParts( | 87 content::BrowserMainParts* AwContentBrowserClient::CreateBrowserMainParts( |
82 const content::MainFunctionParams& parameters) { | 88 const content::MainFunctionParams& parameters) { |
83 return new AwBrowserMainParts(browser_context_.get()); | 89 return new AwBrowserMainParts(browser_context_.get()); |
84 } | 90 } |
85 | 91 |
86 content::WebContentsViewDelegate* | 92 content::WebContentsViewDelegate* |
87 AwContentBrowserClient::GetWebContentsViewDelegate( | 93 AwContentBrowserClient::GetWebContentsViewDelegate( |
88 content::WebContents* web_contents) { | 94 content::WebContents* web_contents) { |
89 return (*view_delegate_factory_)(web_contents); | 95 return native_factory_->CreateViewDelegate(web_contents); |
90 } | 96 } |
91 | 97 |
92 void AwContentBrowserClient::RenderProcessHostCreated( | 98 void AwContentBrowserClient::RenderProcessHostCreated( |
93 content::RenderProcessHost* host) { | 99 content::RenderProcessHost* host) { |
94 // If WebView becomes multi-process capable, this may be insecure. | 100 // If WebView becomes multi-process capable, this may be insecure. |
95 // More benefit can be derived from the ChildProcessSecurotyPolicy by | 101 // More benefit can be derived from the ChildProcessSecurotyPolicy by |
96 // deferring the GrantScheme calls until we know that a given child process | 102 // deferring the GrantScheme calls until we know that a given child process |
97 // really does need that priviledge. Check here to ensure we rethink this | 103 // really does need that priviledge. Check here to ensure we rethink this |
98 // when the time comes. See crbug.com/156062. | 104 // when the time comes. See crbug.com/156062. |
99 CHECK(content::RenderProcessHost::run_renderer_in_process()); | 105 CHECK(content::RenderProcessHost::run_renderer_in_process()); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 | 391 |
386 bool AwContentBrowserClient::AllowPepperSocketAPI( | 392 bool AwContentBrowserClient::AllowPepperSocketAPI( |
387 content::BrowserContext* browser_context, | 393 content::BrowserContext* browser_context, |
388 const GURL& url, | 394 const GURL& url, |
389 const content::SocketPermissionRequest& params) { | 395 const content::SocketPermissionRequest& params) { |
390 NOTREACHED() << "Android WebView does not support plugins"; | 396 NOTREACHED() << "Android WebView does not support plugins"; |
391 return false; | 397 return false; |
392 } | 398 } |
393 | 399 |
394 } // namespace android_webview | 400 } // namespace android_webview |
OLD | NEW |