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 "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #include "content/public/common/content_constants.h" | 55 #include "content/public/common/content_constants.h" |
56 #include "content/public/common/content_switches.h" | 56 #include "content/public/common/content_switches.h" |
57 #include "content/public/common/drop_data.h" | 57 #include "content/public/common/drop_data.h" |
58 #include "content/public/common/favicon_url.h" | 58 #include "content/public/common/favicon_url.h" |
59 #include "content/public/common/file_chooser_params.h" | 59 #include "content/public/common/file_chooser_params.h" |
60 #include "content/public/common/page_zoom.h" | 60 #include "content/public/common/page_zoom.h" |
61 #include "content/public/common/ssl_status.h" | 61 #include "content/public/common/ssl_status.h" |
62 #include "content/public/common/three_d_api_types.h" | 62 #include "content/public/common/three_d_api_types.h" |
63 #include "content/public/common/url_constants.h" | 63 #include "content/public/common/url_constants.h" |
64 #include "content/public/common/url_utils.h" | 64 #include "content/public/common/url_utils.h" |
| 65 #include "content/public/common/web_preferences.h" |
65 #include "content/public/renderer/content_renderer_client.h" | 66 #include "content/public/renderer/content_renderer_client.h" |
66 #include "content/public/renderer/document_state.h" | 67 #include "content/public/renderer/document_state.h" |
67 #include "content/public/renderer/navigation_state.h" | 68 #include "content/public/renderer/navigation_state.h" |
68 #include "content/public/renderer/render_view_observer.h" | 69 #include "content/public/renderer/render_view_observer.h" |
69 #include "content/public/renderer/render_view_visitor.h" | 70 #include "content/public/renderer/render_view_visitor.h" |
70 #include "content/public/renderer/web_preferences.h" | |
71 #include "content/renderer/accessibility/renderer_accessibility.h" | 71 #include "content/renderer/accessibility/renderer_accessibility.h" |
72 #include "content/renderer/accessibility/renderer_accessibility_complete.h" | 72 #include "content/renderer/accessibility/renderer_accessibility_complete.h" |
73 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" | 73 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" |
74 #include "content/renderer/browser_plugin/browser_plugin.h" | 74 #include "content/renderer/browser_plugin/browser_plugin.h" |
75 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 75 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
76 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" | 76 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" |
77 #include "content/renderer/devtools/devtools_agent.h" | 77 #include "content/renderer/devtools/devtools_agent.h" |
78 #include "content/renderer/disambiguation_popup_helper.h" | 78 #include "content/renderer/disambiguation_popup_helper.h" |
79 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" | 79 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
80 #include "content/renderer/drop_data_builder.h" | 80 #include "content/renderer/drop_data_builder.h" |
81 #include "content/renderer/external_popup_menu.h" | 81 #include "content/renderer/external_popup_menu.h" |
82 #include "content/renderer/gpu/render_widget_compositor.h" | 82 #include "content/renderer/gpu/render_widget_compositor.h" |
83 #include "content/renderer/history_controller.h" | 83 #include "content/renderer/history_controller.h" |
84 #include "content/renderer/history_serialization.h" | 84 #include "content/renderer/history_serialization.h" |
85 #include "content/renderer/idle_user_detector.h" | 85 #include "content/renderer/idle_user_detector.h" |
86 #include "content/renderer/ime_event_guard.h" | 86 #include "content/renderer/ime_event_guard.h" |
87 #include "content/renderer/input/input_handler_manager.h" | 87 #include "content/renderer/input/input_handler_manager.h" |
88 #include "content/renderer/internal_document_state_data.h" | 88 #include "content/renderer/internal_document_state_data.h" |
89 #include "content/renderer/media/audio_device_factory.h" | 89 #include "content/renderer/media/audio_device_factory.h" |
90 #include "content/renderer/media/media_stream_dispatcher.h" | 90 #include "content/renderer/media/media_stream_dispatcher.h" |
91 #include "content/renderer/media/video_capture_impl_manager.h" | 91 #include "content/renderer/media/video_capture_impl_manager.h" |
92 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" | 92 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
93 #include "content/renderer/memory_benchmarking_extension.h" | 93 #include "content/renderer/memory_benchmarking_extension.h" |
94 #include "content/renderer/mhtml_generator.h" | 94 #include "content/renderer/mhtml_generator.h" |
| 95 #include "content/renderer/net_info_helper.h" |
95 #include "content/renderer/push_messaging_dispatcher.h" | 96 #include "content/renderer/push_messaging_dispatcher.h" |
96 #include "content/renderer/render_frame_impl.h" | 97 #include "content/renderer/render_frame_impl.h" |
97 #include "content/renderer/render_frame_proxy.h" | 98 #include "content/renderer/render_frame_proxy.h" |
98 #include "content/renderer/render_process.h" | 99 #include "content/renderer/render_process.h" |
99 #include "content/renderer/render_thread_impl.h" | 100 #include "content/renderer/render_thread_impl.h" |
100 #include "content/renderer/render_view_impl_params.h" | 101 #include "content/renderer/render_view_impl_params.h" |
101 #include "content/renderer/render_view_mouse_lock_dispatcher.h" | 102 #include "content/renderer/render_view_mouse_lock_dispatcher.h" |
102 #include "content/renderer/render_widget_fullscreen_pepper.h" | 103 #include "content/renderer/render_widget_fullscreen_pepper.h" |
103 #include "content/renderer/renderer_webapplicationcachehost_impl.h" | 104 #include "content/renderer/renderer_webapplicationcachehost_impl.h" |
104 #include "content/renderer/resizing_mode_selector.h" | 105 #include "content/renderer/resizing_mode_selector.h" |
(...skipping 12 matching lines...) Expand all Loading... |
117 #include "media/base/filter_collection.h" | 118 #include "media/base/filter_collection.h" |
118 #include "media/base/media_switches.h" | 119 #include "media/base/media_switches.h" |
119 #include "media/filters/audio_renderer_impl.h" | 120 #include "media/filters/audio_renderer_impl.h" |
120 #include "media/filters/gpu_video_accelerator_factories.h" | 121 #include "media/filters/gpu_video_accelerator_factories.h" |
121 #include "net/base/data_url.h" | 122 #include "net/base/data_url.h" |
122 #include "net/base/escape.h" | 123 #include "net/base/escape.h" |
123 #include "net/base/net_errors.h" | 124 #include "net/base/net_errors.h" |
124 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 125 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
125 #include "net/http/http_util.h" | 126 #include "net/http/http_util.h" |
126 #include "third_party/WebKit/public/platform/WebCString.h" | 127 #include "third_party/WebKit/public/platform/WebCString.h" |
| 128 #include "third_party/WebKit/public/platform/WebConnectionType.h" |
127 #include "third_party/WebKit/public/platform/WebDragData.h" | 129 #include "third_party/WebKit/public/platform/WebDragData.h" |
128 #include "third_party/WebKit/public/platform/WebHTTPBody.h" | 130 #include "third_party/WebKit/public/platform/WebHTTPBody.h" |
129 #include "third_party/WebKit/public/platform/WebImage.h" | 131 #include "third_party/WebKit/public/platform/WebImage.h" |
130 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" | 132 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" |
131 #include "third_party/WebKit/public/platform/WebPoint.h" | 133 #include "third_party/WebKit/public/platform/WebPoint.h" |
132 #include "third_party/WebKit/public/platform/WebRect.h" | 134 #include "third_party/WebKit/public/platform/WebRect.h" |
133 #include "third_party/WebKit/public/platform/WebSize.h" | 135 #include "third_party/WebKit/public/platform/WebSize.h" |
134 #include "third_party/WebKit/public/platform/WebSocketStreamHandle.h" | 136 #include "third_party/WebKit/public/platform/WebSocketStreamHandle.h" |
135 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" | 137 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" |
136 #include "third_party/WebKit/public/platform/WebString.h" | 138 #include "third_party/WebKit/public/platform/WebString.h" |
(...skipping 18 matching lines...) Expand all Loading... |
155 #include "third_party/WebKit/public/web/WebFormControlElement.h" | 157 #include "third_party/WebKit/public/web/WebFormControlElement.h" |
156 #include "third_party/WebKit/public/web/WebFormElement.h" | 158 #include "third_party/WebKit/public/web/WebFormElement.h" |
157 #include "third_party/WebKit/public/web/WebFrame.h" | 159 #include "third_party/WebKit/public/web/WebFrame.h" |
158 #include "third_party/WebKit/public/web/WebGlyphCache.h" | 160 #include "third_party/WebKit/public/web/WebGlyphCache.h" |
159 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 161 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
160 #include "third_party/WebKit/public/web/WebInputElement.h" | 162 #include "third_party/WebKit/public/web/WebInputElement.h" |
161 #include "third_party/WebKit/public/web/WebInputEvent.h" | 163 #include "third_party/WebKit/public/web/WebInputEvent.h" |
162 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 164 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
163 #include "third_party/WebKit/public/web/WebMediaPlayerAction.h" | 165 #include "third_party/WebKit/public/web/WebMediaPlayerAction.h" |
164 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" | 166 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
| 167 #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h" |
165 #include "third_party/WebKit/public/web/WebNodeList.h" | 168 #include "third_party/WebKit/public/web/WebNodeList.h" |
166 #include "third_party/WebKit/public/web/WebPageSerializer.h" | 169 #include "third_party/WebKit/public/web/WebPageSerializer.h" |
167 #include "third_party/WebKit/public/web/WebPlugin.h" | 170 #include "third_party/WebKit/public/web/WebPlugin.h" |
168 #include "third_party/WebKit/public/web/WebPluginAction.h" | 171 #include "third_party/WebKit/public/web/WebPluginAction.h" |
169 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 172 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
170 #include "third_party/WebKit/public/web/WebPluginDocument.h" | 173 #include "third_party/WebKit/public/web/WebPluginDocument.h" |
171 #include "third_party/WebKit/public/web/WebRange.h" | 174 #include "third_party/WebKit/public/web/WebRange.h" |
| 175 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
172 #include "third_party/WebKit/public/web/WebScriptSource.h" | 176 #include "third_party/WebKit/public/web/WebScriptSource.h" |
173 #include "third_party/WebKit/public/web/WebSearchableFormData.h" | 177 #include "third_party/WebKit/public/web/WebSearchableFormData.h" |
174 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 178 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
175 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 179 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
176 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" | 180 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" |
177 #include "third_party/WebKit/public/web/WebSettings.h" | 181 #include "third_party/WebKit/public/web/WebSettings.h" |
178 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 182 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
179 #include "third_party/WebKit/public/web/WebView.h" | 183 #include "third_party/WebKit/public/web/WebView.h" |
180 #include "third_party/WebKit/public/web/WebWindowFeatures.h" | 184 #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
181 #include "third_party/WebKit/public/web/default/WebRenderTheme.h" | 185 #include "third_party/WebKit/public/web/default/WebRenderTheme.h" |
| 186 #include "third_party/icu/source/common/unicode/uchar.h" |
| 187 #include "third_party/icu/source/common/unicode/uscript.h" |
182 #include "ui/base/clipboard/clipboard.h" | 188 #include "ui/base/clipboard/clipboard.h" |
183 #include "ui/base/ui_base_switches_util.h" | 189 #include "ui/base/ui_base_switches_util.h" |
184 #include "ui/events/latency_info.h" | 190 #include "ui/events/latency_info.h" |
185 #include "ui/gfx/native_widget_types.h" | 191 #include "ui/gfx/native_widget_types.h" |
186 #include "ui/gfx/point.h" | 192 #include "ui/gfx/point.h" |
187 #include "ui/gfx/rect.h" | 193 #include "ui/gfx/rect.h" |
188 #include "ui/gfx/rect_conversions.h" | 194 #include "ui/gfx/rect_conversions.h" |
189 #include "ui/gfx/size_conversions.h" | 195 #include "ui/gfx/size_conversions.h" |
190 #include "ui/shell_dialogs/selected_file_info.h" | 196 #include "ui/shell_dialogs/selected_file_info.h" |
191 #include "v8/include/v8.h" | 197 #include "v8/include/v8.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 using blink::WebTouchEvent; | 299 using blink::WebTouchEvent; |
294 using blink::WebURL; | 300 using blink::WebURL; |
295 using blink::WebURLError; | 301 using blink::WebURLError; |
296 using blink::WebURLRequest; | 302 using blink::WebURLRequest; |
297 using blink::WebURLResponse; | 303 using blink::WebURLResponse; |
298 using blink::WebUserGestureIndicator; | 304 using blink::WebUserGestureIndicator; |
299 using blink::WebVector; | 305 using blink::WebVector; |
300 using blink::WebView; | 306 using blink::WebView; |
301 using blink::WebWidget; | 307 using blink::WebWidget; |
302 using blink::WebWindowFeatures; | 308 using blink::WebWindowFeatures; |
| 309 using blink::WebNetworkStateNotifier; |
| 310 using blink::WebRuntimeFeatures; |
303 using base::Time; | 311 using base::Time; |
304 using base::TimeDelta; | 312 using base::TimeDelta; |
305 using webkit_glue::WebURLResponseExtraDataImpl; | 313 using webkit_glue::WebURLResponseExtraDataImpl; |
306 | 314 |
307 #if defined(OS_ANDROID) | 315 #if defined(OS_ANDROID) |
308 using blink::WebContentDetectionResult; | 316 using blink::WebContentDetectionResult; |
309 using blink::WebFloatPoint; | 317 using blink::WebFloatPoint; |
310 using blink::WebFloatRect; | 318 using blink::WebFloatRect; |
311 using blink::WebHitTestResult; | 319 using blink::WebHitTestResult; |
312 #endif | 320 #endif |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 item_list.push_back(item); | 610 item_list.push_back(item); |
603 } | 611 } |
604 | 612 |
605 WebDragData result; | 613 WebDragData result; |
606 result.initialize(); | 614 result.initialize(); |
607 result.setItems(item_list); | 615 result.setItems(item_list); |
608 result.setFilesystemId(drop_data.filesystem_id); | 616 result.setFilesystemId(drop_data.filesystem_id); |
609 return result; | 617 return result; |
610 } | 618 } |
611 | 619 |
| 620 typedef void (*SetFontFamilyWrapper)(blink::WebSettings*, |
| 621 const base::string16&, |
| 622 UScriptCode); |
| 623 |
| 624 void SetStandardFontFamilyWrapper(WebSettings* settings, |
| 625 const base::string16& font, |
| 626 UScriptCode script) { |
| 627 settings->setStandardFontFamily(font, script); |
| 628 } |
| 629 |
| 630 void SetFixedFontFamilyWrapper(WebSettings* settings, |
| 631 const base::string16& font, |
| 632 UScriptCode script) { |
| 633 settings->setFixedFontFamily(font, script); |
| 634 } |
| 635 |
| 636 void SetSerifFontFamilyWrapper(WebSettings* settings, |
| 637 const base::string16& font, |
| 638 UScriptCode script) { |
| 639 settings->setSerifFontFamily(font, script); |
| 640 } |
| 641 |
| 642 void SetSansSerifFontFamilyWrapper(WebSettings* settings, |
| 643 const base::string16& font, |
| 644 UScriptCode script) { |
| 645 settings->setSansSerifFontFamily(font, script); |
| 646 } |
| 647 |
| 648 void SetCursiveFontFamilyWrapper(WebSettings* settings, |
| 649 const base::string16& font, |
| 650 UScriptCode script) { |
| 651 settings->setCursiveFontFamily(font, script); |
| 652 } |
| 653 |
| 654 void SetFantasyFontFamilyWrapper(WebSettings* settings, |
| 655 const base::string16& font, |
| 656 UScriptCode script) { |
| 657 settings->setFantasyFontFamily(font, script); |
| 658 } |
| 659 |
| 660 void SetPictographFontFamilyWrapper(WebSettings* settings, |
| 661 const base::string16& font, |
| 662 UScriptCode script) { |
| 663 settings->setPictographFontFamily(font, script); |
| 664 } |
| 665 |
| 666 // If |scriptCode| is a member of a family of "similar" script codes, returns |
| 667 // the script code in that family that is used by WebKit for font selection |
| 668 // purposes. For example, USCRIPT_KATAKANA_OR_HIRAGANA and USCRIPT_JAPANESE are |
| 669 // considered equivalent for the purposes of font selection. WebKit uses the |
| 670 // script code USCRIPT_KATAKANA_OR_HIRAGANA. So, if |scriptCode| is |
| 671 // USCRIPT_JAPANESE, the function returns USCRIPT_KATAKANA_OR_HIRAGANA. WebKit |
| 672 // uses different scripts than the ones in Chrome pref names because the version |
| 673 // of ICU included on certain ports does not have some of the newer scripts. If |
| 674 // |scriptCode| is not a member of such a family, returns |scriptCode|. |
| 675 UScriptCode GetScriptForWebSettings(UScriptCode scriptCode) { |
| 676 switch (scriptCode) { |
| 677 case USCRIPT_HIRAGANA: |
| 678 case USCRIPT_KATAKANA: |
| 679 case USCRIPT_JAPANESE: |
| 680 return USCRIPT_KATAKANA_OR_HIRAGANA; |
| 681 case USCRIPT_KOREAN: |
| 682 return USCRIPT_HANGUL; |
| 683 default: |
| 684 return scriptCode; |
| 685 } |
| 686 } |
| 687 |
| 688 void ApplyFontsFromMap(const ScriptFontFamilyMap& map, |
| 689 SetFontFamilyWrapper setter, |
| 690 WebSettings* settings) { |
| 691 for (ScriptFontFamilyMap::const_iterator it = map.begin(); it != map.end(); |
| 692 ++it) { |
| 693 int32 script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str()); |
| 694 if (script >= 0 && script < USCRIPT_CODE_LIMIT) { |
| 695 UScriptCode code = static_cast<UScriptCode>(script); |
| 696 (*setter)(settings, it->second, GetScriptForWebSettings(code)); |
| 697 } |
| 698 } |
| 699 } |
| 700 |
612 } // namespace | 701 } // namespace |
613 | 702 |
614 RenderViewImpl::RenderViewImpl(RenderViewImplParams* params) | 703 RenderViewImpl::RenderViewImpl(RenderViewImplParams* params) |
615 : RenderWidget(blink::WebPopupTypeNone, | 704 : RenderWidget(blink::WebPopupTypeNone, |
616 params->screen_info, | 705 params->screen_info, |
617 params->swapped_out, | 706 params->swapped_out, |
618 params->hidden, | 707 params->hidden, |
619 params->never_visible), | 708 params->never_visible), |
620 webkit_preferences_(params->webkit_prefs), | 709 webkit_preferences_(params->webkit_prefs), |
621 send_content_state_immediately_(false), | 710 send_content_state_immediately_(false), |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 ShouldUseAcceleratedCompositingForOverflowScroll(device_scale_factor_)); | 821 ShouldUseAcceleratedCompositingForOverflowScroll(device_scale_factor_)); |
733 webview()->settings()->setAcceleratedCompositingForTransitionEnabled( | 822 webview()->settings()->setAcceleratedCompositingForTransitionEnabled( |
734 ShouldUseTransitionCompositing(device_scale_factor_)); | 823 ShouldUseTransitionCompositing(device_scale_factor_)); |
735 webview()->settings()->setAcceleratedCompositingForFixedRootBackgroundEnabled( | 824 webview()->settings()->setAcceleratedCompositingForFixedRootBackgroundEnabled( |
736 ShouldUseAcceleratedFixedRootBackground(device_scale_factor_)); | 825 ShouldUseAcceleratedFixedRootBackground(device_scale_factor_)); |
737 webview()->settings()->setCompositedScrollingForFramesEnabled( | 826 webview()->settings()->setCompositedScrollingForFramesEnabled( |
738 ShouldUseCompositedScrollingForFrames(device_scale_factor_)); | 827 ShouldUseCompositedScrollingForFrames(device_scale_factor_)); |
739 webview()->settings()->setUseExpandedHeuristicsForGpuRasterization( | 828 webview()->settings()->setUseExpandedHeuristicsForGpuRasterization( |
740 ShouldUseExpandedHeuristicsForGpuRasterization()); | 829 ShouldUseExpandedHeuristicsForGpuRasterization()); |
741 | 830 |
742 ApplyWebPreferences(webkit_preferences_, webview()); | 831 ApplyWebPreferences(webkit_preferences_); |
743 | 832 |
744 webview()->settings()->setAllowConnectingInsecureWebSocket( | 833 webview()->settings()->setAllowConnectingInsecureWebSocket( |
745 command_line.HasSwitch(switches::kAllowInsecureWebSocketFromHttpsOrigin)); | 834 command_line.HasSwitch(switches::kAllowInsecureWebSocketFromHttpsOrigin)); |
746 | 835 |
747 webview()->setMainFrame(main_render_frame_->GetWebFrame()); | 836 webview()->setMainFrame(main_render_frame_->GetWebFrame()); |
748 main_render_frame_->Initialize(); | 837 main_render_frame_->Initialize(); |
749 | 838 |
750 if (switches::IsTouchDragDropEnabled()) | 839 if (switches::IsTouchDragDropEnabled()) |
751 webview()->settings()->setTouchDragDropEnabled(true); | 840 webview()->settings()->setTouchDragDropEnabled(true); |
752 | 841 |
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2272 } | 2361 } |
2273 | 2362 |
2274 WebPreferences& RenderViewImpl::GetWebkitPreferences() { | 2363 WebPreferences& RenderViewImpl::GetWebkitPreferences() { |
2275 return webkit_preferences_; | 2364 return webkit_preferences_; |
2276 } | 2365 } |
2277 | 2366 |
2278 void RenderViewImpl::SetWebkitPreferences(const WebPreferences& preferences) { | 2367 void RenderViewImpl::SetWebkitPreferences(const WebPreferences& preferences) { |
2279 OnUpdateWebPreferences(preferences); | 2368 OnUpdateWebPreferences(preferences); |
2280 } | 2369 } |
2281 | 2370 |
| 2371 void RenderViewImpl::ApplyWebPreferences(const WebPreferences& prefs) { |
| 2372 WebSettings* settings = webview()->settings(); |
| 2373 ApplyFontsFromMap(prefs.standard_font_family_map, |
| 2374 SetStandardFontFamilyWrapper, settings); |
| 2375 ApplyFontsFromMap(prefs.fixed_font_family_map, |
| 2376 SetFixedFontFamilyWrapper, settings); |
| 2377 ApplyFontsFromMap(prefs.serif_font_family_map, |
| 2378 SetSerifFontFamilyWrapper, settings); |
| 2379 ApplyFontsFromMap(prefs.sans_serif_font_family_map, |
| 2380 SetSansSerifFontFamilyWrapper, settings); |
| 2381 ApplyFontsFromMap(prefs.cursive_font_family_map, |
| 2382 SetCursiveFontFamilyWrapper, settings); |
| 2383 ApplyFontsFromMap(prefs.fantasy_font_family_map, |
| 2384 SetFantasyFontFamilyWrapper, settings); |
| 2385 ApplyFontsFromMap(prefs.pictograph_font_family_map, |
| 2386 SetPictographFontFamilyWrapper, settings); |
| 2387 settings->setDefaultFontSize(prefs.default_font_size); |
| 2388 settings->setDefaultFixedFontSize(prefs.default_fixed_font_size); |
| 2389 settings->setMinimumFontSize(prefs.minimum_font_size); |
| 2390 settings->setMinimumLogicalFontSize(prefs.minimum_logical_font_size); |
| 2391 settings->setDefaultTextEncodingName( |
| 2392 base::ASCIIToUTF16(prefs.default_encoding)); |
| 2393 settings->setJavaScriptEnabled(prefs.javascript_enabled); |
| 2394 settings->setWebSecurityEnabled(prefs.web_security_enabled); |
| 2395 settings->setJavaScriptCanOpenWindowsAutomatically( |
| 2396 prefs.javascript_can_open_windows_automatically); |
| 2397 settings->setLoadsImagesAutomatically(prefs.loads_images_automatically); |
| 2398 settings->setImagesEnabled(prefs.images_enabled); |
| 2399 settings->setPluginsEnabled(prefs.plugins_enabled); |
| 2400 settings->setDOMPasteAllowed(prefs.dom_paste_enabled); |
| 2401 settings->setNeedsSiteSpecificQuirks(prefs.site_specific_quirks_enabled); |
| 2402 settings->setShrinksStandaloneImagesToFit( |
| 2403 prefs.shrinks_standalone_images_to_fit); |
| 2404 settings->setUsesEncodingDetector(prefs.uses_universal_detector); |
| 2405 settings->setTextAreasAreResizable(prefs.text_areas_are_resizable); |
| 2406 settings->setAllowScriptsToCloseWindows(prefs.allow_scripts_to_close_windows); |
| 2407 settings->setDownloadableBinaryFontsEnabled(prefs.remote_fonts_enabled); |
| 2408 settings->setJavaScriptCanAccessClipboard( |
| 2409 prefs.javascript_can_access_clipboard); |
| 2410 WebRuntimeFeatures::enableXSLT(prefs.xslt_enabled); |
| 2411 settings->setXSSAuditorEnabled(prefs.xss_auditor_enabled); |
| 2412 settings->setDNSPrefetchingEnabled(prefs.dns_prefetching_enabled); |
| 2413 settings->setLocalStorageEnabled(prefs.local_storage_enabled); |
| 2414 settings->setSyncXHRInDocumentsEnabled(prefs.sync_xhr_in_documents_enabled); |
| 2415 WebRuntimeFeatures::enableDatabase(prefs.databases_enabled); |
| 2416 settings->setOfflineWebApplicationCacheEnabled( |
| 2417 prefs.application_cache_enabled); |
| 2418 settings->setCaretBrowsingEnabled(prefs.caret_browsing_enabled); |
| 2419 settings->setHyperlinkAuditingEnabled(prefs.hyperlink_auditing_enabled); |
| 2420 settings->setCookieEnabled(prefs.cookie_enabled); |
| 2421 settings->setNavigateOnDragDrop(prefs.navigate_on_drag_drop); |
| 2422 |
| 2423 settings->setJavaEnabled(prefs.java_enabled); |
| 2424 |
| 2425 // By default, allow_universal_access_from_file_urls is set to false and thus |
| 2426 // we mitigate attacks from local HTML files by not granting file:// URLs |
| 2427 // universal access. Only test shell will enable this. |
| 2428 settings->setAllowUniversalAccessFromFileURLs( |
| 2429 prefs.allow_universal_access_from_file_urls); |
| 2430 settings->setAllowFileAccessFromFileURLs( |
| 2431 prefs.allow_file_access_from_file_urls); |
| 2432 |
| 2433 // Enable the web audio API if requested on the command line. |
| 2434 settings->setWebAudioEnabled(prefs.webaudio_enabled); |
| 2435 |
| 2436 // Enable experimental WebGL support if requested on command line |
| 2437 // and support is compiled in. |
| 2438 settings->setExperimentalWebGLEnabled(prefs.experimental_webgl_enabled); |
| 2439 |
| 2440 // Disable GL multisampling if requested on command line. |
| 2441 settings->setOpenGLMultisamplingEnabled(prefs.gl_multisampling_enabled); |
| 2442 |
| 2443 // Enable WebGL errors to the JS console if requested. |
| 2444 settings->setWebGLErrorsToConsoleEnabled( |
| 2445 prefs.webgl_errors_to_console_enabled); |
| 2446 |
| 2447 // Uses the mock theme engine for scrollbars. |
| 2448 settings->setMockScrollbarsEnabled(prefs.mock_scrollbars_enabled); |
| 2449 |
| 2450 settings->setLayerSquashingEnabled(prefs.layer_squashing_enabled); |
| 2451 |
| 2452 // Enable gpu-accelerated compositing always. |
| 2453 settings->setAcceleratedCompositingEnabled(true); |
| 2454 |
| 2455 // Enable gpu-accelerated 2d canvas if requested on the command line. |
| 2456 settings->setAccelerated2dCanvasEnabled(prefs.accelerated_2d_canvas_enabled); |
| 2457 |
| 2458 settings->setMinimumAccelerated2dCanvasSize( |
| 2459 prefs.minimum_accelerated_2d_canvas_size); |
| 2460 |
| 2461 // Disable antialiasing for 2d canvas if requested on the command line. |
| 2462 settings->setAntialiased2dCanvasEnabled( |
| 2463 !prefs.antialiased_2d_canvas_disabled); |
| 2464 |
| 2465 // Set MSAA sample count for 2d canvas if requested on the command line (or |
| 2466 // default value if not). |
| 2467 settings->setAccelerated2dCanvasMSAASampleCount( |
| 2468 prefs.accelerated_2d_canvas_msaa_sample_count); |
| 2469 |
| 2470 // Enable deferred filter rendering if requested on the command line. |
| 2471 settings->setDeferredFiltersEnabled(prefs.deferred_filters_enabled); |
| 2472 |
| 2473 // Enable container culling if requested on the command line. |
| 2474 settings->setContainerCullingEnabled(prefs.container_culling_enabled); |
| 2475 |
| 2476 // Enable gesture tap highlight if requested on the command line. |
| 2477 settings->setGestureTapHighlightEnabled(prefs.gesture_tap_highlight_enabled); |
| 2478 |
| 2479 // Enabling accelerated layers from the command line enabled accelerated |
| 2480 // Video. |
| 2481 settings->setAcceleratedCompositingForVideoEnabled( |
| 2482 prefs.accelerated_compositing_for_video_enabled); |
| 2483 |
| 2484 // WebGL and accelerated 2D canvas are always gpu composited. |
| 2485 settings->setAcceleratedCompositingForCanvasEnabled( |
| 2486 prefs.experimental_webgl_enabled || prefs.accelerated_2d_canvas_enabled); |
| 2487 |
| 2488 settings->setAsynchronousSpellCheckingEnabled( |
| 2489 prefs.asynchronous_spell_checking_enabled); |
| 2490 settings->setUnifiedTextCheckerEnabled(prefs.unified_textchecker_enabled); |
| 2491 |
| 2492 for (WebInspectorPreferences::const_iterator it = |
| 2493 prefs.inspector_settings.begin(); |
| 2494 it != prefs.inspector_settings.end(); |
| 2495 ++it) { |
| 2496 webview()->setInspectorSetting(WebString::fromUTF8(it->first), |
| 2497 WebString::fromUTF8(it->second)); |
| 2498 } |
| 2499 |
| 2500 // Tabs to link is not part of the settings. WebCore calls |
| 2501 // ChromeClient::tabsToLinks which is part of the glue code. |
| 2502 webview()->setTabsToLinks(prefs.tabs_to_links); |
| 2503 |
| 2504 settings->setAllowDisplayOfInsecureContent( |
| 2505 prefs.allow_displaying_insecure_content); |
| 2506 settings->setAllowRunningOfInsecureContent( |
| 2507 prefs.allow_running_insecure_content); |
| 2508 settings->setPasswordEchoEnabled(prefs.password_echo_enabled); |
| 2509 settings->setShouldPrintBackgrounds(prefs.should_print_backgrounds); |
| 2510 settings->setShouldClearDocumentBackground( |
| 2511 prefs.should_clear_document_background); |
| 2512 settings->setEnableScrollAnimator(prefs.enable_scroll_animator); |
| 2513 |
| 2514 settings->setRegionBasedColumnsEnabled(prefs.region_based_columns_enabled); |
| 2515 |
| 2516 WebRuntimeFeatures::enableTouch(prefs.touch_enabled); |
| 2517 settings->setMaxTouchPoints(prefs.pointer_events_max_touch_points); |
| 2518 settings->setDeviceSupportsTouch(prefs.device_supports_touch); |
| 2519 settings->setDeviceSupportsMouse(prefs.device_supports_mouse); |
| 2520 settings->setEnableTouchAdjustment(prefs.touch_adjustment_enabled); |
| 2521 |
| 2522 settings->setDeferredImageDecodingEnabled( |
| 2523 prefs.deferred_image_decoding_enabled); |
| 2524 settings->setShouldRespectImageOrientation( |
| 2525 prefs.should_respect_image_orientation); |
| 2526 |
| 2527 settings->setUnsafePluginPastingEnabled(false); |
| 2528 settings->setEditingBehavior( |
| 2529 static_cast<WebSettings::EditingBehavior>(prefs.editing_behavior)); |
| 2530 |
| 2531 settings->setSupportsMultipleWindows(prefs.supports_multiple_windows); |
| 2532 |
| 2533 settings->setViewportEnabled(prefs.viewport_enabled); |
| 2534 settings->setLoadWithOverviewMode(prefs.initialize_at_minimum_page_scale); |
| 2535 settings->setViewportMetaEnabled(prefs.viewport_meta_enabled); |
| 2536 settings->setMainFrameResizesAreOrientationChanges( |
| 2537 prefs.main_frame_resizes_are_orientation_changes); |
| 2538 |
| 2539 settings->setSmartInsertDeleteEnabled(prefs.smart_insert_delete_enabled); |
| 2540 |
| 2541 settings->setSpatialNavigationEnabled(prefs.spatial_navigation_enabled); |
| 2542 |
| 2543 settings->setSelectionIncludesAltImageText(true); |
| 2544 |
| 2545 #if defined(OS_ANDROID) |
| 2546 settings->setAllowCustomScrollbarInMainFrame(false); |
| 2547 settings->setTextAutosizingEnabled(prefs.text_autosizing_enabled); |
| 2548 settings->setAccessibilityFontScaleFactor(prefs.font_scale_factor); |
| 2549 settings->setDeviceScaleAdjustment(prefs.device_scale_adjustment); |
| 2550 webview()->setIgnoreViewportTagScaleLimits(prefs.force_enable_zoom); |
| 2551 settings->setAutoZoomFocusedNodeToLegibleScale(true); |
| 2552 settings->setDoubleTapToZoomEnabled(prefs.double_tap_to_zoom_enabled); |
| 2553 settings->setMediaControlsOverlayPlayButtonEnabled(true); |
| 2554 settings->setMediaPlaybackRequiresUserGesture( |
| 2555 prefs.user_gesture_required_for_media_playback); |
| 2556 settings->setDefaultVideoPosterURL( |
| 2557 base::ASCIIToUTF16(prefs.default_video_poster_url.spec())); |
| 2558 settings->setSupportDeprecatedTargetDensityDPI( |
| 2559 prefs.support_deprecated_target_density_dpi); |
| 2560 settings->setUseLegacyBackgroundSizeShorthandBehavior( |
| 2561 prefs.use_legacy_background_size_shorthand_behavior); |
| 2562 settings->setWideViewportQuirkEnabled(prefs.wide_viewport_quirk); |
| 2563 settings->setUseWideViewport(prefs.use_wide_viewport); |
| 2564 settings->setViewportMetaLayoutSizeQuirk( |
| 2565 prefs.viewport_meta_layout_size_quirk); |
| 2566 settings->setViewportMetaMergeContentQuirk( |
| 2567 prefs.viewport_meta_merge_content_quirk); |
| 2568 settings->setViewportMetaNonUserScalableQuirk( |
| 2569 prefs.viewport_meta_non_user_scalable_quirk); |
| 2570 settings->setViewportMetaZeroValuesQuirk( |
| 2571 prefs.viewport_meta_zero_values_quirk); |
| 2572 settings->setClobberUserAgentInitialScaleQuirk( |
| 2573 prefs.clobber_user_agent_initial_scale_quirk); |
| 2574 settings->setIgnoreMainFrameOverflowHiddenQuirk( |
| 2575 prefs.ignore_main_frame_overflow_hidden_quirk); |
| 2576 settings->setReportScreenSizeInPhysicalPixelsQuirk( |
| 2577 prefs.report_screen_size_in_physical_pixels_quirk); |
| 2578 settings->setMainFrameClipsContent(false); |
| 2579 settings->setShrinksStandaloneImagesToFit(false); |
| 2580 settings->setShrinksViewportContentToFit(true); |
| 2581 #endif |
| 2582 |
| 2583 WebNetworkStateNotifier::setOnLine(prefs.is_online); |
| 2584 WebNetworkStateNotifier::setWebConnectionType( |
| 2585 NetConnectionTypeToWebConnectionType(prefs.connection_type)); |
| 2586 settings->setPinchVirtualViewportEnabled( |
| 2587 prefs.pinch_virtual_viewport_enabled); |
| 2588 |
| 2589 settings->setPinchOverlayScrollbarThickness( |
| 2590 prefs.pinch_overlay_scrollbar_thickness); |
| 2591 settings->setUseSolidColorScrollbars(prefs.use_solid_color_scrollbars); |
| 2592 settings->setCompositorTouchHitTesting(prefs.compositor_touch_hit_testing); |
| 2593 } |
| 2594 |
2282 blink::WebView* RenderViewImpl::GetWebView() { | 2595 blink::WebView* RenderViewImpl::GetWebView() { |
2283 return webview(); | 2596 return webview(); |
2284 } | 2597 } |
2285 | 2598 |
2286 blink::WebElement RenderViewImpl::GetFocusedElement() const { | 2599 blink::WebElement RenderViewImpl::GetFocusedElement() const { |
2287 if (!webview()) | 2600 if (!webview()) |
2288 return WebElement(); | 2601 return WebElement(); |
2289 WebFrame* focused_frame = webview()->focusedFrame(); | 2602 WebFrame* focused_frame = webview()->focusedFrame(); |
2290 if (focused_frame) { | 2603 if (focused_frame) { |
2291 WebDocument doc = focused_frame->document(); | 2604 WebDocument doc = focused_frame->document(); |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2735 WebDragOperation op) { | 3048 WebDragOperation op) { |
2736 webview()->dragSourceEndedAt(client_point, screen_point, op); | 3049 webview()->dragSourceEndedAt(client_point, screen_point, op); |
2737 } | 3050 } |
2738 | 3051 |
2739 void RenderViewImpl::OnDragSourceSystemDragEnded() { | 3052 void RenderViewImpl::OnDragSourceSystemDragEnded() { |
2740 webview()->dragSourceSystemDragEnded(); | 3053 webview()->dragSourceSystemDragEnded(); |
2741 } | 3054 } |
2742 | 3055 |
2743 void RenderViewImpl::OnUpdateWebPreferences(const WebPreferences& prefs) { | 3056 void RenderViewImpl::OnUpdateWebPreferences(const WebPreferences& prefs) { |
2744 webkit_preferences_ = prefs; | 3057 webkit_preferences_ = prefs; |
2745 ApplyWebPreferences(webkit_preferences_, webview()); | 3058 ApplyWebPreferences(webkit_preferences_); |
2746 } | 3059 } |
2747 | 3060 |
2748 void RenderViewImpl::OnEnumerateDirectoryResponse( | 3061 void RenderViewImpl::OnEnumerateDirectoryResponse( |
2749 int id, | 3062 int id, |
2750 const std::vector<base::FilePath>& paths) { | 3063 const std::vector<base::FilePath>& paths) { |
2751 if (!enumeration_completions_[id]) | 3064 if (!enumeration_completions_[id]) |
2752 return; | 3065 return; |
2753 | 3066 |
2754 WebVector<WebString> ws_file_names(paths.size()); | 3067 WebVector<WebString> ws_file_names(paths.size()); |
2755 for (size_t i = 0; i < paths.size(); ++i) | 3068 for (size_t i = 0; i < paths.size(); ++i) |
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3983 std::vector<gfx::Size> sizes; | 4296 std::vector<gfx::Size> sizes; |
3984 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4297 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
3985 if (!url.isEmpty()) | 4298 if (!url.isEmpty()) |
3986 urls.push_back( | 4299 urls.push_back( |
3987 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4300 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
3988 } | 4301 } |
3989 SendUpdateFaviconURL(urls); | 4302 SendUpdateFaviconURL(urls); |
3990 } | 4303 } |
3991 | 4304 |
3992 } // namespace content | 4305 } // namespace content |
OLD | NEW |