OLD | NEW |
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/renderer_host/render_view_host_impl.h" | |
8 #include "content/browser/web_contents/web_contents_impl.h" | 7 #include "content/browser/web_contents/web_contents_impl.h" |
9 #include "content/public/browser/navigation_details.h" | 8 #include "content/public/browser/navigation_details.h" |
| 9 #include "content/public/browser/render_view_host.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 WebContentsObserver::WebContentsObserver(WebContents* web_contents) | 13 WebContentsObserver::WebContentsObserver(WebContents* web_contents) |
14 : web_contents_(NULL) { | 14 : web_contents_(NULL) { |
15 Observe(web_contents); | 15 Observe(web_contents); |
16 } | 16 } |
17 | 17 |
18 WebContentsObserver::WebContentsObserver() | 18 WebContentsObserver::WebContentsObserver() |
19 : web_contents_(NULL) { | 19 : web_contents_(NULL) { |
(...skipping 20 matching lines...) Expand all Loading... |
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_ || !web_contents_->GetRenderViewHost()) { |
46 delete message; | 46 delete message; |
47 return false; | 47 return false; |
48 } | 48 } |
49 | 49 |
50 return static_cast<RenderViewHostImpl*>( | 50 return web_contents_->GetRenderViewHost()->Send(message); |
51 web_contents_->GetRenderViewHost())->Send(message); | |
52 } | 51 } |
53 | 52 |
54 int WebContentsObserver::routing_id() const { | 53 int WebContentsObserver::routing_id() const { |
55 if (!web_contents_ || !web_contents_->GetRenderViewHost()) | 54 if (!web_contents_ || !web_contents_->GetRenderViewHost()) |
56 return MSG_ROUTING_NONE; | 55 return MSG_ROUTING_NONE; |
57 | 56 |
58 return web_contents_->GetRenderViewHost()->GetRoutingID(); | 57 return web_contents_->GetRenderViewHost()->GetRoutingID(); |
59 } | 58 } |
60 | 59 |
61 void WebContentsObserver::WebContentsImplDestroyed() { | 60 void WebContentsObserver::WebContentsImplDestroyed() { |
62 // Do cleanup so that 'this' can safely be deleted from WebContentsDestroyed. | 61 // Do cleanup so that 'this' can safely be deleted from WebContentsDestroyed. |
63 web_contents_->RemoveObserver(this); | 62 web_contents_->RemoveObserver(this); |
64 WebContentsImpl* contents = web_contents_; | 63 WebContentsImpl* contents = web_contents_; |
65 web_contents_ = NULL; | 64 web_contents_ = NULL; |
66 WebContentsDestroyed(contents); | 65 WebContentsDestroyed(contents); |
67 } | 66 } |
68 | 67 |
69 } // namespace content | 68 } // namespace content |
OLD | NEW |