Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: chrome/renderer/render_view.cc

Issue 246079: More WebView / WebViewDelegate cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/render_view.h ('k') | webkit/api/public/WebFrameClient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 opened_by_user_gesture_(true), 212 opened_by_user_gesture_(true),
213 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), 213 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
214 devtools_agent_(NULL), 214 devtools_agent_(NULL),
215 devtools_client_(NULL), 215 devtools_client_(NULL),
216 history_back_list_count_(0), 216 history_back_list_count_(0),
217 history_forward_list_count_(0), 217 history_forward_list_count_(0),
218 has_unload_listener_(false), 218 has_unload_listener_(false),
219 decrement_shared_popup_at_destruction_(false), 219 decrement_shared_popup_at_destruction_(false),
220 form_field_autofill_request_id_(0), 220 form_field_autofill_request_id_(0),
221 popup_notification_visible_(false), 221 popup_notification_visible_(false),
222 spelling_panel_visible_(false),
222 delay_seconds_for_form_state_sync_(kDefaultDelaySecondsForFormStateSync), 223 delay_seconds_for_form_state_sync_(kDefaultDelaySecondsForFormStateSync),
223 preferred_width_(0), 224 preferred_width_(0),
224 send_preferred_width_changes_(false), 225 send_preferred_width_changes_(false),
225 determine_page_text_after_loading_stops_(false), 226 determine_page_text_after_loading_stops_(false),
226 view_type_(ViewType::INVALID), 227 view_type_(ViewType::INVALID),
227 browser_window_id_(-1), 228 browser_window_id_(-1),
228 last_top_level_navigation_page_id_(-1), 229 last_top_level_navigation_page_id_(-1),
229 #if defined(OS_MACOSX) 230 #if defined(OS_MACOSX)
230 has_document_tag_(false), 231 has_document_tag_(false),
231 #endif 232 #endif
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 return; 881 return;
881 webview()->focusedFrame()->executeCommand( 882 webview()->focusedFrame()->executeCommand(
882 WebString::fromUTF8("AdvanceToNextMisspelling")); 883 WebString::fromUTF8("AdvanceToNextMisspelling"));
883 } 884 }
884 885
885 void RenderView::OnToggleSpellPanel(bool is_currently_visible) { 886 void RenderView::OnToggleSpellPanel(bool is_currently_visible) {
886 if (!webview()) 887 if (!webview())
887 return; 888 return;
888 // We need to tell the webView whether the spelling panel is visible or not so 889 // We need to tell the webView whether the spelling panel is visible or not so
889 // that it won't need to make ipc calls later. 890 // that it won't need to make ipc calls later.
890 webview()->SetSpellingPanelVisibility(is_currently_visible); 891 spelling_panel_visible_ = is_currently_visible;
891 webview()->focusedFrame()->executeCommand( 892 webview()->focusedFrame()->executeCommand(
892 WebString::fromUTF8("ToggleSpellPanel")); 893 WebString::fromUTF8("ToggleSpellPanel"));
893 } 894 }
894 895
895 void RenderView::OnToggleSpellCheck() { 896 void RenderView::OnToggleSpellCheck() {
896 if (!webview()) 897 if (!webview())
897 return; 898 return;
898 899
899 WebFrame* frame = webview()->focusedFrame(); 900 WebFrame* frame = webview()->focusedFrame();
900 frame->enableContinuousSpellChecking( 901 frame->enableContinuousSpellChecking(
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 Send(new ViewHostMsg_GetAutoCorrectWord( 1542 Send(new ViewHostMsg_GetAutoCorrectWord(
1542 routing_id_, UTF16ToWideHack(word), document_tag_, &autocorrect_word)); 1543 routing_id_, UTF16ToWideHack(word), document_tag_, &autocorrect_word));
1543 } 1544 }
1544 return WideToUTF16Hack(autocorrect_word); 1545 return WideToUTF16Hack(autocorrect_word);
1545 } 1546 }
1546 1547
1547 void RenderView::showSpellingUI(bool show) { 1548 void RenderView::showSpellingUI(bool show) {
1548 Send(new ViewHostMsg_ShowSpellingPanel(routing_id_, show)); 1549 Send(new ViewHostMsg_ShowSpellingPanel(routing_id_, show));
1549 } 1550 }
1550 1551
1552 bool RenderView::isShowingSpellingUI() {
1553 return spelling_panel_visible_;
1554 }
1555
1551 void RenderView::updateSpellingUIWithMisspelledWord(const WebString& word) { 1556 void RenderView::updateSpellingUIWithMisspelledWord(const WebString& word) {
1552 Send(new ViewHostMsg_UpdateSpellingPanelWithMisspelledWord( 1557 Send(new ViewHostMsg_UpdateSpellingPanelWithMisspelledWord(
1553 routing_id_, UTF16ToWideHack(word))); 1558 routing_id_, UTF16ToWideHack(word)));
1554 } 1559 }
1555 1560
1556 void RenderView::runModalAlertDialog( 1561 void RenderView::runModalAlertDialog(
1557 WebFrame* frame, const WebString& message) { 1562 WebFrame* frame, const WebString& message) {
1558 RunJavaScriptMessage(MessageBoxFlags::kIsJavascriptAlert, 1563 RunJavaScriptMessage(MessageBoxFlags::kIsJavascriptAlert,
1559 UTF16ToWideHack(message), 1564 UTF16ToWideHack(message),
1560 std::wstring(), 1565 std::wstring(),
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1669 1674
1670 NavigationState* navigation_state = NavigationState::FromDataSource(ds); 1675 NavigationState* navigation_state = NavigationState::FromDataSource(ds);
1671 DCHECK(navigation_state); 1676 DCHECK(navigation_state);
1672 if (navigation_state->transition_type() == PageTransition::START_PAGE) 1677 if (navigation_state->transition_type() == PageTransition::START_PAGE)
1673 return; 1678 return;
1674 1679
1675 history_back_list_count_++; 1680 history_back_list_count_++;
1676 history_forward_list_count_ = 0; 1681 history_forward_list_count_ = 0;
1677 } 1682 }
1678 1683
1684 void RenderView::didUpdateInspectorSettings() {
1685 Send(new ViewHostMsg_UpdateInspectorSettings(
1686 routing_id_, webview()->inspectorSettings().utf8()));
1687 }
1688
1679 // WebKit::WebWidgetClient ---------------------------------------------------- 1689 // WebKit::WebWidgetClient ----------------------------------------------------
1680 1690
1681 // We are supposed to get a single call to Show for a newly created RenderView 1691 // We are supposed to get a single call to Show for a newly created RenderView
1682 // that was created via RenderView::CreateWebView. So, we wait until this 1692 // that was created via RenderView::CreateWebView. So, we wait until this
1683 // point to dispatch the ShowView message. 1693 // point to dispatch the ShowView message.
1684 // 1694 //
1685 // This method provides us with the information about how to display the newly 1695 // This method provides us with the information about how to display the newly
1686 // created RenderView (i.e., as a constrained popup or as a new tab). 1696 // created RenderView (i.e., as a constrained popup or as a new tab).
1687 // 1697 //
1688 void RenderView::show(WebNavigationPolicy policy) { 1698 void RenderView::show(WebNavigationPolicy policy) {
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
2313 // cache the width and only send the IPC message when we're sure the 2323 // cache the width and only send the IPC message when we're sure the
2314 // width is different. 2324 // width is different.
2315 int width = webview()->mainFrame()->contentsPreferredWidth(); 2325 int width = webview()->mainFrame()->contentsPreferredWidth();
2316 if (width != preferred_width_) { 2326 if (width != preferred_width_) {
2317 Send(new ViewHostMsg_DidContentsPreferredWidthChange(routing_id_, width)); 2327 Send(new ViewHostMsg_DidContentsPreferredWidthChange(routing_id_, width));
2318 preferred_width_ = width; 2328 preferred_width_ = width;
2319 } 2329 }
2320 } 2330 }
2321 } 2331 }
2322 2332
2333 void RenderView::reportFindInPageMatchCount(int request_id, int count,
2334 bool final_update) {
2335 // If we have a message that has been queued up, then we should just replace
2336 // it. The ACK from the browser will make sure it gets sent when the browser
2337 // wants it.
2338 if (queued_find_reply_message_.get()) {
2339 IPC::Message* msg = new ViewHostMsg_Find_Reply(
2340 routing_id_,
2341 request_id,
2342 count,
2343 gfx::Rect(),
2344 -1, // Don't update active match ordinal.
2345 final_update);
2346 queued_find_reply_message_.reset(msg);
2347 } else {
2348 // Send the search result over to the browser process.
2349 Send(new ViewHostMsg_Find_Reply(
2350 routing_id_,
2351 request_id,
2352 count,
2353 gfx::Rect(),
2354 -1, // // Don't update active match ordinal.
2355 final_update));
2356 }
2357 }
2358
2359 void RenderView::reportFindInPageSelection(int request_id,
2360 int active_match_ordinal,
2361 const WebRect& selection_rect) {
2362 // Send the search result over to the browser process.
2363 Send(new ViewHostMsg_Find_Reply(routing_id_,
2364 request_id,
2365 -1,
2366 selection_rect,
2367 active_match_ordinal,
2368 false));
2369 }
2370
2323 // webkit_glue::WebPluginPageDelegate ----------------------------------------- 2371 // webkit_glue::WebPluginPageDelegate -----------------------------------------
2324 2372
2325 webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( 2373 webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate(
2326 const GURL& url, 2374 const GURL& url,
2327 const std::string& mime_type, 2375 const std::string& mime_type,
2328 std::string* actual_mime_type) { 2376 std::string* actual_mime_type) {
2329 if (!PluginChannelHost::IsListening()) 2377 if (!PluginChannelHost::IsListening())
2330 return NULL; 2378 return NULL;
2331 2379
2332 GURL policy_url; 2380 GURL policy_url;
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
2694 Send(new ViewMsg_DeterminePageText_Reply(routing_id_, contents)); 2742 Send(new ViewMsg_DeterminePageText_Reply(routing_id_, contents));
2695 determine_page_text_after_loading_stops_ = false; 2743 determine_page_text_after_loading_stops_ = false;
2696 return; 2744 return;
2697 } 2745 }
2698 2746
2699 // We set |determine_page_text_after_loading_stops_| true here so that, 2747 // We set |determine_page_text_after_loading_stops_| true here so that,
2700 // after page has been loaded completely, the text in the page is captured. 2748 // after page has been loaded completely, the text in the page is captured.
2701 determine_page_text_after_loading_stops_ = true; 2749 determine_page_text_after_loading_stops_ = true;
2702 } 2750 }
2703 2751
2704 void RenderView::ReportFindInPageMatchCount(int count, int request_id,
2705 bool final_update) {
2706 // If we have a message that has been queued up, then we should just replace
2707 // it. The ACK from the browser will make sure it gets sent when the browser
2708 // wants it.
2709 if (queued_find_reply_message_.get()) {
2710 IPC::Message* msg = new ViewHostMsg_Find_Reply(
2711 routing_id_,
2712 request_id,
2713 count,
2714 gfx::Rect(),
2715 -1, // Don't update active match ordinal.
2716 final_update);
2717 queued_find_reply_message_.reset(msg);
2718 } else {
2719 // Send the search result over to the browser process.
2720 Send(new ViewHostMsg_Find_Reply(
2721 routing_id_,
2722 request_id,
2723 count,
2724 gfx::Rect(),
2725 -1, // // Don't update active match ordinal.
2726 final_update));
2727 }
2728 }
2729
2730 void RenderView::ReportFindInPageSelection(int request_id,
2731 int active_match_ordinal,
2732 const WebRect& selection_rect) {
2733 // Send the search result over to the browser process.
2734 Send(new ViewHostMsg_Find_Reply(routing_id_,
2735 request_id,
2736 -1,
2737 selection_rect,
2738 active_match_ordinal,
2739 false));
2740 }
2741
2742 bool RenderView::WasOpenedByUserGesture() const { 2752 bool RenderView::WasOpenedByUserGesture() const {
2743 return opened_by_user_gesture_; 2753 return opened_by_user_gesture_;
2744 } 2754 }
2745 2755
2746 void RenderView::DnsPrefetch(const std::vector<std::string>& host_names) { 2756 void RenderView::DnsPrefetch(const std::vector<std::string>& host_names) {
2747 Send(new ViewHostMsg_DnsPrefetch(host_names)); 2757 Send(new ViewHostMsg_DnsPrefetch(host_names));
2748 } 2758 }
2749 2759
2750 void RenderView::OnZoom(int function) { 2760 void RenderView::OnZoom(int function) {
2751 static const bool kZoomIsTextOnly = false; 2761 static const bool kZoomIsTextOnly = false;
(...skipping 14 matching lines...) Expand all
2766 2776
2767 void RenderView::OnSetPageEncoding(const std::string& encoding_name) { 2777 void RenderView::OnSetPageEncoding(const std::string& encoding_name) {
2768 webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); 2778 webview()->setPageEncoding(WebString::fromUTF8(encoding_name));
2769 } 2779 }
2770 2780
2771 void RenderView::OnResetPageEncodingToDefault() { 2781 void RenderView::OnResetPageEncodingToDefault() {
2772 WebString no_encoding; 2782 WebString no_encoding;
2773 webview()->setPageEncoding(no_encoding); 2783 webview()->setPageEncoding(no_encoding);
2774 } 2784 }
2775 2785
2776 void RenderView::UpdateInspectorSettings(const std::wstring& raw_settings) {
2777 Send(new ViewHostMsg_UpdateInspectorSettings(routing_id_, raw_settings));
2778 }
2779
2780 WebDevToolsAgentDelegate* RenderView::GetWebDevToolsAgentDelegate() { 2786 WebDevToolsAgentDelegate* RenderView::GetWebDevToolsAgentDelegate() {
2781 return devtools_agent_.get(); 2787 return devtools_agent_.get();
2782 } 2788 }
2783 2789
2784 WebFrame* RenderView::GetChildFrame(const std::wstring& xpath) const { 2790 WebFrame* RenderView::GetChildFrame(const std::wstring& xpath) const {
2785 if (xpath.empty()) 2791 if (xpath.empty())
2786 return webview()->mainFrame(); 2792 return webview()->mainFrame();
2787 2793
2788 // xpath string can represent a frame deep down the tree (across multiple 2794 // xpath string can represent a frame deep down the tree (across multiple
2789 // frame DOMs). 2795 // frame DOMs).
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
3614 new PluginMsg_SignalModalDialogEvent(host_window_)); 3620 new PluginMsg_SignalModalDialogEvent(host_window_));
3615 3621
3616 message->EnableMessagePumping(); // Runs a nested message loop. 3622 message->EnableMessagePumping(); // Runs a nested message loop.
3617 bool rv = Send(message); 3623 bool rv = Send(message);
3618 3624
3619 PluginChannelHost::Broadcast( 3625 PluginChannelHost::Broadcast(
3620 new PluginMsg_ResetModalDialogEvent(host_window_)); 3626 new PluginMsg_ResetModalDialogEvent(host_window_));
3621 3627
3622 return rv; 3628 return rv;
3623 } 3629 }
OLDNEW
« no previous file with comments | « chrome/renderer/render_view.h ('k') | webkit/api/public/WebFrameClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698