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