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

Side by Side Diff: content/browser/renderer_host/render_view_host.cc

Issue 7125006: Get rid of Chrome notifications dependency, and instead go through ContentBrowserClient to show U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix browsertest Created 9 years, 6 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) 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 "content/browser/renderer_host/render_view_host.h" 5 #include "content/browser/renderer_host/render_view_host.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 13 matching lines...) Expand all
24 #include "content/browser/in_process_webkit/session_storage_namespace.h" 24 #include "content/browser/in_process_webkit/session_storage_namespace.h"
25 #include "content/browser/renderer_host/render_process_host.h" 25 #include "content/browser/renderer_host/render_process_host.h"
26 #include "content/browser/renderer_host/render_view_host_delegate.h" 26 #include "content/browser/renderer_host/render_view_host_delegate.h"
27 #include "content/browser/renderer_host/render_view_host_observer.h" 27 #include "content/browser/renderer_host/render_view_host_observer.h"
28 #include "content/browser/renderer_host/render_widget_host.h" 28 #include "content/browser/renderer_host/render_widget_host.h"
29 #include "content/browser/renderer_host/render_widget_host_view.h" 29 #include "content/browser/renderer_host/render_widget_host_view.h"
30 #include "content/browser/site_instance.h" 30 #include "content/browser/site_instance.h"
31 #include "content/browser/user_metrics.h" 31 #include "content/browser/user_metrics.h"
32 #include "content/common/bindings_policy.h" 32 #include "content/common/bindings_policy.h"
33 #include "content/common/content_constants.h" 33 #include "content/common/content_constants.h"
34 #include "content/common/desktop_notification_messages.h"
34 #include "content/common/drag_messages.h" 35 #include "content/common/drag_messages.h"
35 #include "content/common/native_web_keyboard_event.h" 36 #include "content/common/native_web_keyboard_event.h"
36 #include "content/common/notification_details.h" 37 #include "content/common/notification_details.h"
37 #include "content/common/notification_service.h" 38 #include "content/common/notification_service.h"
38 #include "content/common/notification_type.h" 39 #include "content/common/notification_type.h"
39 #include "content/common/result_codes.h" 40 #include "content/common/result_codes.h"
40 #include "content/common/swapped_out_messages.h" 41 #include "content/common/swapped_out_messages.h"
41 #include "content/common/url_constants.h" 42 #include "content/common/url_constants.h"
42 #include "content/common/view_messages.h" 43 #include "content/common/view_messages.h"
43 #include "net/base/net_util.h" 44 #include "net/base/net_util.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 415
415 void RenderViewHost::DragTargetDragLeave() { 416 void RenderViewHost::DragTargetDragLeave() {
416 Send(new DragMsg_TargetDragLeave(routing_id())); 417 Send(new DragMsg_TargetDragLeave(routing_id()));
417 } 418 }
418 419
419 void RenderViewHost::DragTargetDrop( 420 void RenderViewHost::DragTargetDrop(
420 const gfx::Point& client_pt, const gfx::Point& screen_pt) { 421 const gfx::Point& client_pt, const gfx::Point& screen_pt) {
421 Send(new DragMsg_TargetDrop(routing_id(), client_pt, screen_pt)); 422 Send(new DragMsg_TargetDrop(routing_id(), client_pt, screen_pt));
422 } 423 }
423 424
425 void RenderViewHost::DesktopNotificationPermissionRequestDone(
426 int callback_context) {
427 Send(new DesktopNotificationMsg_PermissionRequestDone(
428 routing_id(), callback_context));
429 }
430
431 void RenderViewHost::DesktopNotificationPostDisplay(int callback_context) {
432 Send(new DesktopNotificationMsg_PostDisplay(routing_id(), callback_context));
433 }
434
435 void RenderViewHost::DesktopNotificationPostError(int notification_id,
436 const string16& message) {
437 Send(new DesktopNotificationMsg_PostError(
438 routing_id(), notification_id, message));
439 }
440
441 void RenderViewHost::DesktopNotificationPostClose(int notification_id,
442 bool by_user) {
443 Send(new DesktopNotificationMsg_PostClose(
444 routing_id(), notification_id, by_user));
445 }
446
447 void RenderViewHost::DesktopNotificationPostClick(int notification_id) {
448 Send(new DesktopNotificationMsg_PostClick(routing_id(), notification_id));
449 }
450
424 void RenderViewHost::ExecuteJavascriptInWebFrame( 451 void RenderViewHost::ExecuteJavascriptInWebFrame(
425 const string16& frame_xpath, 452 const string16& frame_xpath,
426 const string16& jscript) { 453 const string16& jscript) {
427 Send(new ViewMsg_ScriptEvalRequest(routing_id(), frame_xpath, jscript, 454 Send(new ViewMsg_ScriptEvalRequest(routing_id(), frame_xpath, jscript,
428 0, false)); 455 0, false));
429 } 456 }
430 457
431 int RenderViewHost::ExecuteJavascriptInWebFrameNotifyResult( 458 int RenderViewHost::ExecuteJavascriptInWebFrameNotifyResult(
432 const string16& frame_xpath, 459 const string16& frame_xpath,
433 const string16& jscript) { 460 const string16& jscript) {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) 686 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor)
660 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) 687 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
661 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) 688 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole)
662 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) 689 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK)
663 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnMsgClosePageACK) 690 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnMsgClosePageACK)
664 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged) 691 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged)
665 IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications, 692 IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications,
666 OnAccessibilityNotifications) 693 OnAccessibilityNotifications)
667 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) 694 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse)
668 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) 695 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL)
696 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission,
697 OnRequestDesktopNotificationPermission)
698 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show,
699 OnShowDesktopNotification)
700 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel,
701 OnCancelDesktopNotification)
669 #if defined(OS_MACOSX) 702 #if defined(OS_MACOSX)
670 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) 703 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup)
671 #endif 704 #endif
672 // Have the super handle all other messages. 705 // Have the super handle all other messages.
673 IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg)) 706 IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg))
674 // NOTE: Do not add a message handler that just calls the delegate! 707 // NOTE: Do not add a message handler that just calls the delegate!
675 // Dispatch the message directly there instead. 708 // Dispatch the message directly there instead.
676 IPC_END_MESSAGE_MAP_EX() 709 IPC_END_MESSAGE_MAP_EX()
677 710
678 if (!msg_is_ok) { 711 if (!msg_is_ok) {
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 render_process_host->Send( 1256 render_process_host->Send(
1224 new ViewMsg_SetZoomLevelForCurrentURL(url, zoom_level)); 1257 new ViewMsg_SetZoomLevelForCurrentURL(url, zoom_level));
1225 } 1258 }
1226 } 1259 }
1227 } else { 1260 } else {
1228 host_zoom_map->SetTemporaryZoomLevel( 1261 host_zoom_map->SetTemporaryZoomLevel(
1229 process()->id(), routing_id(), zoom_level); 1262 process()->id(), routing_id(), zoom_level);
1230 } 1263 }
1231 } 1264 }
1232 1265
1266 void RenderViewHost::OnRequestDesktopNotificationPermission(
1267 const GURL& source_origin, int callback_context) {
1268 content::GetContentClient()->browser()->RequestDesktopNotificationPermission(
1269 source_origin, callback_context, process()->id(), routing_id());
1270 }
1271
1272 void RenderViewHost::OnShowDesktopNotification(
1273 const DesktopNotificationHostMsg_Show_Params& params) {
1274 // Disallow HTML notifications from unwanted schemes. javascript:
1275 // in particular allows unwanted cross-domain access.
1276 GURL url = params.contents_url;
1277 if (params.is_html &&
1278 !url.SchemeIs(chrome::kHttpScheme) &&
1279 !url.SchemeIs(chrome::kHttpsScheme) &&
1280 !url.SchemeIs(chrome::kExtensionScheme) &&
1281 !url.SchemeIs(chrome::kDataScheme)) {
1282 return;
1283 }
1284
1285 content::GetContentClient()->browser()->ShowDesktopNotification(
1286 params, process()->id(), routing_id(), false);
1287 }
1288
1289 void RenderViewHost::OnCancelDesktopNotification(int notification_id) {
1290 content::GetContentClient()->browser()->CancelDesktopNotification(
1291 process()->id(), routing_id(), notification_id);
1292 }
1293
1233 #if defined(OS_MACOSX) 1294 #if defined(OS_MACOSX)
1234 void RenderViewHost::OnMsgShowPopup( 1295 void RenderViewHost::OnMsgShowPopup(
1235 const ViewHostMsg_ShowPopup_Params& params) { 1296 const ViewHostMsg_ShowPopup_Params& params) {
1236 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 1297 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
1237 if (view) { 1298 if (view) {
1238 view->ShowPopupMenu(params.bounds, 1299 view->ShowPopupMenu(params.bounds,
1239 params.item_height, 1300 params.item_height,
1240 params.item_font_size, 1301 params.item_font_size,
1241 params.selected_item, 1302 params.selected_item,
1242 params.popup_items, 1303 params.popup_items,
1243 params.right_aligned); 1304 params.right_aligned);
1244 } 1305 }
1245 } 1306 }
1246 #endif 1307 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698