| 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/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/url_constants.h" | 8 #include "android_webview/common/url_constants.h" |
| 9 #include "android_webview/renderer/aw_render_view_ext.h" | 9 #include "android_webview/renderer/aw_render_view_ext.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "components/visitedlink/renderer/visitedlink_slave.h" |
| 11 #include "content/public/renderer/render_thread.h" | 12 #include "content/public/renderer/render_thread.h" |
| 12 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
| 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |
| 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h" | 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h" |
| 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" | 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
| 18 | 19 |
| 19 namespace android_webview { | 20 namespace android_webview { |
| 20 | 21 |
| 21 AwContentRendererClient::AwContentRendererClient() { | 22 AwContentRendererClient::AwContentRendererClient() { |
| 22 } | 23 } |
| 23 | 24 |
| 24 AwContentRendererClient::~AwContentRendererClient() { | 25 AwContentRendererClient::~AwContentRendererClient() { |
| 25 } | 26 } |
| 26 | 27 |
| 27 void AwContentRendererClient::RenderThreadStarted() { | 28 void AwContentRendererClient::RenderThreadStarted() { |
| 28 WebKit::WebString content_scheme( | 29 WebKit::WebString content_scheme( |
| 29 ASCIIToUTF16(android_webview::kContentScheme)); | 30 ASCIIToUTF16(android_webview::kContentScheme)); |
| 30 WebKit::WebSecurityPolicy::registerURLSchemeAsLocal(content_scheme); | 31 WebKit::WebSecurityPolicy::registerURLSchemeAsLocal(content_scheme); |
| 31 | 32 |
| 33 content::RenderThread* thread = content::RenderThread::Get(); |
| 34 |
| 32 aw_render_process_observer_.reset(new AwRenderProcessObserver); | 35 aw_render_process_observer_.reset(new AwRenderProcessObserver); |
| 33 content::RenderThread::Get()->AddObserver( | 36 thread->AddObserver(aw_render_process_observer_.get()); |
| 34 aw_render_process_observer_.get()); | 37 |
| 38 visited_link_slave_.reset(new components::VisitedLinkSlave); |
| 39 thread->AddObserver(visited_link_slave_.get()); |
| 35 } | 40 } |
| 36 | 41 |
| 37 void AwContentRendererClient::RenderViewCreated( | 42 void AwContentRendererClient::RenderViewCreated( |
| 38 content::RenderView* render_view) { | 43 content::RenderView* render_view) { |
| 39 AwRenderViewExt::RenderViewCreated(render_view); | 44 AwRenderViewExt::RenderViewCreated(render_view); |
| 40 } | 45 } |
| 41 | 46 |
| 42 std::string AwContentRendererClient::GetDefaultEncoding() { | 47 std::string AwContentRendererClient::GetDefaultEncoding() { |
| 43 return AwResource::GetDefaultTextEncoding(); | 48 return AwResource::GetDefaultTextEncoding(); |
| 44 } | 49 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 66 | 71 |
| 67 ReplaceSubstringsAfterOffset(&contents, 0, "%s", | 72 ReplaceSubstringsAfterOffset(&contents, 0, "%s", |
| 68 error_url.possibly_invalid_spec()); | 73 error_url.possibly_invalid_spec()); |
| 69 *error_html = contents; | 74 *error_html = contents; |
| 70 } | 75 } |
| 71 } | 76 } |
| 72 | 77 |
| 73 unsigned long long AwContentRendererClient::VisitedLinkHash( | 78 unsigned long long AwContentRendererClient::VisitedLinkHash( |
| 74 const char* canonical_url, | 79 const char* canonical_url, |
| 75 size_t length) { | 80 size_t length) { |
| 76 // TODO(boliu): Implement a visited link solution for Android WebView. | 81 return visited_link_slave_->ComputeURLFingerprint(canonical_url, length); |
| 77 // Perhaps componentize chrome implementation or move to content/? | |
| 78 return 0LL; | |
| 79 } | 82 } |
| 80 | 83 |
| 81 bool AwContentRendererClient::IsLinkVisited(unsigned long long link_hash) { | 84 bool AwContentRendererClient::IsLinkVisited(unsigned long long link_hash) { |
| 82 // TODO(boliu): Implement a visited link solution for Android WebView. | 85 return visited_link_slave_->IsVisited(link_hash); |
| 83 // Perhaps componentize chrome implementation or move to content/? | |
| 84 return false; | |
| 85 } | 86 } |
| 86 | 87 |
| 87 void AwContentRendererClient::PrefetchHostName(const char* hostname, | 88 void AwContentRendererClient::PrefetchHostName(const char* hostname, |
| 88 size_t length) { | 89 size_t length) { |
| 89 // TODO(boliu): Implement hostname prefetch for Android WebView. | 90 // TODO(boliu): Implement hostname prefetch for Android WebView. |
| 90 // Perhaps componentize chrome implementation or move to content/? | 91 // Perhaps componentize chrome implementation or move to content/? |
| 91 } | 92 } |
| 92 | 93 |
| 93 } // namespace android_webview | 94 } // namespace android_webview |
| OLD | NEW |