Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/renderer/aw_content_renderer_client.h" | 5 #include "android_webview/renderer/aw_content_renderer_client.h" |
| 6 | 6 |
| 7 #include "android_webview/common/aw_resource.h" | 7 #include "android_webview/common/aw_resource.h" |
| 8 #include "android_webview/common/render_view_messages.h" | |
| 8 #include "android_webview/common/url_constants.h" | 9 #include "android_webview/common/url_constants.h" |
| 9 #include "android_webview/renderer/aw_render_view_ext.h" | 10 #include "android_webview/renderer/aw_render_view_ext.h" |
| 10 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 12 #include "components/autofill/content/renderer/autofill_agent.h" | 13 #include "components/autofill/content/renderer/autofill_agent.h" |
| 13 #include "components/autofill/content/renderer/password_autofill_agent.h" | 14 #include "components/autofill/content/renderer/password_autofill_agent.h" |
| 14 #include "components/visitedlink/renderer/visitedlink_slave.h" | 15 #include "components/visitedlink/renderer/visitedlink_slave.h" |
| 16 #include "content/public/renderer/document_state.h" | |
| 17 #include "content/public/renderer/navigation_state.h" | |
| 15 #include "content/public/renderer/render_thread.h" | 18 #include "content/public/renderer/render_thread.h" |
| 19 #include "content/public/renderer/render_view.h" | |
| 16 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 17 #include "third_party/WebKit/public/platform/WebString.h" | 21 #include "third_party/WebKit/public/platform/WebString.h" |
| 18 #include "third_party/WebKit/public/platform/WebURL.h" | 22 #include "third_party/WebKit/public/platform/WebURL.h" |
| 19 #include "third_party/WebKit/public/platform/WebURLError.h" | 23 #include "third_party/WebKit/public/platform/WebURLError.h" |
| 20 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 24 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 25 #include "third_party/WebKit/public/web/WebFrame.h" | |
| 26 #include "third_party/WebKit/public/web/WebNavigationType.h" | |
| 21 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 27 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
| 22 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 23 | 29 |
| 24 namespace android_webview { | 30 namespace android_webview { |
| 25 | 31 |
| 26 AwContentRendererClient::AwContentRendererClient() { | 32 AwContentRendererClient::AwContentRendererClient() { |
| 27 } | 33 } |
| 28 | 34 |
| 29 AwContentRendererClient::~AwContentRendererClient() { | 35 AwContentRendererClient::~AwContentRendererClient() { |
| 30 } | 36 } |
| 31 | 37 |
| 32 void AwContentRendererClient::RenderThreadStarted() { | 38 void AwContentRendererClient::RenderThreadStarted() { |
| 33 WebKit::WebString content_scheme( | 39 WebKit::WebString content_scheme( |
| 34 ASCIIToUTF16(android_webview::kContentScheme)); | 40 ASCIIToUTF16(android_webview::kContentScheme)); |
| 35 WebKit::WebSecurityPolicy::registerURLSchemeAsLocal(content_scheme); | 41 WebKit::WebSecurityPolicy::registerURLSchemeAsLocal(content_scheme); |
| 36 | 42 |
| 37 content::RenderThread* thread = content::RenderThread::Get(); | 43 content::RenderThread* thread = content::RenderThread::Get(); |
| 38 | 44 |
| 39 aw_render_process_observer_.reset(new AwRenderProcessObserver); | 45 aw_render_process_observer_.reset(new AwRenderProcessObserver); |
| 40 thread->AddObserver(aw_render_process_observer_.get()); | 46 thread->AddObserver(aw_render_process_observer_.get()); |
| 41 | 47 |
| 42 visited_link_slave_.reset(new visitedlink::VisitedLinkSlave); | 48 visited_link_slave_.reset(new visitedlink::VisitedLinkSlave); |
| 43 thread->AddObserver(visited_link_slave_.get()); | 49 thread->AddObserver(visited_link_slave_.get()); |
| 44 } | 50 } |
| 45 | 51 |
| 52 bool AwContentRendererClient::HandleNavigation( | |
| 53 content::RenderView* view, | |
| 54 content::DocumentState* document_state, | |
| 55 WebKit::WebFrame* frame, | |
| 56 const WebKit::WebURLRequest& request, | |
| 57 WebKit::WebNavigationType type, | |
| 58 WebKit::WebNavigationPolicy default_policy, | |
| 59 bool is_redirect) { | |
| 60 | |
| 61 // Only GETs can be overridden. | |
| 62 if (!request.httpMethod().equals("GET")) | |
| 63 return false; | |
| 64 | |
| 65 // Any navigation from loadUrl, and goBack/Forward are considered application- | |
| 66 // initiated and hence will not yield a shouldOverrideUrlLoading() callback. | |
| 67 // Webview classic does not consider reload application-initiated so we | |
| 68 // continue the same behavior. | |
| 69 bool application_initiated = | |
| 70 !document_state->navigation_state()->is_content_initiated() | |
|
mkosiba (inactive)
2013/09/25 22:23:26
is_content_initiated would normally be false for c
sgurun-gerrit only
2013/10/09 00:26:13
Done.
| |
| 71 || type == WebKit::WebNavigationTypeBackForward; | |
| 72 | |
| 73 // Don't offer application-initiated navigations unless it's a redirect. | |
| 74 if (application_initiated && !is_redirect) | |
| 75 return false; | |
| 76 | |
| 77 const GURL& gurl = request.url(); | |
| 78 // For HTTP schemes, only top-level navigations can be overridden. | |
| 79 // HandleNavigation receives about:blank navigations, (for example for | |
| 80 // empty iframes), however webview classic does not pass these to the | |
| 81 // app using shouldoverrideurlloading, so we filter them out here. Not | |
| 82 // adding a special test for this, since removing the filtering causes | |
| 83 // multiple shouldoverrideurlloading aw tests to fail, anyway. | |
| 84 if (frame->parent() && (gurl.SchemeIs("http") || gurl.SchemeIs("https") || | |
| 85 gurl.SchemeIs("about"))) | |
| 86 return false; | |
| 87 | |
| 88 bool ignore_navigation = false; | |
| 89 int routing_id = view->GetRoutingID(); | |
| 90 base::string16 url = request.url().string(); | |
| 91 view->Send (new AwViewHostMsg_ShouldOverrideUrlLoading(routing_id, | |
| 92 url, | |
| 93 &ignore_navigation)); | |
| 94 return ignore_navigation; | |
| 95 } | |
| 96 | |
| 46 void AwContentRendererClient::RenderViewCreated( | 97 void AwContentRendererClient::RenderViewCreated( |
| 47 content::RenderView* render_view) { | 98 content::RenderView* render_view) { |
| 48 AwRenderViewExt::RenderViewCreated(render_view); | 99 AwRenderViewExt::RenderViewCreated(render_view); |
| 49 | 100 |
| 50 // TODO(sgurun) do not create a password autofill agent (change | 101 // TODO(sgurun) do not create a password autofill agent (change |
| 51 // autofill agent to store a weakptr). | 102 // autofill agent to store a weakptr). |
| 52 autofill::PasswordAutofillAgent* password_autofill_agent = | 103 autofill::PasswordAutofillAgent* password_autofill_agent = |
| 53 new autofill::PasswordAutofillAgent(render_view); | 104 new autofill::PasswordAutofillAgent(render_view); |
| 54 new autofill::AutofillAgent(render_view, password_autofill_agent); | 105 new autofill::AutofillAgent(render_view, password_autofill_agent); |
| 55 } | 106 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 const char* canonical_url, | 147 const char* canonical_url, |
| 97 size_t length) { | 148 size_t length) { |
| 98 return visited_link_slave_->ComputeURLFingerprint(canonical_url, length); | 149 return visited_link_slave_->ComputeURLFingerprint(canonical_url, length); |
| 99 } | 150 } |
| 100 | 151 |
| 101 bool AwContentRendererClient::IsLinkVisited(unsigned long long link_hash) { | 152 bool AwContentRendererClient::IsLinkVisited(unsigned long long link_hash) { |
| 102 return visited_link_slave_->IsVisited(link_hash); | 153 return visited_link_slave_->IsVisited(link_hash); |
| 103 } | 154 } |
| 104 | 155 |
| 105 } // namespace android_webview | 156 } // namespace android_webview |
| OLD | NEW |