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 "chrome/renderer/render_view.h" | 5 #include "chrome/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> |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 /////////////////////////////////////////////////////////////////////////////// | 533 /////////////////////////////////////////////////////////////////////////////// |
534 | 534 |
535 int32 RenderView::next_page_id_ = 1; | 535 int32 RenderView::next_page_id_ = 1; |
536 | 536 |
537 struct RenderView::PendingFileChooser { | 537 struct RenderView::PendingFileChooser { |
538 PendingFileChooser(const ViewHostMsg_RunFileChooser_Params& p, | 538 PendingFileChooser(const ViewHostMsg_RunFileChooser_Params& p, |
539 WebFileChooserCompletion* c) | 539 WebFileChooserCompletion* c) |
540 : params(p), | 540 : params(p), |
541 completion(c) { | 541 completion(c) { |
542 } | 542 } |
| 543 |
543 ViewHostMsg_RunFileChooser_Params params; | 544 ViewHostMsg_RunFileChooser_Params params; |
544 WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. | 545 WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. |
545 }; | 546 }; |
546 | 547 |
547 RenderView::RenderView(RenderThreadBase* render_thread, | 548 RenderView::RenderView(RenderThreadBase* render_thread, |
548 gfx::NativeViewId parent_hwnd, | 549 gfx::NativeViewId parent_hwnd, |
549 int32 opener_id, | 550 int32 opener_id, |
550 const RendererPreferences& renderer_prefs, | 551 const RendererPreferences& renderer_prefs, |
551 const WebPreferences& webkit_prefs, | 552 const WebPreferences& webkit_prefs, |
552 SharedRenderViewCounter* counter, | 553 SharedRenderViewCounter* counter, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), | 585 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
585 devtools_client_(NULL), | 586 devtools_client_(NULL), |
586 geolocation_dispatcher_(NULL), | 587 geolocation_dispatcher_(NULL), |
587 speech_input_dispatcher_(NULL), | 588 speech_input_dispatcher_(NULL), |
588 device_orientation_dispatcher_(NULL), | 589 device_orientation_dispatcher_(NULL), |
589 print_helper_(NULL), | 590 print_helper_(NULL), |
590 searchbox_(NULL), | 591 searchbox_(NULL), |
591 spellcheck_provider_(NULL), | 592 spellcheck_provider_(NULL), |
592 accessibility_ack_pending_(false), | 593 accessibility_ack_pending_(false), |
593 p2p_socket_dispatcher_(NULL), | 594 p2p_socket_dispatcher_(NULL), |
| 595 enumeration_completion_id_(0), |
594 pending_app_icon_requests_(0), | 596 pending_app_icon_requests_(0), |
595 session_storage_namespace_id_(session_storage_namespace_id) { | 597 session_storage_namespace_id_(session_storage_namespace_id) { |
596 #if defined(OS_MACOSX) | 598 #if defined(OS_MACOSX) |
597 // On Mac, the select popups are rendered by the browser. | 599 // On Mac, the select popups are rendered by the browser. |
598 // Note that we don't do this in RenderMain otherwise this would not be called | 600 // Note that we don't do this in RenderMain otherwise this would not be called |
599 // in single-process mode. | 601 // in single-process mode. |
600 WebKit::WebView::setUseExternalPopupMenus(true); | 602 WebKit::WebView::setUseExternalPopupMenus(true); |
601 #endif | 603 #endif |
602 | 604 |
603 ClearBlockedContentSettings(); | 605 ClearBlockedContentSettings(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 } | 685 } |
684 | 686 |
685 // Observer for Malware DOM details messages. | 687 // Observer for Malware DOM details messages. |
686 new safe_browsing::MalwareDOMDetails(this); | 688 new safe_browsing::MalwareDOMDetails(this); |
687 } | 689 } |
688 | 690 |
689 RenderView::~RenderView() { | 691 RenderView::~RenderView() { |
690 if (decrement_shared_popup_at_destruction_) | 692 if (decrement_shared_popup_at_destruction_) |
691 shared_popup_counter_->data--; | 693 shared_popup_counter_->data--; |
692 | 694 |
693 // If file chooser is still waiting for answer, dispatch empty answer. | 695 // If file chooser or directory enumeration |
| 696 // is still waiting for answer, dispatch empty answer. |
694 while (!file_chooser_completions_.empty()) { | 697 while (!file_chooser_completions_.empty()) { |
695 if (file_chooser_completions_.front()->completion) { | 698 if (file_chooser_completions_.front()->completion) { |
696 file_chooser_completions_.front()->completion->didChooseFile( | 699 file_chooser_completions_.front()->completion->didChooseFile( |
697 WebVector<WebString>()); | 700 WebVector<WebString>()); |
698 } | 701 } |
699 file_chooser_completions_.pop_front(); | 702 file_chooser_completions_.pop_front(); |
700 } | 703 } |
701 | 704 |
| 705 while (!enumeration_completions_.empty()) { |
| 706 if (enumeration_completions_.begin()->second) { |
| 707 enumeration_completions_.begin()->second->didChooseFile( |
| 708 WebVector<WebString>()); |
| 709 } |
| 710 enumeration_completions_.erase(enumeration_completions_.begin()); |
| 711 } |
| 712 |
702 #if defined(OS_MACOSX) | 713 #if defined(OS_MACOSX) |
703 // Tell the spellchecker that the document is closed. | 714 // Tell the spellchecker that the document is closed. |
704 if (has_document_tag_) | 715 if (has_document_tag_) |
705 Send(new ViewHostMsg_DocumentWithTagClosed(routing_id_, document_tag_)); | 716 Send(new ViewHostMsg_DocumentWithTagClosed(routing_id_, document_tag_)); |
706 | 717 |
707 // Destroy all fake plugin window handles on the browser side. | 718 // Destroy all fake plugin window handles on the browser side. |
708 while (!fake_plugin_window_handles_.empty()) { | 719 while (!fake_plugin_window_handles_.empty()) { |
709 // Make sure no NULL plugin window handles were inserted into this list. | 720 // Make sure no NULL plugin window handles were inserted into this list. |
710 DCHECK(*fake_plugin_window_handles_.begin()); | 721 DCHECK(*fake_plugin_window_handles_.begin()); |
711 // DestroyFakePluginWindowHandle modifies fake_plugin_window_handles_. | 722 // DestroyFakePluginWindowHandle modifies fake_plugin_window_handles_. |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) | 1064 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
1054 IPC_MESSAGE_HANDLER(ViewMsg_ScrollFocusedEditableNodeIntoView, | 1065 IPC_MESSAGE_HANDLER(ViewMsg_ScrollFocusedEditableNodeIntoView, |
1055 OnScrollFocusedEditableNodeIntoView) | 1066 OnScrollFocusedEditableNodeIntoView) |
1056 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) | 1067 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
1057 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) | 1068 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
1058 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) | 1069 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) |
1059 IPC_MESSAGE_HANDLER(ViewMsg_InstallMissingPlugin, OnInstallMissingPlugin) | 1070 IPC_MESSAGE_HANDLER(ViewMsg_InstallMissingPlugin, OnInstallMissingPlugin) |
1060 IPC_MESSAGE_HANDLER(ViewMsg_DisplayPrerenderedPage, | 1071 IPC_MESSAGE_HANDLER(ViewMsg_DisplayPrerenderedPage, |
1061 OnDisplayPrerenderedPage) | 1072 OnDisplayPrerenderedPage) |
1062 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) | 1073 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) |
| 1074 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, |
| 1075 OnEnumerateDirectoryResponse) |
1063 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 1076 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
1064 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, | 1077 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, |
1065 OnGetAllSavableResourceLinksForCurrentPage) | 1078 OnGetAllSavableResourceLinksForCurrentPage) |
1066 IPC_MESSAGE_HANDLER( | 1079 IPC_MESSAGE_HANDLER( |
1067 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, | 1080 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
1068 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) | 1081 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
1069 IPC_MESSAGE_HANDLER(ViewMsg_GetApplicationInfo, OnGetApplicationInfo) | 1082 IPC_MESSAGE_HANDLER(ViewMsg_GetApplicationInfo, OnGetApplicationInfo) |
1070 IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnShouldClose) | 1083 IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnShouldClose) |
1071 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) | 1084 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
1072 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) | 1085 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) |
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2361 | 2374 |
2362 bool RenderView::isShowingSpellingUI() { | 2375 bool RenderView::isShowingSpellingUI() { |
2363 return spelling_panel_visible_; | 2376 return spelling_panel_visible_; |
2364 } | 2377 } |
2365 | 2378 |
2366 void RenderView::updateSpellingUIWithMisspelledWord(const WebString& word) { | 2379 void RenderView::updateSpellingUIWithMisspelledWord(const WebString& word) { |
2367 Send(new ViewHostMsg_UpdateSpellingPanelWithMisspelledWord(routing_id_, | 2380 Send(new ViewHostMsg_UpdateSpellingPanelWithMisspelledWord(routing_id_, |
2368 word)); | 2381 word)); |
2369 } | 2382 } |
2370 | 2383 |
| 2384 bool RenderView::enumerateDirectory( |
| 2385 const WebString& path, |
| 2386 WebFileChooserCompletion* chooser_completion) { |
| 2387 int id = enumeration_completion_id_++; |
| 2388 enumeration_completions_[id] = chooser_completion; |
| 2389 return Send(new ViewHostMsg_EnumerateDirectory( |
| 2390 routing_id_, |
| 2391 id, |
| 2392 webkit_glue::WebStringToFilePath(path))); |
| 2393 } |
| 2394 |
2371 void RenderView::continuousSpellCheckingEnabledStateChanged() { | 2395 void RenderView::continuousSpellCheckingEnabledStateChanged() { |
2372 UpdateToggleSpellCheckCommandState(); | 2396 UpdateToggleSpellCheckCommandState(); |
2373 } | 2397 } |
2374 | 2398 |
2375 bool RenderView::runFileChooser( | 2399 bool RenderView::runFileChooser( |
2376 const WebKit::WebFileChooserParams& params, | 2400 const WebKit::WebFileChooserParams& params, |
2377 WebFileChooserCompletion* chooser_completion) { | 2401 WebFileChooserCompletion* chooser_completion) { |
2378 // Do not open the file dialog in a hidden RenderView. | 2402 // Do not open the file dialog in a hidden RenderView. |
2379 if (is_hidden()) | 2403 if (is_hidden()) |
2380 return false; | 2404 return false; |
(...skipping 2349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4730 if (provisional_ds) { | 4754 if (provisional_ds) { |
4731 NavigationState* provisional_navigation_state = | 4755 NavigationState* provisional_navigation_state = |
4732 NavigationState::FromDataSource(provisional_ds); | 4756 NavigationState::FromDataSource(provisional_ds); |
4733 if (provisional_navigation_state) { | 4757 if (provisional_navigation_state) { |
4734 provisional_navigation_state->set_prerendered_page_display_time( | 4758 provisional_navigation_state->set_prerendered_page_display_time( |
4735 Time::Now()); | 4759 Time::Now()); |
4736 } | 4760 } |
4737 } | 4761 } |
4738 } | 4762 } |
4739 | 4763 |
| 4764 void RenderView::OnEnumerateDirectoryResponse( |
| 4765 int id, |
| 4766 const std::vector<FilePath>& paths) { |
| 4767 if (!enumeration_completions_[id]) |
| 4768 return; |
| 4769 |
| 4770 WebVector<WebString> ws_file_names(paths.size()); |
| 4771 for (size_t i = 0; i < paths.size(); ++i) |
| 4772 ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); |
| 4773 |
| 4774 enumeration_completions_[id]->didChooseFile(ws_file_names); |
| 4775 enumeration_completions_.erase(id); |
| 4776 } |
| 4777 |
4740 void RenderView::OnFileChooserResponse(const std::vector<FilePath>& paths) { | 4778 void RenderView::OnFileChooserResponse(const std::vector<FilePath>& paths) { |
4741 // This could happen if we navigated to a different page before the user | 4779 // This could happen if we navigated to a different page before the user |
4742 // closed the chooser. | 4780 // closed the chooser. |
4743 if (file_chooser_completions_.empty()) | 4781 if (file_chooser_completions_.empty()) |
4744 return; | 4782 return; |
4745 | 4783 |
4746 WebVector<WebString> ws_file_names(paths.size()); | 4784 WebVector<WebString> ws_file_names(paths.size()); |
4747 for (size_t i = 0; i < paths.size(); ++i) | 4785 for (size_t i = 0; i < paths.size(); ++i) |
4748 ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); | 4786 ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); |
4749 | 4787 |
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5704 } | 5742 } |
5705 } | 5743 } |
5706 | 5744 |
5707 void RenderView::OnContextMenuClosed( | 5745 void RenderView::OnContextMenuClosed( |
5708 const webkit_glue::CustomContextMenuContext& custom_context) { | 5746 const webkit_glue::CustomContextMenuContext& custom_context) { |
5709 if (custom_context.is_pepper_menu) | 5747 if (custom_context.is_pepper_menu) |
5710 pepper_delegate_.OnContextMenuClosed(custom_context); | 5748 pepper_delegate_.OnContextMenuClosed(custom_context); |
5711 else | 5749 else |
5712 context_menu_node_.reset(); | 5750 context_menu_node_.reset(); |
5713 } | 5751 } |
OLD | NEW |