OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "content/renderer/render_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/process_util.h" | 18 #include "base/process_util.h" |
19 #include "base/string_piece.h" | 19 #include "base/string_piece.h" |
20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
21 #include "base/sys_string_conversions.h" | 21 #include "base/sys_string_conversions.h" |
22 #include "base/time.h" | 22 #include "base/time.h" |
23 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
24 #include "chrome/common/autofill_messages.h" | |
25 #include "chrome/common/bindings_policy.h" | 24 #include "chrome/common/bindings_policy.h" |
26 #include "chrome/common/child_process_logging.h" | |
27 #include "chrome/common/chrome_constants.h" | 25 #include "chrome/common/chrome_constants.h" |
28 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
29 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
30 #include "chrome/common/extensions/extension_messages.h" | |
31 #include "chrome/common/json_value_serializer.h" | |
32 #include "chrome/common/pepper_plugin_registry.h" | 28 #include "chrome/common/pepper_plugin_registry.h" |
33 #include "chrome/common/render_messages.h" | 29 #include "chrome/common/render_messages.h" |
34 #include "chrome/common/render_view_commands.h" | |
35 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
36 #include "chrome/common/web_apps.h" | |
37 #include "chrome/renderer/about_handler.h" | |
38 #include "chrome/renderer/automation/dom_automation_controller.h" | 31 #include "chrome/renderer/automation/dom_automation_controller.h" |
39 #include "chrome/renderer/external_host_bindings.h" | 32 #include "chrome/renderer/external_host_bindings.h" |
40 #include "chrome/renderer/localized_error.h" | 33 #include "chrome/renderer/localized_error.h" |
41 #include "chrome/renderer/searchbox.h" | |
42 #include "chrome/renderer/visitedlink_slave.h" | |
43 #include "content/common/appcache/appcache_dispatcher.h" | 34 #include "content/common/appcache/appcache_dispatcher.h" |
44 #include "content/common/clipboard_messages.h" | 35 #include "content/common/clipboard_messages.h" |
45 #include "content/common/content_constants.h" | 36 #include "content/common/content_constants.h" |
46 #include "content/common/database_messages.h" | 37 #include "content/common/database_messages.h" |
47 #include "content/common/drag_messages.h" | 38 #include "content/common/drag_messages.h" |
48 #include "content/common/file_system/file_system_dispatcher.h" | 39 #include "content/common/file_system/file_system_dispatcher.h" |
49 #include "content/common/file_system/webfilesystem_callback_dispatcher.h" | 40 #include "content/common/file_system/webfilesystem_callback_dispatcher.h" |
50 #include "content/common/notification_service.h" | 41 #include "content/common/notification_service.h" |
51 #include "content/common/pepper_messages.h" | 42 #include "content/common/pepper_messages.h" |
52 #include "content/common/quota_dispatcher.h" | 43 #include "content/common/quota_dispatcher.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 #include "webkit/glue/alt_error_page_resource_fetcher.h" | 131 #include "webkit/glue/alt_error_page_resource_fetcher.h" |
141 #include "webkit/glue/context_menu.h" | 132 #include "webkit/glue/context_menu.h" |
142 #include "webkit/glue/dom_operations.h" | 133 #include "webkit/glue/dom_operations.h" |
143 #include "webkit/glue/form_data.h" | 134 #include "webkit/glue/form_data.h" |
144 #include "webkit/glue/form_field.h" | 135 #include "webkit/glue/form_field.h" |
145 #include "webkit/glue/glue_serialize.h" | 136 #include "webkit/glue/glue_serialize.h" |
146 #include "webkit/glue/image_decoder.h" | 137 #include "webkit/glue/image_decoder.h" |
147 #include "webkit/glue/image_resource_fetcher.h" | 138 #include "webkit/glue/image_resource_fetcher.h" |
148 #include "webkit/glue/media/video_renderer_impl.h" | 139 #include "webkit/glue/media/video_renderer_impl.h" |
149 #include "webkit/glue/password_form_dom_manager.h" | 140 #include "webkit/glue/password_form_dom_manager.h" |
150 #include "webkit/glue/resource_fetcher.h" | |
151 #include "webkit/glue/site_isolation_metrics.h" | 141 #include "webkit/glue/site_isolation_metrics.h" |
152 #include "webkit/glue/webaccessibility.h" | 142 #include "webkit/glue/webaccessibility.h" |
153 #include "webkit/glue/webdropdata.h" | 143 #include "webkit/glue/webdropdata.h" |
154 #include "webkit/glue/webkit_constants.h" | 144 #include "webkit/glue/webkit_constants.h" |
155 #include "webkit/glue/webkit_glue.h" | 145 #include "webkit/glue/webkit_glue.h" |
156 #include "webkit/glue/webmediaplayer_impl.h" | 146 #include "webkit/glue/webmediaplayer_impl.h" |
157 #include "webkit/plugins/npapi/default_plugin_shared.h" | 147 #include "webkit/plugins/npapi/default_plugin_shared.h" |
158 #include "webkit/plugins/npapi/plugin_list.h" | 148 #include "webkit/plugins/npapi/plugin_list.h" |
159 #include "webkit/plugins/npapi/webplugin_delegate.h" | 149 #include "webkit/plugins/npapi/webplugin_delegate.h" |
160 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 150 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 for (size_t i = 0; i < arraysize(kDirProtocols); ++i) { | 291 for (size_t i = 0; i < arraysize(kDirProtocols); ++i) { |
302 if (EqualsASCII(origin.protocol(), kDirProtocols[i])) { | 292 if (EqualsASCII(origin.protocol(), kDirProtocols[i])) { |
303 return frame_url.SchemeIs(kDirProtocols[i]) && | 293 return frame_url.SchemeIs(kDirProtocols[i]) && |
304 frame_url.ExtractFileName().empty(); | 294 frame_url.ExtractFileName().empty(); |
305 } | 295 } |
306 } | 296 } |
307 | 297 |
308 return false; | 298 return false; |
309 } | 299 } |
310 | 300 |
311 // Returns true if the parameter node is a textfield, text area or a content | |
312 // editable div. | |
313 static bool IsEditableNode(const WebNode& node) { | |
314 bool is_editable_node = false; | |
315 if (!node.isNull()) { | |
316 if (node.isContentEditable()) { | |
317 is_editable_node = true; | |
318 } else if (node.isElementNode()) { | |
319 is_editable_node = | |
320 node.toConst<WebElement>().isTextFormControlElement(); | |
321 } | |
322 } | |
323 return is_editable_node; | |
324 } | |
325 | |
326 static bool WebAccessibilityNotificationToViewHostMsg( | 301 static bool WebAccessibilityNotificationToViewHostMsg( |
327 WebAccessibilityNotification notification, | 302 WebAccessibilityNotification notification, |
328 ViewHostMsg_AccessibilityNotification_Type::Value* type) { | 303 ViewHostMsg_AccessibilityNotification_Type::Value* type) { |
329 switch (notification) { | 304 switch (notification) { |
330 case WebKit::WebAccessibilityNotificationCheckedStateChanged: | 305 case WebKit::WebAccessibilityNotificationCheckedStateChanged: |
331 *type = ViewHostMsg_AccessibilityNotification_Type:: | 306 *type = ViewHostMsg_AccessibilityNotification_Type:: |
332 NOTIFICATION_TYPE_CHECK_STATE_CHANGED; | 307 NOTIFICATION_TYPE_CHECK_STATE_CHANGED; |
333 break; | 308 break; |
334 case WebKit::WebAccessibilityNotificationChildrenChanged: | 309 case WebKit::WebAccessibilityNotificationChildrenChanged: |
335 *type = ViewHostMsg_AccessibilityNotification_Type:: | 310 *type = ViewHostMsg_AccessibilityNotification_Type:: |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 view_type_(ViewType::INVALID), | 409 view_type_(ViewType::INVALID), |
435 browser_window_id_(-1), | 410 browser_window_id_(-1), |
436 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), | 411 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), |
437 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), | 412 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), |
438 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), | 413 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
439 geolocation_dispatcher_(NULL), | 414 geolocation_dispatcher_(NULL), |
440 speech_input_dispatcher_(NULL), | 415 speech_input_dispatcher_(NULL), |
441 device_orientation_dispatcher_(NULL), | 416 device_orientation_dispatcher_(NULL), |
442 accessibility_ack_pending_(false), | 417 accessibility_ack_pending_(false), |
443 p2p_socket_dispatcher_(NULL), | 418 p2p_socket_dispatcher_(NULL), |
444 pending_app_icon_requests_(0), | |
445 session_storage_namespace_id_(session_storage_namespace_id) { | 419 session_storage_namespace_id_(session_storage_namespace_id) { |
446 | 420 |
447 ClearBlockedContentSettings(); | 421 ClearBlockedContentSettings(); |
448 | 422 |
449 routing_id_ = routing_id; | 423 routing_id_ = routing_id; |
450 if (opener_id != MSG_ROUTING_NONE) | 424 if (opener_id != MSG_ROUTING_NONE) |
451 opener_id_ = opener_id; | 425 opener_id_ = opener_id; |
452 | 426 |
453 webwidget_ = WebView::create(this); | 427 webwidget_ = WebView::create(this); |
454 | 428 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 } | 583 } |
610 | 584 |
611 WebKit::WebView* RenderView::webview() const { | 585 WebKit::WebView* RenderView::webview() const { |
612 return static_cast<WebKit::WebView*>(webwidget()); | 586 return static_cast<WebKit::WebView*>(webwidget()); |
613 } | 587 } |
614 | 588 |
615 void RenderView::UserMetricsRecordAction(const std::string& action) { | 589 void RenderView::UserMetricsRecordAction(const std::string& action) { |
616 Send(new ViewHostMsg_UserMetricsRecordAction(action)); | 590 Send(new ViewHostMsg_UserMetricsRecordAction(action)); |
617 } | 591 } |
618 | 592 |
619 bool RenderView::InstallWebApplicationUsingDefinitionFile(WebFrame* frame, | |
620 string16* error) { | |
621 // There is an issue of drive-by installs with the below implementation. A web | |
622 // site could force a user to install an app by timing the dialog to come up | |
623 // just before the user clicks. | |
624 // | |
625 // We do show a success UI that allows users to uninstall, but it seems that | |
626 // we might still want to put up an infobar before showing the install dialog. | |
627 // | |
628 // TODO(aa): Figure out this issue before removing the kEnableCrxlessWebApps | |
629 // switch. | |
630 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
631 switches::kEnableCrxlessWebApps)) { | |
632 *error = ASCIIToUTF16("CRX-less web apps aren't enabled."); | |
633 return false; | |
634 } | |
635 | |
636 if (frame != frame->top()) { | |
637 *error = ASCIIToUTF16("Applications can only be installed from the top " | |
638 "frame."); | |
639 return false; | |
640 } | |
641 | |
642 if (pending_app_info_.get()) { | |
643 *error = ASCIIToUTF16("An application install is already in progress."); | |
644 return false; | |
645 } | |
646 | |
647 pending_app_info_.reset(new WebApplicationInfo()); | |
648 if (!web_apps::ParseWebAppFromWebDocument(frame, pending_app_info_.get(), | |
649 error)) { | |
650 return false; | |
651 } | |
652 | |
653 if (!pending_app_info_->manifest_url.is_valid()) { | |
654 *error = ASCIIToUTF16("Web application definition not found or invalid."); | |
655 return false; | |
656 } | |
657 | |
658 app_definition_fetcher_.reset(new ResourceFetcher( | |
659 pending_app_info_->manifest_url, webview()->mainFrame(), | |
660 WebURLRequest::TargetIsSubresource, | |
661 NewCallback(this, &RenderView::DidDownloadApplicationDefinition))); | |
662 return true; | |
663 } | |
664 | |
665 void RenderView::SetReportLoadProgressEnabled(bool enabled) { | 593 void RenderView::SetReportLoadProgressEnabled(bool enabled) { |
666 if (!enabled) { | 594 if (!enabled) { |
667 load_progress_tracker_.reset(NULL); | 595 load_progress_tracker_.reset(NULL); |
668 return; | 596 return; |
669 } | 597 } |
670 if (load_progress_tracker_ == NULL) | 598 if (load_progress_tracker_ == NULL) |
671 load_progress_tracker_.reset(new LoadProgressTracker(this)); | 599 load_progress_tracker_.reset(new LoadProgressTracker(this)); |
672 } | 600 } |
673 | 601 |
674 void RenderView::DidDownloadApplicationDefinition( | |
675 const WebKit::WebURLResponse& response, | |
676 const std::string& data) { | |
677 scoped_ptr<WebApplicationInfo> app_info( | |
678 pending_app_info_.release()); | |
679 | |
680 JSONStringValueSerializer serializer(data); | |
681 int error_code = 0; | |
682 std::string error_message; | |
683 scoped_ptr<Value> result(serializer.Deserialize(&error_code, &error_message)); | |
684 if (!result.get()) { | |
685 AddErrorToRootConsole(UTF8ToUTF16(error_message)); | |
686 return; | |
687 } | |
688 | |
689 string16 error_message_16; | |
690 if (!web_apps::ParseWebAppFromDefinitionFile(result.get(), app_info.get(), | |
691 &error_message_16)) { | |
692 AddErrorToRootConsole(error_message_16); | |
693 return; | |
694 } | |
695 | |
696 if (!app_info->icons.empty()) { | |
697 pending_app_info_.reset(app_info.release()); | |
698 pending_app_icon_requests_ = | |
699 static_cast<int>(pending_app_info_->icons.size()); | |
700 for (size_t i = 0; i < pending_app_info_->icons.size(); ++i) { | |
701 app_icon_fetchers_.push_back(linked_ptr<ImageResourceFetcher>( | |
702 new ImageResourceFetcher( | |
703 pending_app_info_->icons[i].url, | |
704 webview()->mainFrame(), | |
705 static_cast<int>(i), | |
706 pending_app_info_->icons[i].width, | |
707 WebURLRequest::TargetIsFavicon, | |
708 NewCallback(this, &RenderView::DidDownloadApplicationIcon)))); | |
709 } | |
710 } else { | |
711 Send(new ExtensionHostMsg_InstallApplication(routing_id_, *app_info)); | |
712 } | |
713 } | |
714 | |
715 void RenderView::DidDownloadApplicationIcon(ImageResourceFetcher* fetcher, | |
716 const SkBitmap& image) { | |
717 pending_app_info_->icons[fetcher->id()].data = image; | |
718 | |
719 // Remove the image fetcher from our pending list. We're in the callback from | |
720 // ImageResourceFetcher, best to delay deletion. | |
721 for (ImageResourceFetcherList::iterator iter = app_icon_fetchers_.begin(); | |
722 iter != app_icon_fetchers_.end(); ++iter) { | |
723 if (iter->get() == fetcher) { | |
724 iter->release(); | |
725 app_icon_fetchers_.erase(iter); | |
726 break; | |
727 } | |
728 } | |
729 | |
730 // We're in the callback from the ImageResourceFetcher, best to delay | |
731 // deletion. | |
732 MessageLoop::current()->DeleteSoon(FROM_HERE, fetcher); | |
733 | |
734 if (--pending_app_icon_requests_ > 0) | |
735 return; | |
736 | |
737 // There is a maximum size of IPC on OS X and Linux that we have run into in | |
738 // some situations. We're not sure what it is, but our hypothesis is in the | |
739 // neighborhood of 1 MB. | |
740 // | |
741 // To be on the safe side, we give ourselves 128 KB for just the image data. | |
742 // This should be more than enough for 128, 48, and 16 px 32-bit icons. If we | |
743 // want to start allowing larger icons (see bug 63406), we'll have to either | |
744 // experiment mor ewith this and find the real limit, or else come up with | |
745 // some alternative way to transmit the icon data to the browser process. | |
746 // | |
747 // See also: bug 63729. | |
748 const size_t kMaxIconSize = 1024 * 128; | |
749 size_t actual_icon_size = 0; | |
750 for (size_t i = 0; i < pending_app_info_->icons.size(); ++i) { | |
751 size_t current_size = pending_app_info_->icons[i].data.getSize(); | |
752 if (current_size > kMaxIconSize - actual_icon_size) { | |
753 AddErrorToRootConsole(ASCIIToUTF16( | |
754 "Icons are too large. Maximum total size for app icons is 128 KB.")); | |
755 return; | |
756 } | |
757 actual_icon_size += current_size; | |
758 } | |
759 | |
760 Send(new ExtensionHostMsg_InstallApplication( | |
761 routing_id_, *pending_app_info_)); | |
762 pending_app_info_.reset(NULL); | |
763 } | |
764 | |
765 void RenderView::PluginCrashed(const FilePath& plugin_path) { | 602 void RenderView::PluginCrashed(const FilePath& plugin_path) { |
766 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); | 603 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); |
767 } | 604 } |
768 | 605 |
769 WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame, | 606 WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame, |
770 const WebPluginParams& params) { | 607 const WebPluginParams& params) { |
771 webkit::npapi::WebPluginInfo info; | 608 webkit::npapi::WebPluginInfo info; |
772 bool found; | 609 bool found; |
773 int content_setting; | 610 int content_setting; |
774 std::string mime_type; | 611 std::string mime_type; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 delegate->SetContentAreaFocus(has_focus()); | 643 delegate->SetContentAreaFocus(has_focus()); |
807 } | 644 } |
808 | 645 |
809 void RenderView::UnregisterPluginDelegate(WebPluginDelegateProxy* delegate) { | 646 void RenderView::UnregisterPluginDelegate(WebPluginDelegateProxy* delegate) { |
810 plugin_delegates_.erase(delegate); | 647 plugin_delegates_.erase(delegate); |
811 } | 648 } |
812 | 649 |
813 bool RenderView::OnMessageReceived(const IPC::Message& message) { | 650 bool RenderView::OnMessageReceived(const IPC::Message& message) { |
814 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; | 651 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
815 if (main_frame) | 652 if (main_frame) |
816 child_process_logging::SetActiveURL(main_frame->url()); | 653 content::GetContentClient()->SetActiveURL(main_frame->url()); |
817 | 654 |
818 ObserverListBase<RenderViewObserver>::Iterator it(observers_); | 655 ObserverListBase<RenderViewObserver>::Iterator it(observers_); |
819 RenderViewObserver* observer; | 656 RenderViewObserver* observer; |
820 while ((observer = it.GetNext()) != NULL) | 657 while ((observer = it.GetNext()) != NULL) |
821 if (observer->OnMessageReceived(message)) | 658 if (observer->OnMessageReceived(message)) |
822 return true; | 659 return true; |
823 | 660 |
824 bool handled = true; | 661 bool handled = true; |
825 IPC_BEGIN_MESSAGE_MAP(RenderView, message) | 662 IPC_BEGIN_MESSAGE_MAP(RenderView, message) |
826 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) | 663 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 OnDisplayPrerenderedPage) | 712 OnDisplayPrerenderedPage) |
876 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, | 713 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, |
877 OnEnumerateDirectoryResponse) | 714 OnEnumerateDirectoryResponse) |
878 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) | 715 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) |
879 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 716 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
880 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, | 717 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, |
881 OnGetAllSavableResourceLinksForCurrentPage) | 718 OnGetAllSavableResourceLinksForCurrentPage) |
882 IPC_MESSAGE_HANDLER( | 719 IPC_MESSAGE_HANDLER( |
883 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, | 720 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
884 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) | 721 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
885 IPC_MESSAGE_HANDLER(ExtensionMsg_GetApplicationInfo, OnGetApplicationInfo) | |
886 IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnShouldClose) | 722 IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnShouldClose) |
887 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) | 723 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
888 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) | 724 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) |
889 IPC_MESSAGE_HANDLER(ViewMsg_HandleMessageFromExternalHost, | 725 IPC_MESSAGE_HANDLER(ViewMsg_HandleMessageFromExternalHost, |
890 OnHandleMessageFromExternalHost) | 726 OnHandleMessageFromExternalHost) |
891 IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount, | 727 IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount, |
892 OnDisassociateFromPopupCount) | 728 OnDisassociateFromPopupCount) |
893 IPC_MESSAGE_HANDLER(ViewMsg_AllowScriptToClose, | 729 IPC_MESSAGE_HANDLER(ViewMsg_AllowScriptToClose, |
894 OnAllowScriptToClose) | 730 OnAllowScriptToClose) |
895 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) | 731 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 return handled; | 779 return handled; |
944 } | 780 } |
945 | 781 |
946 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { | 782 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { |
947 if (!webview()) | 783 if (!webview()) |
948 return; | 784 return; |
949 | 785 |
950 history_list_offset_ = params.current_history_list_offset; | 786 history_list_offset_ = params.current_history_list_offset; |
951 history_list_length_ = params.current_history_list_length; | 787 history_list_length_ = params.current_history_list_length; |
952 | 788 |
953 child_process_logging::SetActiveURL(params.url); | 789 content::GetContentClient()->SetActiveURL(params.url); |
954 | |
955 AboutHandler::MaybeHandle(params.url); | |
956 | 790 |
957 bool is_reload = | 791 bool is_reload = |
958 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || | 792 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || |
959 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; | 793 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; |
960 | 794 |
961 WebFrame* main_frame = webview()->mainFrame(); | 795 WebFrame* main_frame = webview()->mainFrame(); |
962 if (is_reload && main_frame->currentHistoryItem().isNull()) { | 796 if (is_reload && main_frame->currentHistoryItem().isNull()) { |
963 // We cannot reload if we do not have any history state. This happens, for | 797 // We cannot reload if we do not have any history state. This happens, for |
964 // example, when recovering from a crash. Our workaround here is a bit of | 798 // example, when recovering from a crash. Our workaround here is a bit of |
965 // a hack since it means that reload after a crashed tab does not cause an | 799 // a hack since it means that reload after a crashed tab does not cause an |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1975 // any existing pending sends. | 1809 // any existing pending sends. |
1976 pending_target_url_ = latest_url; | 1810 pending_target_url_ = latest_url; |
1977 target_url_status_ = TARGET_PENDING; | 1811 target_url_status_ = TARGET_PENDING; |
1978 } else { | 1812 } else { |
1979 Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, latest_url)); | 1813 Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, latest_url)); |
1980 target_url_ = latest_url; | 1814 target_url_ = latest_url; |
1981 target_url_status_ = TARGET_INFLIGHT; | 1815 target_url_status_ = TARGET_INFLIGHT; |
1982 } | 1816 } |
1983 } | 1817 } |
1984 | 1818 |
1985 void RenderView::UpdateToggleSpellCheckCommandState() { | |
1986 bool is_enabled = false; | |
1987 WebKit::WebNode node = GetFocusedNode(); | |
1988 if (!node.isNull()) | |
1989 is_enabled = IsEditableNode(node); | |
1990 | |
1991 RenderViewCommandCheckedState checked_state = | |
1992 RENDER_VIEW_COMMAND_CHECKED_STATE_UNCHECKED; | |
1993 if (is_enabled && webview()) { | |
1994 WebFrame* frame = webview()->focusedFrame(); | |
1995 if (frame->isContinuousSpellCheckingEnabled()) | |
1996 checked_state = RENDER_VIEW_COMMAND_CHECKED_STATE_CHECKED; | |
1997 } | |
1998 | |
1999 Send(new ViewHostMsg_CommandStateChanged( | |
2000 routing_id_, | |
2001 RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK, | |
2002 is_enabled, | |
2003 checked_state)); | |
2004 } | |
2005 | |
2006 void RenderView::StartNavStateSyncTimerIfNecessary() { | 1819 void RenderView::StartNavStateSyncTimerIfNecessary() { |
2007 int delay; | 1820 int delay; |
2008 if (send_content_state_immediately_) | 1821 if (send_content_state_immediately_) |
2009 delay = 0; | 1822 delay = 0; |
2010 else if (is_hidden()) | 1823 else if (is_hidden()) |
2011 delay = kDelaySecondsForContentStateSyncHidden; | 1824 delay = kDelaySecondsForContentStateSyncHidden; |
2012 else | 1825 else |
2013 delay = kDelaySecondsForContentStateSync; | 1826 delay = kDelaySecondsForContentStateSync; |
2014 | 1827 |
2015 if (nav_state_sync_timer_.IsRunning()) { | 1828 if (nav_state_sync_timer_.IsRunning()) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2073 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); | 1886 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); |
2074 | 1887 |
2075 if (WebAccessibilityCache::accessibilityEnabled() && node.isNull()) { | 1888 if (WebAccessibilityCache::accessibilityEnabled() && node.isNull()) { |
2076 // TODO(ctguil): Make WebKit send this notification. | 1889 // TODO(ctguil): Make WebKit send this notification. |
2077 // When focus is cleared notify accessibility that the document is focused. | 1890 // When focus is cleared notify accessibility that the document is focused. |
2078 postAccessibilityNotification( | 1891 postAccessibilityNotification( |
2079 webview()->accessibilityObject(), | 1892 webview()->accessibilityObject(), |
2080 WebKit::WebAccessibilityNotificationFocusedUIElementChanged); | 1893 WebKit::WebAccessibilityNotificationFocusedUIElementChanged); |
2081 } | 1894 } |
2082 | 1895 |
2083 UpdateToggleSpellCheckCommandState(); | 1896 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); |
2084 } | 1897 } |
2085 | 1898 |
2086 void RenderView::navigateBackForwardSoon(int offset) { | 1899 void RenderView::navigateBackForwardSoon(int offset) { |
2087 Send(new ViewHostMsg_GoToEntryAtOffset(routing_id_, offset)); | 1900 Send(new ViewHostMsg_GoToEntryAtOffset(routing_id_, offset)); |
2088 } | 1901 } |
2089 | 1902 |
2090 int RenderView::historyBackListCount() { | 1903 int RenderView::historyBackListCount() { |
2091 return history_list_offset_ < 0 ? 0 : history_list_offset_; | 1904 return history_list_offset_ < 0 ? 0 : history_list_offset_; |
2092 } | 1905 } |
2093 | 1906 |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2547 | 2360 |
2548 void RenderView::didCompleteClientRedirect( | 2361 void RenderView::didCompleteClientRedirect( |
2549 WebFrame* frame, const WebURL& from) { | 2362 WebFrame* frame, const WebURL& from) { |
2550 if (!frame->parent()) | 2363 if (!frame->parent()) |
2551 completed_client_redirect_src_ = from; | 2364 completed_client_redirect_src_ = from; |
2552 FOR_EACH_OBSERVER( | 2365 FOR_EACH_OBSERVER( |
2553 RenderViewObserver, observers_, DidCompleteClientRedirect(frame, from)); | 2366 RenderViewObserver, observers_, DidCompleteClientRedirect(frame, from)); |
2554 } | 2367 } |
2555 | 2368 |
2556 void RenderView::didCreateDataSource(WebFrame* frame, WebDataSource* ds) { | 2369 void RenderView::didCreateDataSource(WebFrame* frame, WebDataSource* ds) { |
2557 // If there are any app-related fetches in progress, they can be cancelled now | |
2558 // since we have navigated away from the page that created them. | |
2559 if (!frame->parent()) { | |
2560 app_icon_fetchers_.clear(); | |
2561 app_definition_fetcher_.reset(NULL); | |
2562 } | |
2563 | |
2564 // The rest of RenderView assumes that a WebDataSource will always have a | 2370 // The rest of RenderView assumes that a WebDataSource will always have a |
2565 // non-null NavigationState. | 2371 // non-null NavigationState. |
2566 bool content_initiated = !pending_navigation_state_.get(); | 2372 bool content_initiated = !pending_navigation_state_.get(); |
2567 NavigationState* state = content_initiated ? | 2373 NavigationState* state = content_initiated ? |
2568 NavigationState::CreateContentInitiated() : | 2374 NavigationState::CreateContentInitiated() : |
2569 pending_navigation_state_.release(); | 2375 pending_navigation_state_.release(); |
2570 | 2376 |
2571 // NavigationState::referred_by_prefetcher_ is true if we are | 2377 // NavigationState::referred_by_prefetcher_ is true if we are |
2572 // navigating from a page that used prefetching using a link on that | 2378 // navigating from a page that used prefetching using a link on that |
2573 // page. We are early enough in the request process here that we | 2379 // page. We are early enough in the request process here that we |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3411 // Decode the favicon using WebKit's image decoder. | 3217 // Decode the favicon using WebKit's image decoder. |
3412 webkit_glue::ImageDecoder decoder(gfx::Size(kFaviconSize, kFaviconSize)); | 3218 webkit_glue::ImageDecoder decoder(gfx::Size(kFaviconSize, kFaviconSize)); |
3413 const unsigned char* src_data = | 3219 const unsigned char* src_data = |
3414 reinterpret_cast<const unsigned char*>(&data[0]); | 3220 reinterpret_cast<const unsigned char*>(&data[0]); |
3415 | 3221 |
3416 return decoder.Decode(src_data, data.size()); | 3222 return decoder.Decode(src_data, data.size()); |
3417 } | 3223 } |
3418 return SkBitmap(); | 3224 return SkBitmap(); |
3419 } | 3225 } |
3420 | 3226 |
3421 void RenderView::OnGetApplicationInfo(int page_id) { | |
3422 WebApplicationInfo app_info; | |
3423 if (page_id == page_id_) { | |
3424 string16 error; | |
3425 web_apps::ParseWebAppFromWebDocument(webview()->mainFrame(), &app_info, | |
3426 &error); | |
3427 } | |
3428 | |
3429 // Prune out any data URLs in the set of icons. The browser process expects | |
3430 // any icon with a data URL to have originated from a favicon. We don't want | |
3431 // to decode arbitrary data URLs in the browser process. See | |
3432 // http://b/issue?id=1162972 | |
3433 for (size_t i = 0; i < app_info.icons.size(); ++i) { | |
3434 if (app_info.icons[i].url.SchemeIs(chrome::kDataScheme)) { | |
3435 app_info.icons.erase(app_info.icons.begin() + i); | |
3436 --i; | |
3437 } | |
3438 } | |
3439 | |
3440 Send(new ExtensionHostMsg_DidGetApplicationInfo( | |
3441 routing_id_, page_id, app_info)); | |
3442 } | |
3443 | |
3444 GURL RenderView::GetAlternateErrorPageURL(const GURL& failed_url, | 3227 GURL RenderView::GetAlternateErrorPageURL(const GURL& failed_url, |
3445 ErrorPageType error_type) { | 3228 ErrorPageType error_type) { |
3446 if (failed_url.SchemeIsSecure()) { | 3229 if (failed_url.SchemeIsSecure()) { |
3447 // If the URL that failed was secure, then the embedding web page was not | 3230 // If the URL that failed was secure, then the embedding web page was not |
3448 // expecting a network attacker to be able to manipulate its contents. As | 3231 // expecting a network attacker to be able to manipulate its contents. As |
3449 // we fetch alternate error pages over HTTP, we would be allowing a network | 3232 // we fetch alternate error pages over HTTP, we would be allowing a network |
3450 // attacker to manipulate the contents of the response if we tried to use | 3233 // attacker to manipulate the contents of the response if we tried to use |
3451 // the link doctor here. | 3234 // the link doctor here. |
3452 return GURL(); | 3235 return GURL(); |
3453 } | 3236 } |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3819 WebFrame* focused_frame = webview()->focusedFrame(); | 3602 WebFrame* focused_frame = webview()->focusedFrame(); |
3820 if (focused_frame) { | 3603 if (focused_frame) { |
3821 WebDocument doc = focused_frame->document(); | 3604 WebDocument doc = focused_frame->document(); |
3822 if (!doc.isNull()) | 3605 if (!doc.isNull()) |
3823 return doc.focusedNode(); | 3606 return doc.focusedNode(); |
3824 } | 3607 } |
3825 | 3608 |
3826 return WebNode(); | 3609 return WebNode(); |
3827 } | 3610 } |
3828 | 3611 |
| 3612 bool RenderView::IsEditableNode(const WebNode& node) { |
| 3613 bool is_editable_node = false; |
| 3614 if (!node.isNull()) { |
| 3615 if (node.isContentEditable()) { |
| 3616 is_editable_node = true; |
| 3617 } else if (node.isElementNode()) { |
| 3618 is_editable_node = |
| 3619 node.toConst<WebElement>().isTextFormControlElement(); |
| 3620 } |
| 3621 } |
| 3622 return is_editable_node; |
| 3623 } |
| 3624 |
3829 void RenderView::EvaluateScript(const string16& frame_xpath, | 3625 void RenderView::EvaluateScript(const string16& frame_xpath, |
3830 const string16& script, | 3626 const string16& script, |
3831 int id, | 3627 int id, |
3832 bool notify_result) { | 3628 bool notify_result) { |
3833 v8::Handle<v8::Value> result; | 3629 v8::Handle<v8::Value> result; |
3834 WebFrame* web_frame = GetChildFrame(UTF16ToWideHack(frame_xpath)); | 3630 WebFrame* web_frame = GetChildFrame(UTF16ToWideHack(frame_xpath)); |
3835 if (web_frame) | 3631 if (web_frame) |
3836 result = web_frame->executeScriptAndReturnValue(WebScriptSource(script)); | 3632 result = web_frame->executeScriptAndReturnValue(WebScriptSource(script)); |
3837 if (notify_result) { | 3633 if (notify_result) { |
3838 ListValue list; | 3634 ListValue list; |
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4788 // If you hit this please file a bug against jcivelli and include the page | 4584 // If you hit this please file a bug against jcivelli and include the page |
4789 // and steps to repro. | 4585 // and steps to repro. |
4790 NOTREACHED(); | 4586 NOTREACHED(); |
4791 return; | 4587 return; |
4792 } | 4588 } |
4793 external_popup_menu_->DidSelectItem(selected_index); | 4589 external_popup_menu_->DidSelectItem(selected_index); |
4794 external_popup_menu_.reset(); | 4590 external_popup_menu_.reset(); |
4795 } | 4591 } |
4796 #endif | 4592 #endif |
4797 | 4593 |
4798 void RenderView::AddErrorToRootConsole(const string16& message) { | |
4799 if (webview() && webview()->mainFrame()) { | |
4800 webview()->mainFrame()->addMessageToConsole( | |
4801 WebConsoleMessage(WebConsoleMessage::LevelError, message)); | |
4802 } | |
4803 } | |
4804 | |
4805 #if defined(ENABLE_FLAPPER_HACKS) | 4594 #if defined(ENABLE_FLAPPER_HACKS) |
4806 void RenderView::OnConnectTcpACK( | 4595 void RenderView::OnConnectTcpACK( |
4807 int request_id, | 4596 int request_id, |
4808 IPC::PlatformFileForTransit socket_for_transit, | 4597 IPC::PlatformFileForTransit socket_for_transit, |
4809 const PP_Flash_NetAddress& local_addr, | 4598 const PP_Flash_NetAddress& local_addr, |
4810 const PP_Flash_NetAddress& remote_addr) { | 4599 const PP_Flash_NetAddress& remote_addr) { |
4811 pepper_delegate_.OnConnectTcpACK( | 4600 pepper_delegate_.OnConnectTcpACK( |
4812 request_id, | 4601 request_id, |
4813 IPC::PlatformFileForTransitToPlatformFile(socket_for_transit), | 4602 IPC::PlatformFileForTransitToPlatformFile(socket_for_transit), |
4814 local_addr, | 4603 local_addr, |
(...skipping 13 matching lines...) Expand all Loading... |
4828 const webkit_glue::CustomContextMenuContext& custom_context) { | 4617 const webkit_glue::CustomContextMenuContext& custom_context) { |
4829 if (custom_context.is_pepper_menu) | 4618 if (custom_context.is_pepper_menu) |
4830 pepper_delegate_.OnContextMenuClosed(custom_context); | 4619 pepper_delegate_.OnContextMenuClosed(custom_context); |
4831 else | 4620 else |
4832 context_menu_node_.reset(); | 4621 context_menu_node_.reset(); |
4833 } | 4622 } |
4834 | 4623 |
4835 void RenderView::OnNetworkStateChanged(bool online) { | 4624 void RenderView::OnNetworkStateChanged(bool online) { |
4836 WebNetworkStateNotifier::setOnLine(online); | 4625 WebNetworkStateNotifier::setOnLine(online); |
4837 } | 4626 } |
OLD | NEW |