OLD | NEW |
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/tab_contents/tab_contents_observer.h" | 5 #include "content/browser/tab_contents/tab_contents_observer.h" |
6 | 6 |
7 #include "content/browser/renderer_host/render_view_host.h" | 7 #include "content/browser/renderer_host/render_view_host.h" |
8 #include "content/browser/tab_contents/tab_contents.h" | 8 #include "content/browser/tab_contents/tab_contents.h" |
9 | 9 |
10 TabContentsObserver::Registrar::Registrar(TabContentsObserver* observer) | 10 TabContentsObserver::Registrar::Registrar(TabContentsObserver* observer) |
11 : observer_(observer), tab_(NULL) { | 11 : observer_(observer), tab_(NULL) { |
12 } | 12 } |
13 | 13 |
14 TabContentsObserver::Registrar::~Registrar() { | 14 TabContentsObserver::Registrar::~Registrar() { |
15 if (tab_) | 15 if (tab_) |
16 tab_->RemoveObserver(observer_); | 16 tab_->RemoveObserver(observer_); |
17 } | 17 } |
18 | 18 |
19 void TabContentsObserver::Registrar::Observe(TabContents* tab) { | 19 void TabContentsObserver::Registrar::Observe(TabContents* tab) { |
20 observer_->SetTabContents(tab); | 20 observer_->SetTabContents(tab); |
21 if (tab_) | 21 if (tab_) |
22 tab_->RemoveObserver(observer_); | 22 tab_->RemoveObserver(observer_); |
23 tab_ = tab; | 23 tab_ = tab; |
24 if (tab_) | 24 if (tab_) |
25 tab_->AddObserver(observer_); | 25 tab_->AddObserver(observer_); |
26 } | 26 } |
27 | 27 |
28 void TabContentsObserver::NavigateToPendingEntry( | 28 void TabContentsObserver::NavigateToPendingEntry( |
29 const GURL& url, | 29 const GURL& url, |
30 NavigationController::ReloadType reload_type) { | 30 NavigationController::ReloadType reload_type) { |
31 } | 31 } |
32 | 32 |
33 void TabContentsObserver::DidNavigateMainFramePostCommit( | 33 void TabContentsObserver::DidNavigateMainFramePostCommit( |
34 const NavigationController::LoadCommittedDetails& details, | 34 const NavigationController::LoadCommittedDetails& details, |
35 const ViewHostMsg_FrameNavigate_Params& params) { | 35 const ViewHostMsg_FrameNavigate_Params& params) { |
36 } | 36 } |
37 | 37 |
38 void TabContentsObserver::DidNavigateAnyFramePostCommit( | 38 void TabContentsObserver::DidNavigateAnyFramePostCommit( |
39 const NavigationController::LoadCommittedDetails& details, | 39 const NavigationController::LoadCommittedDetails& details, |
40 const ViewHostMsg_FrameNavigate_Params& params) { | 40 const ViewHostMsg_FrameNavigate_Params& params) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } | 137 } |
138 | 138 |
139 void TabContentsObserver::TabContentsDestroyed() { | 139 void TabContentsObserver::TabContentsDestroyed() { |
140 // Do cleanup so that 'this' can safely be deleted from | 140 // Do cleanup so that 'this' can safely be deleted from |
141 // TabContentsDestroyed. | 141 // TabContentsDestroyed. |
142 tab_contents_->RemoveObserver(this); | 142 tab_contents_->RemoveObserver(this); |
143 TabContents* tab = tab_contents_; | 143 TabContents* tab = tab_contents_; |
144 tab_contents_ = NULL; | 144 tab_contents_ = NULL; |
145 TabContentsDestroyed(tab); | 145 TabContentsDestroyed(tab); |
146 } | 146 } |
OLD | NEW |