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

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

Issue 1155713005: Use a resource throttle to implement shouldOverrideUrlLoading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix qinmin nit 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
« no previous file with comments | « no previous file | android_webview/browser/aw_contents_client_bridge_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_printing_message_filter.h" 12 #include "android_webview/browser/aw_printing_message_filter.h"
13 #include "android_webview/browser/aw_quota_permission_context.h" 13 #include "android_webview/browser/aw_quota_permission_context.h"
14 #include "android_webview/browser/aw_web_preferences_populater.h" 14 #include "android_webview/browser/aw_web_preferences_populater.h"
15 #include "android_webview/browser/jni_dependency_factory.h" 15 #include "android_webview/browser/jni_dependency_factory.h"
16 #include "android_webview/browser/net/aw_url_request_context_getter.h" 16 #include "android_webview/browser/net/aw_url_request_context_getter.h"
17 #include "android_webview/browser/net_disk_cache_remover.h" 17 #include "android_webview/browser/net_disk_cache_remover.h"
18 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" 18 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h"
19 #include "android_webview/common/render_view_messages.h" 19 #include "android_webview/common/render_view_messages.h"
20 #include "android_webview/common/url_constants.h" 20 #include "android_webview/common/url_constants.h"
21 #include "base/android/locale_utils.h" 21 #include "base/android/locale_utils.h"
22 #include "base/base_paths_android.h" 22 #include "base/base_paths_android.h"
23 #include "base/path_service.h" 23 #include "base/path_service.h"
24 #include "components/cdm/browser/cdm_message_filter_android.h" 24 #include "components/cdm/browser/cdm_message_filter_android.h"
25 #include "content/public/browser/access_token_store.h" 25 #include "content/public/browser/access_token_store.h"
26 #include "content/public/browser/browser_message_filter.h" 26 #include "content/public/browser/browser_message_filter.h"
27 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/child_process_security_policy.h" 27 #include "content/public/browser/child_process_security_policy.h"
29 #include "content/public/browser/client_certificate_delegate.h" 28 #include "content/public/browser/client_certificate_delegate.h"
30 #include "content/public/browser/render_frame_host.h" 29 #include "content/public/browser/render_frame_host.h"
31 #include "content/public/browser/render_process_host.h" 30 #include "content/public/browser/render_process_host.h"
32 #include "content/public/browser/render_view_host.h" 31 #include "content/public/browser/render_view_host.h"
33 #include "content/public/browser/web_contents.h" 32 #include "content/public/browser/web_contents.h"
34 #include "content/public/common/url_constants.h" 33 #include "content/public/common/url_constants.h"
35 #include "content/public/common/web_preferences.h" 34 #include "content/public/common/web_preferences.h"
36 #include "net/android/network_library.h" 35 #include "net/android/network_library.h"
37 #include "net/ssl/ssl_cert_request_info.h" 36 #include "net/ssl/ssl_cert_request_info.h"
38 #include "net/ssl/ssl_info.h" 37 #include "net/ssl/ssl_info.h"
39 #include "ui/base/resource/resource_bundle.h" 38 #include "ui/base/resource/resource_bundle.h"
40 #include "ui/resources/grit/ui_resources.h" 39 #include "ui/resources/grit/ui_resources.h"
41 40
42 using content::BrowserThread;
43 using content::ResourceType; 41 using content::ResourceType;
44 42
45 namespace android_webview { 43 namespace android_webview {
46 namespace { 44 namespace {
47 45
48 // TODO(sgurun) move this to its own file. 46 // TODO(sgurun) move this to its own file.
49 // This class filters out incoming aw_contents related IPC messages for the 47 // This class filters out incoming aw_contents related IPC messages for the
50 // renderer process on the IPC thread. 48 // renderer process on the IPC thread.
51 class AwContentsMessageFilter : public content::BrowserMessageFilter { 49 class AwContentsMessageFilter : public content::BrowserMessageFilter {
52 public: 50 public:
53 explicit AwContentsMessageFilter(int process_id); 51 explicit AwContentsMessageFilter(int process_id);
54 52
55 // BrowserMessageFilter methods. 53 // BrowserMessageFilter methods.
56 void OverrideThreadForMessage(const IPC::Message& message,
57 BrowserThread::ID* thread) override;
58 bool OnMessageReceived(const IPC::Message& message) override; 54 bool OnMessageReceived(const IPC::Message& message) override;
59 55
60 void OnShouldOverrideUrlLoading(int routing_id,
61 const base::string16& url,
62 bool has_user_gesture,
63 bool is_redirect,
64 bool* ignore_navigation);
65 void OnSubFrameCreated(int parent_render_frame_id, int child_render_frame_id); 56 void OnSubFrameCreated(int parent_render_frame_id, int child_render_frame_id);
66 57
67 private: 58 private:
68 ~AwContentsMessageFilter() override; 59 ~AwContentsMessageFilter() override;
69 60
70 int process_id_; 61 int process_id_;
71 62
72 DISALLOW_COPY_AND_ASSIGN(AwContentsMessageFilter); 63 DISALLOW_COPY_AND_ASSIGN(AwContentsMessageFilter);
73 }; 64 };
74 65
75 AwContentsMessageFilter::AwContentsMessageFilter(int process_id) 66 AwContentsMessageFilter::AwContentsMessageFilter(int process_id)
76 : BrowserMessageFilter(AndroidWebViewMsgStart), 67 : BrowserMessageFilter(AndroidWebViewMsgStart),
77 process_id_(process_id) { 68 process_id_(process_id) {
78 } 69 }
79 70
80 AwContentsMessageFilter::~AwContentsMessageFilter() { 71 AwContentsMessageFilter::~AwContentsMessageFilter() {
81 } 72 }
82 73
83 void AwContentsMessageFilter::OverrideThreadForMessage(
84 const IPC::Message& message, BrowserThread::ID* thread) {
85 if (message.type() == AwViewHostMsg_ShouldOverrideUrlLoading::ID) {
86 *thread = BrowserThread::UI;
87 }
88 }
89
90 bool AwContentsMessageFilter::OnMessageReceived(const IPC::Message& message) { 74 bool AwContentsMessageFilter::OnMessageReceived(const IPC::Message& message) {
91 bool handled = true; 75 bool handled = true;
92 IPC_BEGIN_MESSAGE_MAP(AwContentsMessageFilter, message) 76 IPC_BEGIN_MESSAGE_MAP(AwContentsMessageFilter, message)
93 IPC_MESSAGE_HANDLER(AwViewHostMsg_ShouldOverrideUrlLoading,
94 OnShouldOverrideUrlLoading)
95 IPC_MESSAGE_HANDLER(AwViewHostMsg_SubFrameCreated, OnSubFrameCreated) 77 IPC_MESSAGE_HANDLER(AwViewHostMsg_SubFrameCreated, OnSubFrameCreated)
96 IPC_MESSAGE_UNHANDLED(handled = false) 78 IPC_MESSAGE_UNHANDLED(handled = false)
97 IPC_END_MESSAGE_MAP() 79 IPC_END_MESSAGE_MAP()
98 return handled; 80 return handled;
99 } 81 }
100 82
101 void AwContentsMessageFilter::OnShouldOverrideUrlLoading(
102 int render_frame_id,
103 const base::string16& url,
104 bool has_user_gesture,
105 bool is_redirect,
106 bool* ignore_navigation) {
107 DCHECK_CURRENTLY_ON(BrowserThread::UI);
108 *ignore_navigation = false;
109 AwContentsClientBridgeBase* client =
110 AwContentsClientBridgeBase::FromID(process_id_, render_frame_id);
111 if (client) {
112 *ignore_navigation =
113 client->ShouldOverrideUrlLoading(url, has_user_gesture, is_redirect);
114 } else {
115 LOG(WARNING) << "Failed to find the associated render view host for url: "
116 << url;
117 }
118 }
119
120 void AwContentsMessageFilter::OnSubFrameCreated(int parent_render_frame_id, 83 void AwContentsMessageFilter::OnSubFrameCreated(int parent_render_frame_id,
121 int child_render_frame_id) { 84 int child_render_frame_id) {
122 AwContentsIoThreadClient::SubFrameCreated( 85 AwContentsIoThreadClient::SubFrameCreated(
123 process_id_, parent_render_frame_id, child_render_frame_id); 86 process_id_, parent_render_frame_id, child_render_frame_id);
124 } 87 }
125 88
126 class AwAccessTokenStore : public content::AccessTokenStore { 89 class AwAccessTokenStore : public content::AccessTokenStore {
127 public: 90 public:
128 AwAccessTokenStore() { } 91 AwAccessTokenStore() { }
129 92
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 435
473 #if defined(VIDEO_HOLE) 436 #if defined(VIDEO_HOLE)
474 content::ExternalVideoSurfaceContainer* 437 content::ExternalVideoSurfaceContainer*
475 AwContentBrowserClient::OverrideCreateExternalVideoSurfaceContainer( 438 AwContentBrowserClient::OverrideCreateExternalVideoSurfaceContainer(
476 content::WebContents* web_contents) { 439 content::WebContents* web_contents) {
477 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents); 440 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents);
478 } 441 }
479 #endif 442 #endif
480 443
481 } // namespace android_webview 444 } // namespace android_webview
OLDNEW
« no previous file with comments | « no previous file | android_webview/browser/aw_contents_client_bridge_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698