| Index: content/browser/tab_contents/tab_contents_observer.cc
|
| ===================================================================
|
| --- content/browser/tab_contents/tab_contents_observer.cc (revision 80315)
|
| +++ content/browser/tab_contents/tab_contents_observer.cc (working copy)
|
| @@ -7,6 +7,24 @@
|
| #include "content/browser/renderer_host/render_view_host.h"
|
| #include "content/browser/tab_contents/tab_contents.h"
|
|
|
| +TabContentsObserver::Registrar::Registrar(TabContentsObserver* observer)
|
| + : observer_(observer), tab_(NULL) {
|
| +}
|
| +
|
| +TabContentsObserver::Registrar::~Registrar() {
|
| + if (tab_)
|
| + tab_->RemoveObserver(observer_);
|
| +}
|
| +
|
| +void TabContentsObserver::Registrar::Observe(TabContents* tab) {
|
| + observer_->SetTabContents(tab);
|
| + if (tab_)
|
| + tab_->RemoveObserver(observer_);
|
| + tab_ = tab;
|
| + if (tab_)
|
| + tab_->AddObserver(observer_);
|
| +}
|
| +
|
| void TabContentsObserver::NavigateToPendingEntry() {
|
| }
|
|
|
| @@ -35,12 +53,15 @@
|
| void TabContentsObserver::StopNavigation() {
|
| }
|
|
|
| -TabContentsObserver::TabContentsObserver(TabContents* tab_contents)
|
| - : tab_contents_(tab_contents),
|
| - routing_id_(tab_contents->render_view_host()->routing_id()) {
|
| +TabContentsObserver::TabContentsObserver(TabContents* tab_contents) {
|
| + SetTabContents(tab_contents);
|
| tab_contents_->AddObserver(this);
|
| }
|
|
|
| +TabContentsObserver::TabContentsObserver()
|
| + : tab_contents_(NULL), routing_id_(MSG_ROUTING_NONE) {
|
| +}
|
| +
|
| TabContentsObserver::~TabContentsObserver() {
|
| if (tab_contents_)
|
| tab_contents_->RemoveObserver(this);
|
| @@ -62,6 +83,12 @@
|
| return tab_contents_->render_view_host()->Send(message);
|
| }
|
|
|
| +void TabContentsObserver::SetTabContents(TabContents* tab_contents) {
|
| + tab_contents_ = tab_contents;
|
| + if (tab_contents_)
|
| + routing_id_ = tab_contents->render_view_host()->routing_id();
|
| +}
|
| +
|
| void TabContentsObserver::TabContentsDestroyed() {
|
| // Do cleanup so that 'this' can safely be deleted from
|
| // OnTabContentsDestroyed.
|
|
|