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

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

Issue 2827047: Make RenderView call the plugin through WebKit::WebPlugin (instead of casting... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: compile until webkit is rolled Created 10 years, 5 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') | chrome/renderer/webplugin_delegate_pepper.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) 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 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 return; 1120 return;
1121 1121
1122 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Cut")); 1122 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Cut"));
1123 UserMetricsRecordAction("Cut"); 1123 UserMetricsRecordAction("Cut");
1124 } 1124 }
1125 1125
1126 void RenderView::OnCopy() { 1126 void RenderView::OnCopy() {
1127 if (!webview()) 1127 if (!webview())
1128 return; 1128 return;
1129 1129
1130 if (webview()->mainFrame()->document().isPluginDocument()) {
1131 webkit_glue::WebPluginDelegate* delegate = GetDelegateForPluginDocument();
1132 delegate->Copy();
1133 return;
1134 }
1135
1136 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Copy")); 1130 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Copy"));
1137 UserMetricsRecordAction("Copy"); 1131 UserMetricsRecordAction("Copy");
1138 } 1132 }
1139 1133
1140 #if defined(OS_MACOSX) 1134 #if defined(OS_MACOSX)
1141 void RenderView::OnCopyToFindPboard() { 1135 void RenderView::OnCopyToFindPboard() {
1142 if (!webview()) 1136 if (!webview())
1143 return; 1137 return;
1144 1138
1145 // Since the find pasteboard supports only plain text, this can be simpler 1139 // Since the find pasteboard supports only plain text, this can be simpler
(...skipping 2333 matching lines...) Expand 10 before | Expand all | Expand 10 after
3479 NOTREACHED() << "unknown ErrorPageType"; 3473 NOTREACHED() << "unknown ErrorPageType";
3480 } 3474 }
3481 3475
3482 // OK, build the final url to return. 3476 // OK, build the final url to return.
3483 GURL::Replacements link_doctor_params; 3477 GURL::Replacements link_doctor_params;
3484 link_doctor_params.SetQueryStr(params); 3478 link_doctor_params.SetQueryStr(params);
3485 GURL url = alternate_error_page_url_.ReplaceComponents(link_doctor_params); 3479 GURL url = alternate_error_page_url_.ReplaceComponents(link_doctor_params);
3486 return url; 3480 return url;
3487 } 3481 }
3488 3482
3489 webkit_glue::WebPluginDelegate* RenderView::GetDelegateForPluginDocument() { 3483 WebKit::WebPlugin* RenderView::GetWebPluginFromPluginDocument() {
3490 WebPlugin* plugin = 3484 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin();
3491 webview()->mainFrame()->document().to<WebPluginDocument>().plugin();
3492 return static_cast<webkit_glue::WebPluginImpl*>(plugin)->delegate();
3493 } 3485 }
3494 3486
3495 void RenderView::OnFind(int request_id, const string16& search_text, 3487 void RenderView::OnFind(int request_id, const string16& search_text,
3496 const WebFindOptions& options) { 3488 const WebFindOptions& options) {
3497 WebFrame* main_frame = webview()->mainFrame(); 3489 WebFrame* main_frame = webview()->mainFrame();
3498 3490
3499 if (main_frame->document().isPluginDocument()) { 3491 if (main_frame->document().isPluginDocument()) {
3500 webkit_glue::WebPluginDelegate* delegate = GetDelegateForPluginDocument(); 3492 #if defined(WEBPLUGIN_HAS_FIND_INTERFACE)
3501 if (options.findNext) { 3493 if (options.findNext) {
3502 // Just navigate back/forward. 3494 // Just navigate back/forward.
3503 delegate->SelectFindResult(options.forward); 3495 GetWebPluginFromPluginDocument()->selectFindResult(options.forward);
3504 } else { 3496 } else {
3505 if (delegate->SupportsFind()) { 3497 if (GetWebPluginFromPluginDocument()->supportsFind()) {
3506 delegate->StartFind(UTF16ToUTF8(search_text), 3498 GetWebPluginFromPluginDocument()->startFind(
3507 options.matchCase, 3499 search_text, options.matchCase, request_id);
3508 request_id);
3509 } else { 3500 } else {
3510 ReportNoFindInPageResults(request_id); 3501 ReportNoFindInPageResults(request_id);
3511 } 3502 }
3512 } 3503 }
3504 #endif
3513 return; 3505 return;
3514 } 3506 }
3515 3507
3516 WebFrame* frame_after_main = main_frame->traverseNext(true); 3508 WebFrame* frame_after_main = main_frame->traverseNext(true);
3517 WebFrame* focused_frame = webview()->focusedFrame(); 3509 WebFrame* focused_frame = webview()->focusedFrame();
3518 WebFrame* search_frame = focused_frame; // start searching focused frame. 3510 WebFrame* search_frame = focused_frame; // start searching focused frame.
3519 3511
3520 bool multi_frame = (frame_after_main != main_frame); 3512 bool multi_frame = (frame_after_main != main_frame);
3521 3513
3522 // If we have multiple frames, we don't want to wrap the search within the 3514 // If we have multiple frames, we don't want to wrap the search within the
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
3615 } 3607 }
3616 } 3608 }
3617 3609
3618 void RenderView::OnStopFinding(const ViewMsg_StopFinding_Params& params) { 3610 void RenderView::OnStopFinding(const ViewMsg_StopFinding_Params& params) {
3619 WebView* view = webview(); 3611 WebView* view = webview();
3620 if (!view) 3612 if (!view)
3621 return; 3613 return;
3622 3614
3623 WebDocument doc = view->mainFrame()->document(); 3615 WebDocument doc = view->mainFrame()->document();
3624 if (doc.isPluginDocument()) { 3616 if (doc.isPluginDocument()) {
3625 GetDelegateForPluginDocument()->StopFind(); 3617 #if defined(WEBPLUGIN_HAS_FIND_INTERFACE)
3618 GetWebPluginFromPluginDocument()->stopFind();
3619 #endif
3626 return; 3620 return;
3627 } 3621 }
3628 3622
3629 bool clear_selection = 3623 bool clear_selection =
3630 params.action == ViewMsg_StopFinding_Params::kClearSelection; 3624 params.action == ViewMsg_StopFinding_Params::kClearSelection;
3631 if (clear_selection) 3625 if (clear_selection)
3632 view->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect")); 3626 view->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect"));
3633 3627
3634 WebFrame* frame = view->mainFrame(); 3628 WebFrame* frame = view->mainFrame();
3635 while (frame) { 3629 while (frame) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3674 void RenderView::ClearBlockedContentSettings() { 3668 void RenderView::ClearBlockedContentSettings() {
3675 for (size_t i = 0; i < arraysize(content_blocked_); ++i) 3669 for (size_t i = 0; i < arraysize(content_blocked_); ++i)
3676 content_blocked_[i] = false; 3670 content_blocked_[i] = false;
3677 } 3671 }
3678 3672
3679 void RenderView::OnZoom(PageZoom::Function function) { 3673 void RenderView::OnZoom(PageZoom::Function function) {
3680 if (!webview()) // Not sure if this can happen, but no harm in being safe. 3674 if (!webview()) // Not sure if this can happen, but no harm in being safe.
3681 return; 3675 return;
3682 3676
3683 webview()->hidePopups(); 3677 webview()->hidePopups();
3684 // Should we be saving zoom levels for plugins? It's not clear, so for now
3685 // don't.
3686 if (webview()->mainFrame()->document().isPluginDocument()) {
3687 webkit_glue::WebPluginDelegate* delegate = GetDelegateForPluginDocument();
3688 int zoom;
3689 if (function == PageZoom::RESET) {
3690 zoom = 0;
3691 } else if (function == PageZoom::ZOOM_OUT) {
3692 zoom = -1;
3693 } else if (function == PageZoom::ZOOM_IN) {
3694 zoom = 1;
3695 } else {
3696 NOTREACHED();
3697 return;
3698 }
3699 delegate->Zoom(zoom);
3700 return;
3701 }
3702 3678
3703 int zoom_level = webview()->zoomLevel(); 3679 int zoom_level = webview()->zoomLevel();
3704 int new_zoom_level = webview()->setZoomLevel(false, 3680 int new_zoom_level = webview()->setZoomLevel(false,
3705 (function == PageZoom::RESET) ? 0 : (zoom_level + function)); 3681 (function == PageZoom::RESET) ? 0 : (zoom_level + function));
3706 3682
3707 // Tell the browser which url got zoomed so it can update the saved values. 3683 // Tell the browser which url got zoomed so it can update the saved values.
3708 Send(new ViewHostMsg_DidZoomURL( 3684 Send(new ViewHostMsg_DidZoomURL(
3709 GURL(webview()->mainFrame()->url()), new_zoom_level)); 3685 GURL(webview()->mainFrame()->url()), new_zoom_level));
3710 } 3686 }
3711 3687
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after
5270 webkit_glue::FormData form; 5246 webkit_glue::FormData form;
5271 const WebInputElement element = node.toConst<WebInputElement>(); 5247 const WebInputElement element = node.toConst<WebInputElement>();
5272 if (!form_manager_.FindFormWithFormControlElement( 5248 if (!form_manager_.FindFormWithFormControlElement(
5273 element, FormManager::REQUIRE_NONE, &form)) 5249 element, FormManager::REQUIRE_NONE, &form))
5274 return; 5250 return;
5275 5251
5276 autofill_action_ = action; 5252 autofill_action_ = action;
5277 Send(new ViewHostMsg_FillAutoFillFormData( 5253 Send(new ViewHostMsg_FillAutoFillFormData(
5278 routing_id_, autofill_query_id_, form, value, label)); 5254 routing_id_, autofill_query_id_, form, value, label));
5279 } 5255 }
OLDNEW
« no previous file with comments | « chrome/renderer/render_view.h ('k') | chrome/renderer/webplugin_delegate_pepper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698