| 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 "chrome/browser/ui/tabs/tab_strip_model.h" | 5 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 DeletionObserver(CloseTracker* parent, WebContents* web_contents) | 66 DeletionObserver(CloseTracker* parent, WebContents* web_contents) |
| 67 : WebContentsObserver(web_contents), | 67 : WebContentsObserver(web_contents), |
| 68 parent_(parent) { | 68 parent_(parent) { |
| 69 } | 69 } |
| 70 | 70 |
| 71 // Expose web_contents() publicly. | 71 // Expose web_contents() publicly. |
| 72 using content::WebContentsObserver::web_contents; | 72 using content::WebContentsObserver::web_contents; |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 // WebContentsObserver: | 75 // WebContentsObserver: |
| 76 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE { | 76 virtual void WebContentsDestroyed() OVERRIDE { |
| 77 parent_->OnWebContentsDestroyed(this); | 77 parent_->OnWebContentsDestroyed(this); |
| 78 } | 78 } |
| 79 | 79 |
| 80 CloseTracker* parent_; | 80 CloseTracker* parent_; |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(DeletionObserver); | 82 DISALLOW_COPY_AND_ASSIGN(DeletionObserver); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 void OnWebContentsDestroyed(DeletionObserver* observer); | 85 void OnWebContentsDestroyed(DeletionObserver* observer); |
| 86 | 86 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 bool pinned() const { return pinned_; } | 154 bool pinned() const { return pinned_; } |
| 155 void set_pinned(bool value) { pinned_ = value; } | 155 void set_pinned(bool value) { pinned_ = value; } |
| 156 bool blocked() const { return blocked_; } | 156 bool blocked() const { return blocked_; } |
| 157 void set_blocked(bool value) { blocked_ = value; } | 157 void set_blocked(bool value) { blocked_ = value; } |
| 158 bool discarded() const { return discarded_; } | 158 bool discarded() const { return discarded_; } |
| 159 void set_discarded(bool value) { discarded_ = value; } | 159 void set_discarded(bool value) { discarded_ = value; } |
| 160 | 160 |
| 161 private: | 161 private: |
| 162 // Make sure that if someone deletes this WebContents out from under us, it | 162 // Make sure that if someone deletes this WebContents out from under us, it |
| 163 // is properly removed from the tab strip. | 163 // is properly removed from the tab strip. |
| 164 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; | 164 virtual void WebContentsDestroyed() OVERRIDE; |
| 165 | 165 |
| 166 // The WebContents being tracked by this WebContentsData. The | 166 // The WebContents being tracked by this WebContentsData. The |
| 167 // WebContentsObserver does keep a reference, but when the WebContents is | 167 // WebContentsObserver does keep a reference, but when the WebContents is |
| 168 // deleted, the WebContentsObserver reference is NULLed and thus inaccessible. | 168 // deleted, the WebContentsObserver reference is NULLed and thus inaccessible. |
| 169 WebContents* contents_; | 169 WebContents* contents_; |
| 170 | 170 |
| 171 // The TabStripModel containing this WebContents. | 171 // The TabStripModel containing this WebContents. |
| 172 TabStripModel* tab_strip_model_; | 172 TabStripModel* tab_strip_model_; |
| 173 | 173 |
| 174 // The group is used to model a set of tabs spawned from a single parent | 174 // The group is used to model a set of tabs spawned from a single parent |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 pinned_(false), | 217 pinned_(false), |
| 218 blocked_(false), | 218 blocked_(false), |
| 219 discarded_(false) { | 219 discarded_(false) { |
| 220 } | 220 } |
| 221 | 221 |
| 222 void TabStripModel::WebContentsData::SetWebContents(WebContents* contents) { | 222 void TabStripModel::WebContentsData::SetWebContents(WebContents* contents) { |
| 223 contents_ = contents; | 223 contents_ = contents; |
| 224 Observe(contents); | 224 Observe(contents); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void TabStripModel::WebContentsData::WebContentsDestroyed( | 227 void TabStripModel::WebContentsData::WebContentsDestroyed() { |
| 228 WebContents* web_contents) { | 228 DCHECK_EQ(contents_, web_contents()); |
| 229 DCHECK_EQ(contents_, web_contents); | |
| 230 | 229 |
| 231 // Note that we only detach the contents here, not close it - it's | 230 // Note that we only detach the contents here, not close it - it's |
| 232 // already been closed. We just want to undo our bookkeeping. | 231 // already been closed. We just want to undo our bookkeeping. |
| 233 int index = tab_strip_model_->GetIndexOfWebContents(web_contents); | 232 int index = tab_strip_model_->GetIndexOfWebContents(web_contents()); |
| 234 DCHECK_NE(TabStripModel::kNoTab, index); | 233 DCHECK_NE(TabStripModel::kNoTab, index); |
| 235 tab_strip_model_->DetachWebContentsAt(index); | 234 tab_strip_model_->DetachWebContentsAt(index); |
| 236 } | 235 } |
| 237 | 236 |
| 238 /////////////////////////////////////////////////////////////////////////////// | 237 /////////////////////////////////////////////////////////////////////////////// |
| 239 // TabStripModel, public: | 238 // TabStripModel, public: |
| 240 | 239 |
| 241 TabStripModel::TabStripModel(TabStripModelDelegate* delegate, Profile* profile) | 240 TabStripModel::TabStripModel(TabStripModelDelegate* delegate, Profile* profile) |
| 242 : delegate_(delegate), | 241 : delegate_(delegate), |
| 243 profile_(profile), | 242 profile_(profile), |
| (...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 void TabStripModel::ForgetOpenersAndGroupsReferencing( | 1406 void TabStripModel::ForgetOpenersAndGroupsReferencing( |
| 1408 const WebContents* tab) { | 1407 const WebContents* tab) { |
| 1409 for (WebContentsDataVector::const_iterator i = contents_data_.begin(); | 1408 for (WebContentsDataVector::const_iterator i = contents_data_.begin(); |
| 1410 i != contents_data_.end(); ++i) { | 1409 i != contents_data_.end(); ++i) { |
| 1411 if ((*i)->group() == tab) | 1410 if ((*i)->group() == tab) |
| 1412 (*i)->set_group(NULL); | 1411 (*i)->set_group(NULL); |
| 1413 if ((*i)->opener() == tab) | 1412 if ((*i)->opener() == tab) |
| 1414 (*i)->set_opener(NULL); | 1413 (*i)->set_opener(NULL); |
| 1415 } | 1414 } |
| 1416 } | 1415 } |
| OLD | NEW |