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

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

Issue 1530183004: Revert 3 CLs for shouldOverrideUrlLoading implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase (simple conflict in AwContentsClientShouldOverrideUrlLoadingTest). Created 4 years, 11 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 <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 15 matching lines...) Expand all
26 #include "base/android/locale_utils.h" 26 #include "base/android/locale_utils.h"
27 #include "base/base_paths_android.h" 27 #include "base/base_paths_android.h"
28 #include "base/command_line.h" 28 #include "base/command_line.h"
29 #include "base/files/scoped_file.h" 29 #include "base/files/scoped_file.h"
30 #include "base/path_service.h" 30 #include "base/path_service.h"
31 #include "components/cdm/browser/cdm_message_filter_android.h" 31 #include "components/cdm/browser/cdm_message_filter_android.h"
32 #include "components/crash/content/browser/crash_micro_dump_manager_android.h" 32 #include "components/crash/content/browser/crash_micro_dump_manager_android.h"
33 #include "components/navigation_interception/intercept_navigation_delegate.h" 33 #include "components/navigation_interception/intercept_navigation_delegate.h"
34 #include "content/public/browser/access_token_store.h" 34 #include "content/public/browser/access_token_store.h"
35 #include "content/public/browser/browser_message_filter.h" 35 #include "content/public/browser/browser_message_filter.h"
36 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/child_process_security_policy.h" 37 #include "content/public/browser/child_process_security_policy.h"
37 #include "content/public/browser/client_certificate_delegate.h" 38 #include "content/public/browser/client_certificate_delegate.h"
38 #include "content/public/browser/navigation_handle.h" 39 #include "content/public/browser/navigation_handle.h"
39 #include "content/public/browser/navigation_throttle.h" 40 #include "content/public/browser/navigation_throttle.h"
40 #include "content/public/browser/render_frame_host.h" 41 #include "content/public/browser/render_frame_host.h"
41 #include "content/public/browser/render_process_host.h" 42 #include "content/public/browser/render_process_host.h"
42 #include "content/public/browser/render_view_host.h" 43 #include "content/public/browser/render_view_host.h"
43 #include "content/public/browser/web_contents.h" 44 #include "content/public/browser/web_contents.h"
44 #include "content/public/common/content_switches.h" 45 #include "content/public/common/content_switches.h"
45 #include "content/public/common/url_constants.h" 46 #include "content/public/common/url_constants.h"
46 #include "content/public/common/web_preferences.h" 47 #include "content/public/common/web_preferences.h"
47 #include "net/android/network_library.h" 48 #include "net/android/network_library.h"
48 #include "net/ssl/ssl_cert_request_info.h" 49 #include "net/ssl/ssl_cert_request_info.h"
49 #include "net/ssl/ssl_info.h" 50 #include "net/ssl/ssl_info.h"
50 #include "ui/base/resource/resource_bundle.h" 51 #include "ui/base/resource/resource_bundle.h"
51 #include "ui/base/resource/resource_bundle_android.h" 52 #include "ui/base/resource/resource_bundle_android.h"
52 #include "ui/resources/grit/ui_resources.h" 53 #include "ui/resources/grit/ui_resources.h"
53 54
55 using content::BrowserThread;
54 using content::ResourceType; 56 using content::ResourceType;
55 57
56 namespace android_webview { 58 namespace android_webview {
57 namespace { 59 namespace {
58 60
59 // TODO(sgurun) move this to its own file. 61 // TODO(sgurun) move this to its own file.
60 // This class filters out incoming aw_contents related IPC messages for the 62 // This class filters out incoming aw_contents related IPC messages for the
61 // renderer process on the IPC thread. 63 // renderer process on the IPC thread.
62 class AwContentsMessageFilter : public content::BrowserMessageFilter { 64 class AwContentsMessageFilter : public content::BrowserMessageFilter {
63 public: 65 public:
64 explicit AwContentsMessageFilter(int process_id); 66 explicit AwContentsMessageFilter(int process_id);
65 67
66 // BrowserMessageFilter methods. 68 // BrowserMessageFilter methods.
69 void OverrideThreadForMessage(const IPC::Message& message,
70 BrowserThread::ID* thread) override;
67 bool OnMessageReceived(const IPC::Message& message) override; 71 bool OnMessageReceived(const IPC::Message& message) override;
68 72
73 void OnShouldOverrideUrlLoading(int routing_id,
74 const base::string16& url,
75 bool has_user_gesture,
76 bool is_redirect,
77 bool is_main_frame,
78 bool* ignore_navigation);
69 void OnSubFrameCreated(int parent_render_frame_id, int child_render_frame_id); 79 void OnSubFrameCreated(int parent_render_frame_id, int child_render_frame_id);
70 80
71 private: 81 private:
72 ~AwContentsMessageFilter() override; 82 ~AwContentsMessageFilter() override;
73 83
74 int process_id_; 84 int process_id_;
75 85
76 DISALLOW_COPY_AND_ASSIGN(AwContentsMessageFilter); 86 DISALLOW_COPY_AND_ASSIGN(AwContentsMessageFilter);
77 }; 87 };
78 88
79 AwContentsMessageFilter::AwContentsMessageFilter(int process_id) 89 AwContentsMessageFilter::AwContentsMessageFilter(int process_id)
80 : BrowserMessageFilter(AndroidWebViewMsgStart), 90 : BrowserMessageFilter(AndroidWebViewMsgStart),
81 process_id_(process_id) { 91 process_id_(process_id) {
82 } 92 }
83 93
84 AwContentsMessageFilter::~AwContentsMessageFilter() { 94 AwContentsMessageFilter::~AwContentsMessageFilter() {
85 } 95 }
86 96
97 void AwContentsMessageFilter::OverrideThreadForMessage(
98 const IPC::Message& message,
99 BrowserThread::ID* thread) {
100 if (message.type() == AwViewHostMsg_ShouldOverrideUrlLoading::ID) {
101 *thread = BrowserThread::UI;
102 }
103 }
104
87 bool AwContentsMessageFilter::OnMessageReceived(const IPC::Message& message) { 105 bool AwContentsMessageFilter::OnMessageReceived(const IPC::Message& message) {
88 bool handled = true; 106 bool handled = true;
89 IPC_BEGIN_MESSAGE_MAP(AwContentsMessageFilter, message) 107 IPC_BEGIN_MESSAGE_MAP(AwContentsMessageFilter, message)
108 IPC_MESSAGE_HANDLER(AwViewHostMsg_ShouldOverrideUrlLoading,
109 OnShouldOverrideUrlLoading)
90 IPC_MESSAGE_HANDLER(AwViewHostMsg_SubFrameCreated, OnSubFrameCreated) 110 IPC_MESSAGE_HANDLER(AwViewHostMsg_SubFrameCreated, OnSubFrameCreated)
91 IPC_MESSAGE_UNHANDLED(handled = false) 111 IPC_MESSAGE_UNHANDLED(handled = false)
92 IPC_END_MESSAGE_MAP() 112 IPC_END_MESSAGE_MAP()
93 return handled; 113 return handled;
94 } 114 }
95 115
116 void AwContentsMessageFilter::OnShouldOverrideUrlLoading(
117 int render_frame_id,
118 const base::string16& url,
119 bool has_user_gesture,
120 bool is_redirect,
121 bool is_main_frame,
122 bool* ignore_navigation) {
123 DCHECK_CURRENTLY_ON(BrowserThread::UI);
124 *ignore_navigation = false;
125 AwContentsClientBridgeBase* client =
126 AwContentsClientBridgeBase::FromID(process_id_, render_frame_id);
127 if (client) {
128 *ignore_navigation = client->ShouldOverrideUrlLoading(
129 url, has_user_gesture, is_redirect, is_main_frame);
130 } else {
131 LOG(WARNING) << "Failed to find the associated render view host for url: "
132 << url;
133 }
134 }
135
96 void AwContentsMessageFilter::OnSubFrameCreated(int parent_render_frame_id, 136 void AwContentsMessageFilter::OnSubFrameCreated(int parent_render_frame_id,
97 int child_render_frame_id) { 137 int child_render_frame_id) {
98 AwContentsIoThreadClient::SubFrameCreated( 138 AwContentsIoThreadClient::SubFrameCreated(
99 process_id_, parent_render_frame_id, child_render_frame_id); 139 process_id_, parent_render_frame_id, child_render_frame_id);
100 } 140 }
101 141
102 class AwAccessTokenStore : public content::AccessTokenStore { 142 class AwAccessTokenStore : public content::AccessTokenStore {
103 public: 143 public:
104 AwAccessTokenStore() { } 144 AwAccessTokenStore() { }
105 145
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 CreateWebPreferencesPopulater()); 553 CreateWebPreferencesPopulater());
514 } 554 }
515 preferences_populater_->PopulateFor( 555 preferences_populater_->PopulateFor(
516 content::WebContents::FromRenderViewHost(rvh), web_prefs); 556 content::WebContents::FromRenderViewHost(rvh), web_prefs);
517 } 557 }
518 558
519 ScopedVector<content::NavigationThrottle> 559 ScopedVector<content::NavigationThrottle>
520 AwContentBrowserClient::CreateThrottlesForNavigation( 560 AwContentBrowserClient::CreateThrottlesForNavigation(
521 content::NavigationHandle* navigation_handle) { 561 content::NavigationHandle* navigation_handle) {
522 ScopedVector<content::NavigationThrottle> throttles; 562 ScopedVector<content::NavigationThrottle> throttles;
523 if (navigation_handle->IsInMainFrame() || 563 // We allow intercepting only navigations within main frames. This
524 (!navigation_handle->GetURL().SchemeIs(url::kHttpScheme) && 564 // is used to post onPageStarted. We handle shouldOverrideUrlLoading
525 !navigation_handle->GetURL().SchemeIs(url::kHttpsScheme) && 565 // via a sync IPC.
526 !navigation_handle->GetURL().SchemeIs(url::kAboutScheme))) { 566 if (navigation_handle->IsInMainFrame()) {
527 throttles.push_back( 567 throttles.push_back(
528 navigation_interception::InterceptNavigationDelegate::CreateThrottleFor( 568 navigation_interception::InterceptNavigationDelegate::CreateThrottleFor(
529 navigation_handle)); 569 navigation_handle));
530 } 570 }
531 return throttles; 571 return throttles;
532 } 572 }
533 573
534 #if defined(VIDEO_HOLE) 574 #if defined(VIDEO_HOLE)
535 content::ExternalVideoSurfaceContainer* 575 content::ExternalVideoSurfaceContainer*
536 AwContentBrowserClient::OverrideCreateExternalVideoSurfaceContainer( 576 AwContentBrowserClient::OverrideCreateExternalVideoSurfaceContainer(
537 content::WebContents* web_contents) { 577 content::WebContents* web_contents) {
538 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents); 578 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents);
539 } 579 }
540 #endif 580 #endif
541 581
542 } // namespace android_webview 582 } // 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