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

Side by Side Diff: content/public/browser/web_contents_observer.cc

Issue 10830337: Add IPC::Sender and GetRoutingID() to WebContents for convenience and safety. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR Created 8 years, 4 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 | « content/public/browser/web_contents.h ('k') | no next file » | 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) 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/public/browser/web_contents_observer.h" 5 #include "content/public/browser/web_contents_observer.h"
6 6
7 #include "content/browser/web_contents/web_contents_impl.h" 7 #include "content/browser/web_contents/web_contents_impl.h"
8 #include "content/public/browser/navigation_details.h" 8 #include "content/public/browser/navigation_details.h"
9 #include "content/public/browser/render_view_host.h" 9 #include "content/public/browser/render_view_host.h"
10 10
(...skipping 24 matching lines...) Expand all
35 if (web_contents_) { 35 if (web_contents_) {
36 web_contents_->AddObserver(this); 36 web_contents_->AddObserver(this);
37 } 37 }
38 } 38 }
39 39
40 bool WebContentsObserver::OnMessageReceived(const IPC::Message& message) { 40 bool WebContentsObserver::OnMessageReceived(const IPC::Message& message) {
41 return false; 41 return false;
42 } 42 }
43 43
44 bool WebContentsObserver::Send(IPC::Message* message) { 44 bool WebContentsObserver::Send(IPC::Message* message) {
45 if (!web_contents_ || !web_contents_->GetRenderViewHost()) { 45 if (!web_contents_) {
46 delete message; 46 delete message;
47 return false; 47 return false;
48 } 48 }
49 49
50 return web_contents_->GetRenderViewHost()->Send(message); 50 return web_contents_->Send(message);
51 } 51 }
52 52
53 int WebContentsObserver::routing_id() const { 53 int WebContentsObserver::routing_id() const {
54 if (!web_contents_ || !web_contents_->GetRenderViewHost()) 54 if (!web_contents_)
55 return MSG_ROUTING_NONE; 55 return MSG_ROUTING_NONE;
56 56
57 return web_contents_->GetRenderViewHost()->GetRoutingID(); 57 return web_contents_->GetRoutingID();
58 } 58 }
59 59
60 void WebContentsObserver::WebContentsImplDestroyed() { 60 void WebContentsObserver::WebContentsImplDestroyed() {
61 // Do cleanup so that 'this' can safely be deleted from WebContentsDestroyed. 61 // Do cleanup so that 'this' can safely be deleted from WebContentsDestroyed.
62 web_contents_->RemoveObserver(this); 62 web_contents_->RemoveObserver(this);
63 WebContentsImpl* contents = web_contents_; 63 WebContentsImpl* contents = web_contents_;
64 web_contents_ = NULL; 64 web_contents_ = NULL;
65 WebContentsDestroyed(contents); 65 WebContentsDestroyed(contents);
66 } 66 }
67 67
68 } // namespace content 68 } // namespace content
OLDNEW
« no previous file with comments | « content/public/browser/web_contents.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698