| 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/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 23 matching lines...) Expand all Loading... |
| 34 return; | 34 return; |
| 35 } | 35 } |
| 36 if (web_contents_) | 36 if (web_contents_) |
| 37 web_contents_->RemoveObserver(this); | 37 web_contents_->RemoveObserver(this); |
| 38 web_contents_ = static_cast<WebContentsImpl*>(web_contents); | 38 web_contents_ = static_cast<WebContentsImpl*>(web_contents); |
| 39 if (web_contents_) { | 39 if (web_contents_) { |
| 40 web_contents_->AddObserver(this); | 40 web_contents_->AddObserver(this); |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| 44 bool WebContentsObserver::OnMessageReceived( | |
| 45 const IPC::Message& message, | |
| 46 RenderFrameHost* render_frame_host) { | |
| 47 return false; | |
| 48 } | |
| 49 | |
| 50 bool WebContentsObserver::OnMessageReceived(const IPC::Message& message) { | 44 bool WebContentsObserver::OnMessageReceived(const IPC::Message& message) { |
| 51 return false; | 45 return false; |
| 52 } | 46 } |
| 53 | 47 |
| 54 bool WebContentsObserver::Send(IPC::Message* message) { | 48 bool WebContentsObserver::Send(IPC::Message* message) { |
| 55 if (!web_contents_) { | 49 if (!web_contents_) { |
| 56 delete message; | 50 delete message; |
| 57 return false; | 51 return false; |
| 58 } | 52 } |
| 59 | 53 |
| 60 return web_contents_->Send(message); | 54 return web_contents_->Send(message); |
| 61 } | 55 } |
| 62 | 56 |
| 63 int WebContentsObserver::routing_id() const { | 57 int WebContentsObserver::routing_id() const { |
| 64 if (!web_contents_) | 58 if (!web_contents_) |
| 65 return MSG_ROUTING_NONE; | 59 return MSG_ROUTING_NONE; |
| 66 | 60 |
| 67 return web_contents_->GetRoutingID(); | 61 return web_contents_->GetRoutingID(); |
| 68 } | 62 } |
| 69 | 63 |
| 70 void WebContentsObserver::WebContentsImplDestroyed() { | 64 void WebContentsObserver::WebContentsImplDestroyed() { |
| 71 // Do cleanup so that 'this' can safely be deleted from WebContentsDestroyed. | 65 // Do cleanup so that 'this' can safely be deleted from WebContentsDestroyed. |
| 72 web_contents_->RemoveObserver(this); | 66 web_contents_->RemoveObserver(this); |
| 73 WebContentsImpl* contents = web_contents_; | 67 WebContentsImpl* contents = web_contents_; |
| 74 web_contents_ = NULL; | 68 web_contents_ = NULL; |
| 75 WebContentsDestroyed(contents); | 69 WebContentsDestroyed(contents); |
| 76 } | 70 } |
| 77 | 71 |
| 78 } // namespace content | 72 } // namespace content |
| OLD | NEW |