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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "android_webview/common/aw_resource.h" | 9 #include "android_webview/common/aw_resource.h" |
10 #include "android_webview/common/aw_switches.h" | 10 #include "android_webview/common/aw_switches.h" |
11 #include "android_webview/common/render_view_messages.h" | 11 #include "android_webview/common/render_view_messages.h" |
12 #include "android_webview/common/url_constants.h" | 12 #include "android_webview/common/url_constants.h" |
13 #include "android_webview/grit/aw_resources.h" | 13 #include "android_webview/grit/aw_resources.h" |
14 #include "android_webview/grit/aw_strings.h" | 14 #include "android_webview/grit/aw_strings.h" |
15 #include "android_webview/renderer/aw_content_settings_client.h" | 15 #include "android_webview/renderer/aw_content_settings_client.h" |
16 #include "android_webview/renderer/aw_key_systems.h" | 16 #include "android_webview/renderer/aw_key_systems.h" |
17 #include "android_webview/renderer/aw_print_web_view_helper_delegate.h" | 17 #include "android_webview/renderer/aw_print_web_view_helper_delegate.h" |
18 #include "android_webview/renderer/aw_render_frame_ext.h" | 18 #include "android_webview/renderer/aw_render_frame_ext.h" |
19 #include "android_webview/renderer/aw_render_view_ext.h" | 19 #include "android_webview/renderer/aw_render_view_ext.h" |
20 #include "android_webview/renderer/print_render_frame_observer.h" | 20 #include "android_webview/renderer/print_render_frame_observer.h" |
21 #include "base/command_line.h" | 21 #include "base/command_line.h" |
22 #include "base/i18n/rtl.h" | 22 #include "base/i18n/rtl.h" |
23 #include "base/message_loop/message_loop.h" | 23 #include "base/message_loop/message_loop.h" |
24 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
26 #include "components/autofill/content/renderer/autofill_agent.h" | 26 #include "components/autofill/content/renderer/autofill_agent.h" |
27 #include "components/autofill/content/renderer/password_autofill_agent.h" | 27 #include "components/autofill/content/renderer/password_autofill_agent.h" |
28 #include "components/printing/renderer/print_web_view_helper.h" | 28 #include "components/printing/renderer/print_web_view_helper.h" |
| 29 #include "components/spellcheck/spellcheck_build_features.h" |
29 #include "components/supervised_user_error_page/gin_wrapper.h" | 30 #include "components/supervised_user_error_page/gin_wrapper.h" |
30 #include "components/supervised_user_error_page/supervised_user_error_page_andro
id.h" | 31 #include "components/supervised_user_error_page/supervised_user_error_page_andro
id.h" |
31 #include "components/visitedlink/renderer/visitedlink_slave.h" | 32 #include "components/visitedlink/renderer/visitedlink_slave.h" |
32 #include "components/web_restrictions/interfaces/web_restrictions.mojom.h" | 33 #include "components/web_restrictions/interfaces/web_restrictions.mojom.h" |
33 #include "content/public/common/url_constants.h" | 34 #include "content/public/common/url_constants.h" |
34 #include "content/public/renderer/document_state.h" | 35 #include "content/public/renderer/document_state.h" |
35 #include "content/public/renderer/navigation_state.h" | 36 #include "content/public/renderer/navigation_state.h" |
36 #include "content/public/renderer/render_frame.h" | 37 #include "content/public/renderer/render_frame.h" |
37 #include "content/public/renderer/render_thread.h" | 38 #include "content/public/renderer/render_thread.h" |
38 #include "content/public/renderer/render_view.h" | 39 #include "content/public/renderer/render_view.h" |
39 #include "net/base/escape.h" | 40 #include "net/base/escape.h" |
40 #include "net/base/net_errors.h" | 41 #include "net/base/net_errors.h" |
41 #include "services/service_manager/public/cpp/interface_provider.h" | 42 #include "services/service_manager/public/cpp/interface_provider.h" |
42 #include "services/service_manager/public/cpp/interface_registry.h" | 43 #include "services/service_manager/public/cpp/interface_registry.h" |
43 #include "third_party/WebKit/public/platform/WebString.h" | 44 #include "third_party/WebKit/public/platform/WebString.h" |
44 #include "third_party/WebKit/public/platform/WebURL.h" | 45 #include "third_party/WebKit/public/platform/WebURL.h" |
45 #include "third_party/WebKit/public/platform/WebURLError.h" | 46 #include "third_party/WebKit/public/platform/WebURLError.h" |
46 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 47 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
47 #include "third_party/WebKit/public/web/WebFrame.h" | 48 #include "third_party/WebKit/public/web/WebFrame.h" |
48 #include "third_party/WebKit/public/web/WebNavigationType.h" | 49 #include "third_party/WebKit/public/web/WebNavigationType.h" |
49 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 50 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
50 #include "ui/base/l10n/l10n_util.h" | 51 #include "ui/base/l10n/l10n_util.h" |
51 #include "ui/base/resource/resource_bundle.h" | 52 #include "ui/base/resource/resource_bundle.h" |
52 #include "url/gurl.h" | 53 #include "url/gurl.h" |
53 #include "url/url_constants.h" | 54 #include "url/url_constants.h" |
54 | 55 |
55 #if defined(ENABLE_SPELLCHECK) | 56 #if BUILDFLAG(ENABLE_SPELLCHECK) |
56 #include "components/spellcheck/renderer/spellcheck.h" | 57 #include "components/spellcheck/renderer/spellcheck.h" |
57 #include "components/spellcheck/renderer/spellcheck_provider.h" | 58 #include "components/spellcheck/renderer/spellcheck_provider.h" |
58 #endif | 59 #endif |
59 | 60 |
60 using content::RenderThread; | 61 using content::RenderThread; |
61 | 62 |
62 namespace android_webview { | 63 namespace android_webview { |
63 | 64 |
64 AwContentRendererClient::AwContentRendererClient() {} | 65 AwContentRendererClient::AwContentRendererClient() {} |
65 | 66 |
66 AwContentRendererClient::~AwContentRendererClient() {} | 67 AwContentRendererClient::~AwContentRendererClient() {} |
67 | 68 |
68 void AwContentRendererClient::RenderThreadStarted() { | 69 void AwContentRendererClient::RenderThreadStarted() { |
69 RenderThread* thread = RenderThread::Get(); | 70 RenderThread* thread = RenderThread::Get(); |
70 aw_render_thread_observer_.reset(new AwRenderThreadObserver); | 71 aw_render_thread_observer_.reset(new AwRenderThreadObserver); |
71 thread->AddObserver(aw_render_thread_observer_.get()); | 72 thread->AddObserver(aw_render_thread_observer_.get()); |
72 | 73 |
73 visited_link_slave_.reset(new visitedlink::VisitedLinkSlave); | 74 visited_link_slave_.reset(new visitedlink::VisitedLinkSlave); |
74 thread->GetInterfaceRegistry()->AddInterface( | 75 thread->GetInterfaceRegistry()->AddInterface( |
75 visited_link_slave_->GetBindCallback()); | 76 visited_link_slave_->GetBindCallback()); |
76 | 77 |
77 blink::WebString content_scheme(base::ASCIIToUTF16(url::kContentScheme)); | 78 blink::WebString content_scheme(base::ASCIIToUTF16(url::kContentScheme)); |
78 blink::WebSecurityPolicy::registerURLSchemeAsLocal(content_scheme); | 79 blink::WebSecurityPolicy::registerURLSchemeAsLocal(content_scheme); |
79 | 80 |
80 blink::WebString aw_scheme( | 81 blink::WebString aw_scheme( |
81 base::ASCIIToUTF16(android_webview::kAndroidWebViewVideoPosterScheme)); | 82 base::ASCIIToUTF16(android_webview::kAndroidWebViewVideoPosterScheme)); |
82 blink::WebSecurityPolicy::registerURLSchemeAsSecure(aw_scheme); | 83 blink::WebSecurityPolicy::registerURLSchemeAsSecure(aw_scheme); |
83 | 84 |
84 #if defined(ENABLE_SPELLCHECK) | 85 #if BUILDFLAG(ENABLE_SPELLCHECK) |
85 if (!spellcheck_) { | 86 if (!spellcheck_) { |
86 spellcheck_ = base::MakeUnique<SpellCheck>(); | 87 spellcheck_ = base::MakeUnique<SpellCheck>(); |
87 thread->AddObserver(spellcheck_.get()); | 88 thread->AddObserver(spellcheck_.get()); |
88 } | 89 } |
89 #endif | 90 #endif |
90 } | 91 } |
91 | 92 |
92 bool AwContentRendererClient::HandleNavigation( | 93 bool AwContentRendererClient::HandleNavigation( |
93 content::RenderFrame* render_frame, | 94 content::RenderFrame* render_frame, |
94 bool is_content_initiated, | 95 bool is_content_initiated, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 170 } |
170 | 171 |
171 void AwContentRendererClient::RenderViewCreated( | 172 void AwContentRendererClient::RenderViewCreated( |
172 content::RenderView* render_view) { | 173 content::RenderView* render_view) { |
173 AwRenderViewExt::RenderViewCreated(render_view); | 174 AwRenderViewExt::RenderViewCreated(render_view); |
174 | 175 |
175 new printing::PrintWebViewHelper( | 176 new printing::PrintWebViewHelper( |
176 render_view, std::unique_ptr<printing::PrintWebViewHelper::Delegate>( | 177 render_view, std::unique_ptr<printing::PrintWebViewHelper::Delegate>( |
177 new AwPrintWebViewHelperDelegate())); | 178 new AwPrintWebViewHelperDelegate())); |
178 | 179 |
179 #if defined(ENABLE_SPELLCHECK) | 180 #if BUILDFLAG(ENABLE_SPELLCHECK) |
180 new SpellCheckProvider(render_view, spellcheck_.get()); | 181 new SpellCheckProvider(render_view, spellcheck_.get()); |
181 #endif | 182 #endif |
182 } | 183 } |
183 | 184 |
184 bool AwContentRendererClient::HasErrorPage(int http_status_code, | 185 bool AwContentRendererClient::HasErrorPage(int http_status_code, |
185 std::string* error_domain) { | 186 std::string* error_domain) { |
186 return http_status_code >= 400; | 187 return http_status_code >= 400; |
187 } | 188 } |
188 | 189 |
189 void AwContentRendererClient::GetNavigationErrorStrings( | 190 void AwContentRendererClient::GetNavigationErrorStrings( |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 for (auto* extension : kMediaPlayerExtensions) { | 277 for (auto* extension : kMediaPlayerExtensions) { |
277 if (base::EndsWith(url.path(), extension, | 278 if (base::EndsWith(url.path(), extension, |
278 base::CompareCase::INSENSITIVE_ASCII)) { | 279 base::CompareCase::INSENSITIVE_ASCII)) { |
279 return true; | 280 return true; |
280 } | 281 } |
281 } | 282 } |
282 return false; | 283 return false; |
283 } | 284 } |
284 | 285 |
285 } // namespace android_webview | 286 } // namespace android_webview |
OLD | NEW |