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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 #include "third_party/WebKit/WebKit/chromium/public/WebCString.h" | 79 #include "third_party/WebKit/WebKit/chromium/public/WebCString.h" |
80 #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h" | 80 #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h" |
81 #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsAgent.h" | 81 #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsAgent.h" |
82 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" | 82 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" |
83 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" | 83 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" |
84 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h" | 84 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h" |
85 #include "third_party/WebKit/WebKit/chromium/public/WebFormControlElement.h" | 85 #include "third_party/WebKit/WebKit/chromium/public/WebFormControlElement.h" |
86 #include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h" | 86 #include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h" |
87 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 87 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
88 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" | 88 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" |
| 89 #include "third_party/WebKit/WebKit/chromium/public/WebIconLoadingCompletion.h" |
89 #include "third_party/WebKit/WebKit/chromium/public/WebImage.h" | 90 #include "third_party/WebKit/WebKit/chromium/public/WebImage.h" |
90 #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" | 91 #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" |
91 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" | 92 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" |
92 #include "third_party/WebKit/WebKit/chromium/public/WebNodeList.h" | 93 #include "third_party/WebKit/WebKit/chromium/public/WebNodeList.h" |
93 #include "third_party/WebKit/WebKit/chromium/public/WebPageSerializer.h" | 94 #include "third_party/WebKit/WebKit/chromium/public/WebPageSerializer.h" |
94 #include "third_party/WebKit/WebKit/chromium/public/WebPlugin.h" | 95 #include "third_party/WebKit/WebKit/chromium/public/WebPlugin.h" |
95 #include "third_party/WebKit/WebKit/chromium/public/WebPluginDocument.h" | 96 #include "third_party/WebKit/WebKit/chromium/public/WebPluginDocument.h" |
96 #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" | 97 #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" |
97 #include "third_party/WebKit/WebKit/chromium/public/WebRange.h" | 98 #include "third_party/WebKit/WebKit/chromium/public/WebRange.h" |
98 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" | 99 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 using WebKit::WebDragData; | 166 using WebKit::WebDragData; |
166 using WebKit::WebDragOperation; | 167 using WebKit::WebDragOperation; |
167 using WebKit::WebDragOperationsMask; | 168 using WebKit::WebDragOperationsMask; |
168 using WebKit::WebEditingAction; | 169 using WebKit::WebEditingAction; |
169 using WebKit::WebFileChooserCompletion; | 170 using WebKit::WebFileChooserCompletion; |
170 using WebKit::WebFindOptions; | 171 using WebKit::WebFindOptions; |
171 using WebKit::WebFormControlElement; | 172 using WebKit::WebFormControlElement; |
172 using WebKit::WebFormElement; | 173 using WebKit::WebFormElement; |
173 using WebKit::WebFrame; | 174 using WebKit::WebFrame; |
174 using WebKit::WebHistoryItem; | 175 using WebKit::WebHistoryItem; |
| 176 using WebKit::WebIconLoadingCompletion; |
175 using WebKit::WebImage; | 177 using WebKit::WebImage; |
176 using WebKit::WebInputElement; | 178 using WebKit::WebInputElement; |
177 using WebKit::WebMediaPlayer; | 179 using WebKit::WebMediaPlayer; |
178 using WebKit::WebMediaPlayerAction; | 180 using WebKit::WebMediaPlayerAction; |
179 using WebKit::WebMediaPlayerClient; | 181 using WebKit::WebMediaPlayerClient; |
180 using WebKit::WebNavigationPolicy; | 182 using WebKit::WebNavigationPolicy; |
181 using WebKit::WebNavigationType; | 183 using WebKit::WebNavigationType; |
182 using WebKit::WebNode; | 184 using WebKit::WebNode; |
183 using WebKit::WebPageSerializer; | 185 using WebKit::WebPageSerializer; |
184 using WebKit::WebPageSerializerClient; | 186 using WebKit::WebPageSerializerClient; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 is_loading_(false), | 370 is_loading_(false), |
369 navigation_gesture_(NavigationGestureUnknown), | 371 navigation_gesture_(NavigationGestureUnknown), |
370 page_id_(-1), | 372 page_id_(-1), |
371 last_page_id_sent_to_browser_(-1), | 373 last_page_id_sent_to_browser_(-1), |
372 last_indexed_page_id_(-1), | 374 last_indexed_page_id_(-1), |
373 opened_by_user_gesture_(true), | 375 opened_by_user_gesture_(true), |
374 opener_suppressed_(false), | 376 opener_suppressed_(false), |
375 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), | 377 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), |
376 devtools_agent_(NULL), | 378 devtools_agent_(NULL), |
377 devtools_client_(NULL), | 379 devtools_client_(NULL), |
| 380 choose_icon_for_files_counter_(0), |
378 history_list_offset_(-1), | 381 history_list_offset_(-1), |
379 history_list_length_(0), | 382 history_list_length_(0), |
380 has_unload_listener_(false), | 383 has_unload_listener_(false), |
381 decrement_shared_popup_at_destruction_(false), | 384 decrement_shared_popup_at_destruction_(false), |
382 autofill_query_id_(0), | 385 autofill_query_id_(0), |
383 script_can_close_(true), | 386 script_can_close_(true), |
384 spelling_panel_visible_(false), | 387 spelling_panel_visible_(false), |
385 send_content_state_immediately_(false), | 388 send_content_state_immediately_(false), |
386 send_preferred_size_changes_(false), | 389 send_preferred_size_changes_(false), |
387 ALLOW_THIS_IN_INITIALIZER_LIST( | 390 ALLOW_THIS_IN_INITIALIZER_LIST( |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 IPC_MESSAGE_HANDLER(ViewMsg_DragSourceEndedOrMoved, | 626 IPC_MESSAGE_HANDLER(ViewMsg_DragSourceEndedOrMoved, |
624 OnDragSourceEndedOrMoved) | 627 OnDragSourceEndedOrMoved) |
625 IPC_MESSAGE_HANDLER(ViewMsg_DragSourceSystemDragEnded, | 628 IPC_MESSAGE_HANDLER(ViewMsg_DragSourceSystemDragEnded, |
626 OnDragSourceSystemDragEnded) | 629 OnDragSourceSystemDragEnded) |
627 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) | 630 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
628 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) | 631 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
629 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) | 632 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
630 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) | 633 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) |
631 IPC_MESSAGE_HANDLER(ViewMsg_InstallMissingPlugin, OnInstallMissingPlugin) | 634 IPC_MESSAGE_HANDLER(ViewMsg_InstallMissingPlugin, OnInstallMissingPlugin) |
632 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) | 635 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) |
| 636 IPC_MESSAGE_HANDLER(ViewMsg_ChooseIconForFilesResponse, |
| 637 OnChooseIconForFilesResponse) |
633 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 638 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
634 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, | 639 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, |
635 OnGetAllSavableResourceLinksForCurrentPage) | 640 OnGetAllSavableResourceLinksForCurrentPage) |
636 IPC_MESSAGE_HANDLER( | 641 IPC_MESSAGE_HANDLER( |
637 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, | 642 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
638 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) | 643 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
639 IPC_MESSAGE_HANDLER(ViewMsg_GetApplicationInfo, OnGetApplicationInfo) | 644 IPC_MESSAGE_HANDLER(ViewMsg_GetApplicationInfo, OnGetApplicationInfo) |
640 IPC_MESSAGE_HANDLER(ViewMsg_GetAccessibilityInfo, OnGetAccessibilityInfo) | 645 IPC_MESSAGE_HANDLER(ViewMsg_GetAccessibilityInfo, OnGetAccessibilityInfo) |
641 IPC_MESSAGE_HANDLER(ViewMsg_ClearAccessibilityInfo, | 646 IPC_MESSAGE_HANDLER(ViewMsg_ClearAccessibilityInfo, |
642 OnClearAccessibilityInfo) | 647 OnClearAccessibilityInfo) |
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 | 1809 |
1805 bool RenderView::isShowingSpellingUI() { | 1810 bool RenderView::isShowingSpellingUI() { |
1806 return spelling_panel_visible_; | 1811 return spelling_panel_visible_; |
1807 } | 1812 } |
1808 | 1813 |
1809 void RenderView::updateSpellingUIWithMisspelledWord(const WebString& word) { | 1814 void RenderView::updateSpellingUIWithMisspelledWord(const WebString& word) { |
1810 Send(new ViewHostMsg_UpdateSpellingPanelWithMisspelledWord(routing_id_, | 1815 Send(new ViewHostMsg_UpdateSpellingPanelWithMisspelledWord(routing_id_, |
1811 word)); | 1816 word)); |
1812 } | 1817 } |
1813 | 1818 |
| 1819 bool RenderView::chooseIconForFiles( |
| 1820 const WebKit::WebVector<WebKit::WebString>& filenames, |
| 1821 WebIconLoadingCompletion* completion) { |
| 1822 icon_loading_map_[choose_icon_for_files_counter_] = completion; |
| 1823 |
| 1824 std::vector<FilePath> file_paths; |
| 1825 file_paths.reserve(filenames.size()); |
| 1826 for (unsigned i = 0; i < filenames.size(); ++i) |
| 1827 file_paths.push_back(webkit_glue::WebStringToFilePath(filenames[i])); |
| 1828 int request_id = choose_icon_for_files_counter_++; |
| 1829 Send(new ViewHostMsg_ChooseIconForFiles(routing_id_, request_id, file_paths)); |
| 1830 return true; |
| 1831 } |
| 1832 |
1814 bool RenderView::runFileChooser( | 1833 bool RenderView::runFileChooser( |
1815 const WebKit::WebFileChooserParams& params, | 1834 const WebKit::WebFileChooserParams& params, |
1816 WebFileChooserCompletion* chooser_completion) { | 1835 WebFileChooserCompletion* chooser_completion) { |
1817 ViewHostMsg_RunFileChooser_Params ipc_params; | 1836 ViewHostMsg_RunFileChooser_Params ipc_params; |
1818 ipc_params.mode = params.multiSelect ? | 1837 ipc_params.mode = params.multiSelect ? |
1819 ViewHostMsg_RunFileChooser_Params::OpenMultiple : | 1838 ViewHostMsg_RunFileChooser_Params::OpenMultiple : |
1820 ViewHostMsg_RunFileChooser_Params::Open; | 1839 ViewHostMsg_RunFileChooser_Params::Open; |
1821 ipc_params.title = params.title; | 1840 ipc_params.title = params.title; |
1822 ipc_params.default_file_name = | 1841 ipc_params.default_file_name = |
1823 webkit_glue::WebStringToFilePath(params.initialValue); | 1842 webkit_glue::WebStringToFilePath(params.initialValue); |
(...skipping 2002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3826 void RenderView::OnRevertTranslation(int page_id) { | 3845 void RenderView::OnRevertTranslation(int page_id) { |
3827 translate_helper_.RevertTranslation(page_id); | 3846 translate_helper_.RevertTranslation(page_id); |
3828 } | 3847 } |
3829 | 3848 |
3830 void RenderView::OnInstallMissingPlugin() { | 3849 void RenderView::OnInstallMissingPlugin() { |
3831 // This could happen when the first default plugin is deleted. | 3850 // This could happen when the first default plugin is deleted. |
3832 if (first_default_plugin_) | 3851 if (first_default_plugin_) |
3833 first_default_plugin_->InstallMissingPlugin(); | 3852 first_default_plugin_->InstallMissingPlugin(); |
3834 } | 3853 } |
3835 | 3854 |
| 3855 void RenderView::OnChooseIconForFilesResponse( |
| 3856 int request_id, const std::vector<unsigned char>& icon_data) { |
| 3857 IconLoadingMap::iterator it = icon_loading_map_.find(request_id); |
| 3858 if (it == icon_loading_map_.end()) |
| 3859 return; |
| 3860 WebIconLoadingCompletion* completion = it->second; |
| 3861 icon_loading_map_.erase(it); |
| 3862 |
| 3863 // reinterpret_cast: No need to care signedness of binary data. |
| 3864 WebData web_data(reinterpret_cast<const char*>(&icon_data[0]), |
| 3865 icon_data.size()); |
| 3866 completion->iconLoaded(web_data); |
| 3867 } |
| 3868 |
3836 void RenderView::OnFileChooserResponse(const std::vector<FilePath>& paths) { | 3869 void RenderView::OnFileChooserResponse(const std::vector<FilePath>& paths) { |
3837 // This could happen if we navigated to a different page before the user | 3870 // This could happen if we navigated to a different page before the user |
3838 // closed the chooser. | 3871 // closed the chooser. |
3839 if (file_chooser_completions_.empty()) | 3872 if (file_chooser_completions_.empty()) |
3840 return; | 3873 return; |
3841 | 3874 |
3842 WebVector<WebString> ws_file_names(paths.size()); | 3875 WebVector<WebString> ws_file_names(paths.size()); |
3843 for (size_t i = 0; i < paths.size(); ++i) | 3876 for (size_t i = 0; i < paths.size(); ++i) |
3844 ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); | 3877 ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); |
3845 | 3878 |
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4985 | 5018 |
4986 if (last_top_level_navigation_page_id_ != page_id_ && | 5019 if (last_top_level_navigation_page_id_ != page_id_ && |
4987 // Not interested in reloads. | 5020 // Not interested in reloads. |
4988 type != WebKit::WebNavigationTypeReload && | 5021 type != WebKit::WebNavigationTypeReload && |
4989 type != WebKit::WebNavigationTypeFormSubmitted) { | 5022 type != WebKit::WebNavigationTypeFormSubmitted) { |
4990 return true; | 5023 return true; |
4991 } | 5024 } |
4992 } | 5025 } |
4993 return false; | 5026 return false; |
4994 } | 5027 } |
OLD | NEW |