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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 183923030: Almost finish moving context_menu_node_ from RenderViewImpl to RenderFrameImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 1077
1078 ObserverListBase<RenderViewObserver>::Iterator it(observers_); 1078 ObserverListBase<RenderViewObserver>::Iterator it(observers_);
1079 RenderViewObserver* observer; 1079 RenderViewObserver* observer;
1080 while ((observer = it.GetNext()) != NULL) 1080 while ((observer = it.GetNext()) != NULL)
1081 if (observer->OnMessageReceived(message)) 1081 if (observer->OnMessageReceived(message))
1082 return true; 1082 return true;
1083 1083
1084 bool handled = true; 1084 bool handled = true;
1085 bool msg_is_ok = true; 1085 bool msg_is_ok = true;
1086 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewImpl, message, msg_is_ok) 1086 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewImpl, message, msg_is_ok)
1087 IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy)
1088 IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut)
1089 IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete) 1087 IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete)
1090 IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand) 1088 IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand)
1091 IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret) 1089 IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret)
1092 IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste)
1093 IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) 1090 IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle)
1094 IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo) 1091 IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo)
1095 IPC_MESSAGE_HANDLER(InputMsg_Replace, OnReplace) 1092 IPC_MESSAGE_HANDLER(InputMsg_Replace, OnReplace)
1096 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling) 1093 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling)
1097 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, 1094 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect,
1098 OnScrollFocusedEditableNodeIntoRect) 1095 OnScrollFocusedEditableNodeIntoRect)
1099 IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll) 1096 IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll)
1100 IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange) 1097 IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange)
1101 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, 1098 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent,
1102 OnSetEditCommandsForNextKeyEvent) 1099 OnSetEditCommandsForNextKeyEvent)
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 void RenderViewImpl::OnUpdateTargetURLAck() { 1278 void RenderViewImpl::OnUpdateTargetURLAck() {
1282 // Check if there is a targeturl waiting to be sent. 1279 // Check if there is a targeturl waiting to be sent.
1283 if (target_url_status_ == TARGET_PENDING) { 1280 if (target_url_status_ == TARGET_PENDING) {
1284 Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, 1281 Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_,
1285 pending_target_url_)); 1282 pending_target_url_));
1286 } 1283 }
1287 1284
1288 target_url_status_ = TARGET_NONE; 1285 target_url_status_ = TARGET_NONE;
1289 } 1286 }
1290 1287
1291 void RenderViewImpl::OnCopy() {
1292 if (!webview())
1293 return;
1294
1295 base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
1296 WebNode current_node = context_menu_node_.isNull() ?
1297 GetFocusedElement() : context_menu_node_;
1298 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Copy"),
1299 current_node);
1300 }
1301
1302 void RenderViewImpl::OnCut() {
1303 if (!webview())
1304 return;
1305
1306 base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
1307 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Cut"),
1308 GetFocusedElement());
1309 }
1310
1311 void RenderViewImpl::OnDelete() { 1288 void RenderViewImpl::OnDelete() {
1312 if (!webview()) 1289 if (!webview())
1313 return; 1290 return;
1314 1291
1315 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Delete"), 1292 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Delete"),
1316 GetFocusedElement()); 1293 GetFocusedElement());
1317 } 1294 }
1318 1295
1319 void RenderViewImpl::OnExecuteEditCommand(const std::string& name, 1296 void RenderViewImpl::OnExecuteEditCommand(const std::string& name,
1320 const std::string& value) { 1297 const std::string& value) {
1321 if (!webview() || !webview()->focusedFrame()) 1298 if (!webview() || !webview()->focusedFrame())
1322 return; 1299 return;
1323 1300
1324 webview()->focusedFrame()->executeCommand( 1301 webview()->focusedFrame()->executeCommand(
1325 WebString::fromUTF8(name), WebString::fromUTF8(value)); 1302 WebString::fromUTF8(name), WebString::fromUTF8(value));
1326 } 1303 }
1327 1304
1328 void RenderViewImpl::OnMoveCaret(const gfx::Point& point) { 1305 void RenderViewImpl::OnMoveCaret(const gfx::Point& point) {
1329 if (!webview()) 1306 if (!webview())
1330 return; 1307 return;
1331 1308
1332 Send(new ViewHostMsg_MoveCaret_ACK(routing_id_)); 1309 Send(new ViewHostMsg_MoveCaret_ACK(routing_id_));
1333 1310
1334 webview()->focusedFrame()->moveCaretSelection(point); 1311 webview()->focusedFrame()->moveCaretSelection(point);
1335 } 1312 }
1336 1313
1337 void RenderViewImpl::OnPaste() {
1338 if (!webview())
1339 return;
1340
1341 base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
1342 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Paste"),
1343 GetFocusedElement());
1344 }
1345
1346 void RenderViewImpl::OnPasteAndMatchStyle() { 1314 void RenderViewImpl::OnPasteAndMatchStyle() {
1347 if (!webview()) 1315 if (!webview())
1348 return; 1316 return;
1349 1317
1350 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); 1318 base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
1351 webview()->focusedFrame()->executeCommand( 1319 webview()->focusedFrame()->executeCommand(
1352 WebString::fromUTF8("PasteAndMatchStyle"), GetFocusedElement()); 1320 WebString::fromUTF8("PasteAndMatchStyle"), GetFocusedElement());
1353 } 1321 }
1354 1322
1355 void RenderViewImpl::OnRedo() { 1323 void RenderViewImpl::OnRedo() {
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
2225 void RenderViewImpl::focusPrevious() { 2193 void RenderViewImpl::focusPrevious() {
2226 Send(new ViewHostMsg_TakeFocus(routing_id_, true)); 2194 Send(new ViewHostMsg_TakeFocus(routing_id_, true));
2227 } 2195 }
2228 2196
2229 void RenderViewImpl::focusedNodeChanged(const WebNode& node) { 2197 void RenderViewImpl::focusedNodeChanged(const WebNode& node) {
2230 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); 2198 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node)));
2231 2199
2232 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); 2200 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node));
2233 } 2201 }
2234 2202
2203 void RenderViewImpl::focusedFrameChanged(WebFrame* frame) {
2204 int frame_routing_id = RenderFrameImpl::FromWebFrame(frame)->GetRoutingID();
2205 Send(new ViewHostMsg_FocusedFrameChanged(routing_id_, frame_routing_id));
2206 }
2207
2235 void RenderViewImpl::numberOfWheelEventHandlersChanged(unsigned num_handlers) { 2208 void RenderViewImpl::numberOfWheelEventHandlersChanged(unsigned num_handlers) {
2236 Send(new ViewHostMsg_DidChangeNumWheelEvents(routing_id_, num_handlers)); 2209 Send(new ViewHostMsg_DidChangeNumWheelEvents(routing_id_, num_handlers));
2237 } 2210 }
2238 2211
2239 void RenderViewImpl::didUpdateLayout() { 2212 void RenderViewImpl::didUpdateLayout() {
2240 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout()); 2213 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout());
2241 2214
2242 // We don't always want to set up a timer, only if we've been put in that 2215 // We don't always want to set up a timer, only if we've been put in that
2243 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| 2216 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode|
2244 // message. 2217 // message.
(...skipping 2978 matching lines...) Expand 10 before | Expand all | Expand 10 after
5223 for (size_t i = 0; i < icon_urls.size(); i++) { 5196 for (size_t i = 0; i < icon_urls.size(); i++) {
5224 WebURL url = icon_urls[i].iconURL(); 5197 WebURL url = icon_urls[i].iconURL();
5225 if (!url.isEmpty()) 5198 if (!url.isEmpty())
5226 urls.push_back(FaviconURL(url, 5199 urls.push_back(FaviconURL(url,
5227 ToFaviconType(icon_urls[i].iconType()))); 5200 ToFaviconType(icon_urls[i].iconType())));
5228 } 5201 }
5229 SendUpdateFaviconURL(urls); 5202 SendUpdateFaviconURL(urls);
5230 } 5203 }
5231 5204
5232 } // namespace content 5205 } // namespace content
OLDNEW
« content/renderer/render_frame_impl.h ('K') | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698