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

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

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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
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 14 matching lines...) Expand all
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/content_constants.h" 32 #include "content/common/content_constants.h"
33 #include "content/common/desktop_notification_messages.h" 33 #include "content/common/desktop_notification_messages.h"
34 #include "content/common/drag_messages.h" 34 #include "content/common/drag_messages.h"
35 #include "content/common/notification_service.h" 35 #include "content/public/browser/notification_service.h"
36 #include "content/common/result_codes.h" 36 #include "content/common/result_codes.h"
37 #include "content/common/speech_input_messages.h" 37 #include "content/common/speech_input_messages.h"
38 #include "content/common/swapped_out_messages.h" 38 #include "content/common/swapped_out_messages.h"
39 #include "content/common/view_messages.h" 39 #include "content/common/view_messages.h"
40 #include "content/public/browser/native_web_keyboard_event.h" 40 #include "content/public/browser/native_web_keyboard_event.h"
41 #include "content/public/browser/notification_details.h" 41 #include "content/public/browser/notification_details.h"
42 #include "content/public/browser/notification_types.h" 42 #include "content/public/browser/notification_types.h"
43 #include "content/public/common/bindings_policy.h" 43 #include "content/public/common/bindings_policy.h"
44 #include "content/public/common/url_constants.h" 44 #include "content/public/common/url_constants.h"
45 #include "net/base/net_util.h" 45 #include "net/base/net_util.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 process()->browser_context()->GetWebKitContext()); 122 process()->browser_context()->GetWebKitContext());
123 } 123 }
124 124
125 DCHECK(instance_); 125 DCHECK(instance_);
126 CHECK(delegate_); // http://crbug.com/82827 126 CHECK(delegate_); // http://crbug.com/82827
127 127
128 process()->EnableSendQueue(); 128 process()->EnableSendQueue();
129 129
130 content::GetContentClient()->browser()->RenderViewHostCreated(this); 130 content::GetContentClient()->browser()->RenderViewHostCreated(this);
131 131
132 NotificationService::current()->Notify( 132 content::NotificationService::current()->Notify(
133 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED, 133 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED,
134 content::Source<RenderViewHost>(this), 134 content::Source<RenderViewHost>(this),
135 NotificationService::NoDetails()); 135 content::NotificationService::NoDetails());
136 } 136 }
137 137
138 RenderViewHost::~RenderViewHost() { 138 RenderViewHost::~RenderViewHost() {
139 FOR_EACH_OBSERVER( 139 FOR_EACH_OBSERVER(
140 RenderViewHostObserver, observers_, RenderViewHostDestruction()); 140 RenderViewHostObserver, observers_, RenderViewHostDestruction());
141 141
142 NotificationService::current()->Notify( 142 content::NotificationService::current()->Notify(
143 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, 143 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED,
144 content::Source<RenderViewHost>(this), 144 content::Source<RenderViewHost>(this),
145 NotificationService::NoDetails()); 145 content::NotificationService::NoDetails());
146 146
147 delegate()->RenderViewDeleted(this); 147 delegate()->RenderViewDeleted(this);
148 148
149 // Be sure to clean up any leftover state from cross-site requests. 149 // Be sure to clean up any leftover state from cross-site requests.
150 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( 150 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest(
151 process()->id(), routing_id(), false); 151 process()->id(), routing_id(), false);
152 } 152 }
153 153
154 bool RenderViewHost::CreateRenderView(const string16& frame_name) { 154 bool RenderViewHost::CreateRenderView(const string16& frame_name) {
155 DCHECK(!IsRenderViewLive()) << "Creating view twice"; 155 DCHECK(!IsRenderViewLive()) << "Creating view twice";
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 } 359 }
360 360
361 void RenderViewHost::ClosePage() { 361 void RenderViewHost::ClosePage() {
362 // Start the hang monitor in case the renderer hangs in the unload handler. 362 // Start the hang monitor in case the renderer hangs in the unload handler.
363 is_waiting_for_unload_ack_ = true; 363 is_waiting_for_unload_ack_ = true;
364 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 364 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
365 365
366 if (IsRenderViewLive()) { 366 if (IsRenderViewLive()) {
367 // TODO(creis): Should this be moved to Shutdown? It may not be called for 367 // TODO(creis): Should this be moved to Shutdown? It may not be called for
368 // RenderViewHosts that have been swapped out. 368 // RenderViewHosts that have been swapped out.
369 NotificationService::current()->Notify( 369 content::NotificationService::current()->Notify(
370 content::NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, 370 content::NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW,
371 content::Source<RenderViewHost>(this), 371 content::Source<RenderViewHost>(this),
372 NotificationService::NoDetails()); 372 content::NotificationService::NoDetails());
373 373
374 Send(new ViewMsg_ClosePage(routing_id())); 374 Send(new ViewMsg_ClosePage(routing_id()));
375 } else { 375 } else {
376 // This RenderViewHost doesn't have a live renderer, so just skip the unload 376 // This RenderViewHost doesn't have a live renderer, so just skip the unload
377 // event and close the page. 377 // event and close the page.
378 ClosePageIgnoringUnloadEvents(); 378 ClosePageIgnoringUnloadEvents();
379 } 379 }
380 } 380 }
381 381
382 void RenderViewHost::ClosePageIgnoringUnloadEvents() { 382 void RenderViewHost::ClosePageIgnoringUnloadEvents() {
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 } 1059 }
1060 } 1060 }
1061 1061
1062 void RenderViewHost::OnUpdateDragCursor(WebDragOperation current_op) { 1062 void RenderViewHost::OnUpdateDragCursor(WebDragOperation current_op) {
1063 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 1063 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
1064 if (view) 1064 if (view)
1065 view->UpdateDragCursor(current_op); 1065 view->UpdateDragCursor(current_op);
1066 } 1066 }
1067 1067
1068 void RenderViewHost::OnTargetDropACK() { 1068 void RenderViewHost::OnTargetDropACK() {
1069 NotificationService::current()->Notify( 1069 content::NotificationService::current()->Notify(
1070 content::NOTIFICATION_RENDER_VIEW_HOST_DID_RECEIVE_DRAG_TARGET_DROP_ACK, 1070 content::NOTIFICATION_RENDER_VIEW_HOST_DID_RECEIVE_DRAG_TARGET_DROP_ACK,
1071 content::Source<RenderViewHost>(this), 1071 content::Source<RenderViewHost>(this),
1072 NotificationService::NoDetails()); 1072 content::NotificationService::NoDetails());
1073 } 1073 }
1074 1074
1075 void RenderViewHost::OnTakeFocus(bool reverse) { 1075 void RenderViewHost::OnTakeFocus(bool reverse) {
1076 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 1076 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
1077 if (view) 1077 if (view)
1078 view->TakeFocus(reverse); 1078 view->TakeFocus(reverse);
1079 } 1079 }
1080 1080
1081 void RenderViewHost::OnAddMessageToConsole(int32 level, 1081 void RenderViewHost::OnAddMessageToConsole(int32 level,
1082 const string16& message, 1082 const string16& message,
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 if (!params.empty()) { 1329 if (!params.empty()) {
1330 for (unsigned i = 0; i < params.size(); i++) { 1330 for (unsigned i = 0; i < params.size(); i++) {
1331 const ViewHostMsg_AccessibilityNotification_Params& param = params[i]; 1331 const ViewHostMsg_AccessibilityNotification_Params& param = params[i];
1332 1332
1333 if (param.notification_type == ViewHostMsg_AccEvent::LOAD_COMPLETE && 1333 if (param.notification_type == ViewHostMsg_AccEvent::LOAD_COMPLETE &&
1334 save_accessibility_tree_for_testing_) { 1334 save_accessibility_tree_for_testing_) {
1335 accessibility_tree_ = param.acc_tree; 1335 accessibility_tree_ = param.acc_tree;
1336 } 1336 }
1337 } 1337 }
1338 1338
1339 NotificationService::current()->Notify( 1339 content::NotificationService::current()->Notify(
1340 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 1340 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
1341 content::Source<RenderViewHost>(this), 1341 content::Source<RenderViewHost>(this),
1342 NotificationService::NoDetails()); 1342 content::NotificationService::NoDetails());
1343 } 1343 }
1344 1344
1345 Send(new ViewMsg_AccessibilityNotifications_ACK(routing_id())); 1345 Send(new ViewMsg_AccessibilityNotifications_ACK(routing_id()));
1346 } 1346 }
1347 1347
1348 void RenderViewHost::OnScriptEvalResponse(int id, const ListValue& result) { 1348 void RenderViewHost::OnScriptEvalResponse(int id, const ListValue& result) {
1349 Value* result_value; 1349 Value* result_value;
1350 if (!result.Get(0, &result_value)) { 1350 if (!result.Get(0, &result_value)) {
1351 // Programming error or rogue renderer. 1351 // Programming error or rogue renderer.
1352 NOTREACHED() << "Got bad arguments for OnScriptEvalResponse"; 1352 NOTREACHED() << "Got bad arguments for OnScriptEvalResponse";
1353 return; 1353 return;
1354 } 1354 }
1355 std::pair<int, Value*> details(id, result_value); 1355 std::pair<int, Value*> details(id, result_value);
1356 NotificationService::current()->Notify( 1356 content::NotificationService::current()->Notify(
1357 content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, 1357 content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT,
1358 content::Source<RenderViewHost>(this), 1358 content::Source<RenderViewHost>(this),
1359 content::Details<std::pair<int, Value*> >(&details)); 1359 content::Details<std::pair<int, Value*> >(&details));
1360 } 1360 }
1361 1361
1362 void RenderViewHost::OnDidZoomURL(double zoom_level, 1362 void RenderViewHost::OnDidZoomURL(double zoom_level,
1363 bool remember, 1363 bool remember,
1364 const GURL& url) { 1364 const GURL& url) {
1365 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1365 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1366 HostZoomMap* host_zoom_map = process()->browser_context()->GetHostZoomMap(); 1366 HostZoomMap* host_zoom_map = process()->browser_context()->GetHostZoomMap();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 void RenderViewHost::OnRunFileChooser( 1426 void RenderViewHost::OnRunFileChooser(
1427 const ViewHostMsg_RunFileChooser_Params& params) { 1427 const ViewHostMsg_RunFileChooser_Params& params) {
1428 delegate_->RunFileChooser(this, params); 1428 delegate_->RunFileChooser(this, params);
1429 } 1429 }
1430 1430
1431 void RenderViewHost::OnWebUISend(const GURL& source_url, 1431 void RenderViewHost::OnWebUISend(const GURL& source_url,
1432 const std::string& name, 1432 const std::string& name,
1433 const base::ListValue& args) { 1433 const base::ListValue& args) {
1434 delegate_->WebUISend(this, source_url, name, args); 1434 delegate_->WebUISend(this, source_url, name, args);
1435 } 1435 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698