| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 #include "gfx/native_widget_types.h" | 67 #include "gfx/native_widget_types.h" |
| 68 #include "grit/generated_resources.h" | 68 #include "grit/generated_resources.h" |
| 69 #include "grit/renderer_resources.h" | 69 #include "grit/renderer_resources.h" |
| 70 #include "net/base/data_url.h" | 70 #include "net/base/data_url.h" |
| 71 #include "net/base/escape.h" | 71 #include "net/base/escape.h" |
| 72 #include "net/base/net_errors.h" | 72 #include "net/base/net_errors.h" |
| 73 #include "skia/ext/bitmap_platform_device.h" | 73 #include "skia/ext/bitmap_platform_device.h" |
| 74 #include "skia/ext/image_operations.h" | 74 #include "skia/ext/image_operations.h" |
| 75 #include "third_party/cld/encodings/compact_lang_det/win/cld_unicodetext.h" | 75 #include "third_party/cld/encodings/compact_lang_det/win/cld_unicodetext.h" |
| 76 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityCache.h" | 76 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityCache.h" |
| 77 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h" |
| 77 #include "third_party/WebKit/WebKit/chromium/public/WebCString.h" | 78 #include "third_party/WebKit/WebKit/chromium/public/WebCString.h" |
| 78 #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h" | 79 #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h" |
| 79 #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsAgent.h" | 80 #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsAgent.h" |
| 80 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" | 81 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" |
| 81 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" | 82 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" |
| 82 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h" | 83 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h" |
| 83 #include "third_party/WebKit/WebKit/chromium/public/WebFormControlElement.h" | 84 #include "third_party/WebKit/WebKit/chromium/public/WebFormControlElement.h" |
| 84 #include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h" | 85 #include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h" |
| 85 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 86 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
| 86 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" | 87 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) | 629 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) |
| 629 IPC_MESSAGE_HANDLER(ViewMsg_InstallMissingPlugin, OnInstallMissingPlugin) | 630 IPC_MESSAGE_HANDLER(ViewMsg_InstallMissingPlugin, OnInstallMissingPlugin) |
| 630 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) | 631 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) |
| 631 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 632 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
| 632 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, | 633 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, |
| 633 OnGetAllSavableResourceLinksForCurrentPage) | 634 OnGetAllSavableResourceLinksForCurrentPage) |
| 634 IPC_MESSAGE_HANDLER( | 635 IPC_MESSAGE_HANDLER( |
| 635 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, | 636 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
| 636 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) | 637 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
| 637 IPC_MESSAGE_HANDLER(ViewMsg_GetApplicationInfo, OnGetApplicationInfo) | 638 IPC_MESSAGE_HANDLER(ViewMsg_GetApplicationInfo, OnGetApplicationInfo) |
| 639 IPC_MESSAGE_HANDLER(ViewMsg_GetAccessibilityInfo, OnGetAccessibilityInfo) |
| 640 IPC_MESSAGE_HANDLER(ViewMsg_ClearAccessibilityInfo, |
| 641 OnClearAccessibilityInfo) |
| 638 IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnMsgShouldClose) | 642 IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnMsgShouldClose) |
| 639 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) | 643 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
| 640 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) | 644 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) |
| 641 IPC_MESSAGE_HANDLER(ViewMsg_HandleMessageFromExternalHost, | 645 IPC_MESSAGE_HANDLER(ViewMsg_HandleMessageFromExternalHost, |
| 642 OnMessageFromExternalHost) | 646 OnMessageFromExternalHost) |
| 643 IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount, | 647 IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount, |
| 644 OnDisassociateFromPopupCount) | 648 OnDisassociateFromPopupCount) |
| 645 IPC_MESSAGE_HANDLER(ViewMsg_AutoFillSuggestionsReturned, | 649 IPC_MESSAGE_HANDLER(ViewMsg_AutoFillSuggestionsReturned, |
| 646 OnAutoFillSuggestionsReturned) | 650 OnAutoFillSuggestionsReturned) |
| 647 IPC_MESSAGE_HANDLER(ViewMsg_AutoFillForms, OnAutoFillForms) | 651 IPC_MESSAGE_HANDLER(ViewMsg_AutoFillForms, OnAutoFillForms) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 673 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) | 677 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) |
| 674 #endif | 678 #endif |
| 675 IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent, | 679 IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent, |
| 676 OnSetEditCommandsForNextKeyEvent) | 680 OnSetEditCommandsForNextKeyEvent) |
| 677 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteCode, | 681 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteCode, |
| 678 OnExecuteCode) | 682 OnExecuteCode) |
| 679 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, | 683 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, |
| 680 OnCustomContextMenuAction) | 684 OnCustomContextMenuAction) |
| 681 IPC_MESSAGE_HANDLER(ViewMsg_TranslatePage, OnTranslatePage) | 685 IPC_MESSAGE_HANDLER(ViewMsg_TranslatePage, OnTranslatePage) |
| 682 IPC_MESSAGE_HANDLER(ViewMsg_RevertTranslation, OnRevertTranslation) | 686 IPC_MESSAGE_HANDLER(ViewMsg_RevertTranslation, OnRevertTranslation) |
| 683 IPC_MESSAGE_HANDLER(ViewMsg_GetAccessibilityTree, OnGetAccessibilityTree) | |
| 684 | 687 |
| 685 // Have the super handle all other messages. | 688 // Have the super handle all other messages. |
| 686 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) | 689 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) |
| 687 IPC_END_MESSAGE_MAP() | 690 IPC_END_MESSAGE_MAP() |
| 688 } | 691 } |
| 689 | 692 |
| 690 void RenderView::SendThumbnail() { | 693 void RenderView::SendThumbnail() { |
| 691 WebFrame* main_frame = webview()->mainFrame(); | 694 WebFrame* main_frame = webview()->mainFrame(); |
| 692 if (!main_frame) | 695 if (!main_frame) |
| 693 return; | 696 return; |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); | 1327 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); |
| 1325 } | 1328 } |
| 1326 | 1329 |
| 1327 last_page_id_sent_to_browser_ = | 1330 last_page_id_sent_to_browser_ = |
| 1328 std::max(last_page_id_sent_to_browser_, page_id_); | 1331 std::max(last_page_id_sent_to_browser_, page_id_); |
| 1329 | 1332 |
| 1330 // If we end up reusing this WebRequest (for example, due to a #ref click), | 1333 // If we end up reusing this WebRequest (for example, due to a #ref click), |
| 1331 // we don't want the transition type to persist. Just clear it. | 1334 // we don't want the transition type to persist. Just clear it. |
| 1332 navigation_state->set_transition_type(PageTransition::LINK); | 1335 navigation_state->set_transition_type(PageTransition::LINK); |
| 1333 | 1336 |
| 1337 #if defined(OS_WIN) |
| 1334 if (accessibility_.get()) { | 1338 if (accessibility_.get()) { |
| 1335 accessibility_->clear(); | 1339 // Remove accessibility info cache. |
| 1336 accessibility_.reset(); | 1340 accessibility_.reset(); |
| 1337 } | 1341 } |
| 1342 #else |
| 1343 // TODO(port): accessibility not yet implemented. See http://crbug.com/8288. |
| 1344 #endif |
| 1338 } | 1345 } |
| 1339 | 1346 |
| 1340 // Tell the embedding application that the title of the active page has changed | 1347 // Tell the embedding application that the title of the active page has changed |
| 1341 void RenderView::UpdateTitle(WebFrame* frame, const string16& title) { | 1348 void RenderView::UpdateTitle(WebFrame* frame, const string16& title) { |
| 1342 // Ignore all but top level navigations... | 1349 // Ignore all but top level navigations... |
| 1343 if (!frame->parent()) { | 1350 if (!frame->parent()) { |
| 1344 Send(new ViewHostMsg_UpdateTitle( | 1351 Send(new ViewHostMsg_UpdateTitle( |
| 1345 routing_id_, | 1352 routing_id_, |
| 1346 page_id_, | 1353 page_id_, |
| 1347 UTF16ToWideHack(title.length() > chrome::kMaxTitleChars ? | 1354 UTF16ToWideHack(title.length() > chrome::kMaxTitleChars ? |
| (...skipping 2549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3897 ExtensionProcessBindings::SetViewType(webview(), type); | 3904 ExtensionProcessBindings::SetViewType(webview(), type); |
| 3898 } | 3905 } |
| 3899 } | 3906 } |
| 3900 view_type_ = type; | 3907 view_type_ = type; |
| 3901 } | 3908 } |
| 3902 | 3909 |
| 3903 void RenderView::OnUpdateBrowserWindowId(int window_id) { | 3910 void RenderView::OnUpdateBrowserWindowId(int window_id) { |
| 3904 browser_window_id_ = window_id; | 3911 browser_window_id_ = window_id; |
| 3905 } | 3912 } |
| 3906 | 3913 |
| 3907 void RenderView::OnGetAccessibilityTree() { | 3914 void RenderView::OnGetAccessibilityInfo( |
| 3908 if (accessibility_.get()) { | 3915 const webkit_glue::WebAccessibility::InParams& in_params, |
| 3916 webkit_glue::WebAccessibility::OutParams* out_params) { |
| 3917 #if defined(OS_WIN) |
| 3918 if (!accessibility_.get()) { |
| 3919 // TODO(dglazkov): Once implemented for all ports, remove lazy |
| 3920 // instantiation of accessibility_. |
| 3921 accessibility_.reset(WebAccessibilityCache::create()); |
| 3922 accessibility_->initialize(webview()); |
| 3923 } |
| 3924 |
| 3925 out_params->return_code = |
| 3926 webkit_glue::WebAccessibility::GetAccObjInfo(accessibility_.get(), |
| 3927 in_params, |
| 3928 out_params); |
| 3929 |
| 3930 #else // defined(OS_WIN) |
| 3931 // TODO(port): accessibility not yet implemented |
| 3932 NOTIMPLEMENTED(); |
| 3933 #endif |
| 3934 } |
| 3935 |
| 3936 void RenderView::OnClearAccessibilityInfo(int acc_obj_id, bool clear_all) { |
| 3937 #if defined(OS_WIN) |
| 3938 if (!accessibility_.get()) { |
| 3939 // If accessibility is not activated, ignore clearing message. |
| 3940 return; |
| 3941 } |
| 3942 |
| 3943 if (clear_all) { |
| 3909 accessibility_->clear(); | 3944 accessibility_->clear(); |
| 3945 return; |
| 3910 } | 3946 } |
| 3911 accessibility_.reset(WebAccessibilityCache::create()); | |
| 3912 accessibility_->initialize(webview()); | |
| 3913 | 3947 |
| 3914 WebAccessibilityObject src_tree = webview()->accessibilityObject(); | 3948 accessibility_->remove(acc_obj_id); |
| 3915 webkit_glue::WebAccessibility dst_tree(src_tree, accessibility_.get()); | 3949 |
| 3916 Send(new ViewHostMsg_AccessibilityTree(routing_id_, dst_tree)); | 3950 #else // defined(OS_WIN) |
| 3951 // TODO(port): accessibility not yet implemented |
| 3952 NOTIMPLEMENTED(); |
| 3953 #endif |
| 3917 } | 3954 } |
| 3918 | 3955 |
| 3919 void RenderView::OnGetAllSavableResourceLinksForCurrentPage( | 3956 void RenderView::OnGetAllSavableResourceLinksForCurrentPage( |
| 3920 const GURL& page_url) { | 3957 const GURL& page_url) { |
| 3921 // Prepare list to storage all savable resource links. | 3958 // Prepare list to storage all savable resource links. |
| 3922 std::vector<GURL> resources_list; | 3959 std::vector<GURL> resources_list; |
| 3923 std::vector<GURL> referrers_list; | 3960 std::vector<GURL> referrers_list; |
| 3924 std::vector<GURL> frames_list; | 3961 std::vector<GURL> frames_list; |
| 3925 webkit_glue::SavableResourcesResult result(&resources_list, | 3962 webkit_glue::SavableResourcesResult result(&resources_list, |
| 3926 &referrers_list, | 3963 &referrers_list, |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4936 | 4973 |
| 4937 if (last_top_level_navigation_page_id_ != page_id_ && | 4974 if (last_top_level_navigation_page_id_ != page_id_ && |
| 4938 // Not interested in reloads. | 4975 // Not interested in reloads. |
| 4939 type != WebKit::WebNavigationTypeReload && | 4976 type != WebKit::WebNavigationTypeReload && |
| 4940 type != WebKit::WebNavigationTypeFormSubmitted) { | 4977 type != WebKit::WebNavigationTypeFormSubmitted) { |
| 4941 return true; | 4978 return true; |
| 4942 } | 4979 } |
| 4943 } | 4980 } |
| 4944 return false; | 4981 return false; |
| 4945 } | 4982 } |
| OLD | NEW |