Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: chrome/browser/ui/tabs/tab_strip_model.cc

Issue 225093019: Zoom Extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 bool reset_group_on_select() const { return reset_group_on_select_; } 153 bool reset_group_on_select() const { return reset_group_on_select_; }
154 void set_reset_group_on_select(bool value) { reset_group_on_select_ = value; } 154 void set_reset_group_on_select(bool value) { reset_group_on_select_ = value; }
155 bool pinned() const { return pinned_; } 155 bool pinned() const { return pinned_; }
156 void set_pinned(bool value) { pinned_ = value; } 156 void set_pinned(bool value) { pinned_ = value; }
157 bool blocked() const { return blocked_; } 157 bool blocked() const { return blocked_; }
158 void set_blocked(bool value) { blocked_ = value; } 158 void set_blocked(bool value) { blocked_ = value; }
159 bool discarded() const { return discarded_; } 159 bool discarded() const { return discarded_; }
160 void set_discarded(bool value) { discarded_ = value; } 160 void set_discarded(bool value) { discarded_ = value; }
161 161
162 private: 162 private:
163 // Notify observers when a WebContents zooms.
164 virtual void DidSetZoomLevel(double old_zoom_level,
165 double new_zoom_level,
166 content::ZoomMode zoom_mode) OVERRIDE;
167
163 // Make sure that if someone deletes this WebContents out from under us, it 168 // Make sure that if someone deletes this WebContents out from under us, it
164 // is properly removed from the tab strip. 169 // is properly removed from the tab strip.
165 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; 170 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE;
166 171
167 // The WebContents being tracked by this WebContentsData. The 172 // The WebContents being tracked by this WebContentsData. The
168 // WebContentsObserver does keep a reference, but when the WebContents is 173 // WebContentsObserver does keep a reference, but when the WebContents is
169 // deleted, the WebContentsObserver reference is NULLed and thus inaccessible. 174 // deleted, the WebContentsObserver reference is NULLed and thus inaccessible.
170 WebContents* contents_; 175 WebContents* contents_;
171 176
172 // The TabStripModel containing this WebContents. 177 // The TabStripModel containing this WebContents.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 pinned_(false), 223 pinned_(false),
219 blocked_(false), 224 blocked_(false),
220 discarded_(false) { 225 discarded_(false) {
221 } 226 }
222 227
223 void TabStripModel::WebContentsData::SetWebContents(WebContents* contents) { 228 void TabStripModel::WebContentsData::SetWebContents(WebContents* contents) {
224 contents_ = contents; 229 contents_ = contents;
225 Observe(contents); 230 Observe(contents);
226 } 231 }
227 232
233 void TabStripModel::WebContentsData::DidSetZoomLevel(
234 double old_zoom_level,
235 double new_zoom_level,
236 content::ZoomMode zoom_mode) {
237 DCHECK(contents_);
238 tab_strip_model_->WebContentsZoomChange(contents_, old_zoom_level,
239 new_zoom_level, zoom_mode);
240 }
241
228 void TabStripModel::WebContentsData::WebContentsDestroyed( 242 void TabStripModel::WebContentsData::WebContentsDestroyed(
229 WebContents* web_contents) { 243 WebContents* web_contents) {
230 DCHECK_EQ(contents_, web_contents); 244 DCHECK_EQ(contents_, web_contents);
231 245
232 // Note that we only detach the contents here, not close it - it's 246 // Note that we only detach the contents here, not close it - it's
233 // already been closed. We just want to undo our bookkeeping. 247 // already been closed. We just want to undo our bookkeeping.
234 int index = tab_strip_model_->GetIndexOfWebContents(web_contents); 248 int index = tab_strip_model_->GetIndexOfWebContents(web_contents);
235 DCHECK_NE(TabStripModel::kNoTab, index); 249 DCHECK_NE(TabStripModel::kNoTab, index);
236 tab_strip_model_->DetachWebContentsAt(index); 250 tab_strip_model_->DetachWebContentsAt(index);
237 } 251 }
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 DCHECK(ContainsIndex(index)); 789 DCHECK(ContainsIndex(index));
776 return selection_model_.IsSelected(index); 790 return selection_model_.IsSelected(index);
777 } 791 }
778 792
779 void TabStripModel::SetSelectionFromModel( 793 void TabStripModel::SetSelectionFromModel(
780 const ui::ListSelectionModel& source) { 794 const ui::ListSelectionModel& source) {
781 DCHECK_NE(ui::ListSelectionModel::kUnselectedIndex, source.active()); 795 DCHECK_NE(ui::ListSelectionModel::kUnselectedIndex, source.active());
782 SetSelection(source, NOTIFY_DEFAULT); 796 SetSelection(source, NOTIFY_DEFAULT);
783 } 797 }
784 798
799 void TabStripModel::WebContentsZoomChange(content::WebContents* contents,
800 double old_zoom_level,
801 double new_zoom_level,
802 content::ZoomMode zoom_mode) {
803 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
804 TabZoomChange(contents, old_zoom_level,
805 new_zoom_level, zoom_mode));
806 }
807
785 void TabStripModel::AddWebContents(WebContents* contents, 808 void TabStripModel::AddWebContents(WebContents* contents,
786 int index, 809 int index,
787 content::PageTransition transition, 810 content::PageTransition transition,
788 int add_types) { 811 int add_types) {
789 // If the newly-opened tab is part of the same task as the parent tab, we want 812 // If the newly-opened tab is part of the same task as the parent tab, we want
790 // to inherit the parent's "group" attribute, so that if this tab is then 813 // to inherit the parent's "group" attribute, so that if this tab is then
791 // closed we'll jump back to the parent tab. 814 // closed we'll jump back to the parent tab.
792 bool inherit_group = (add_types & ADD_INHERIT_GROUP) == ADD_INHERIT_GROUP; 815 bool inherit_group = (add_types & ADD_INHERIT_GROUP) == ADD_INHERIT_GROUP;
793 816
794 if (transition == content::PAGE_TRANSITION_LINK && 817 if (transition == content::PAGE_TRANSITION_LINK &&
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 void TabStripModel::ForgetOpenersAndGroupsReferencing( 1420 void TabStripModel::ForgetOpenersAndGroupsReferencing(
1398 const WebContents* tab) { 1421 const WebContents* tab) {
1399 for (WebContentsDataVector::const_iterator i = contents_data_.begin(); 1422 for (WebContentsDataVector::const_iterator i = contents_data_.begin();
1400 i != contents_data_.end(); ++i) { 1423 i != contents_data_.end(); ++i) {
1401 if ((*i)->group() == tab) 1424 if ((*i)->group() == tab)
1402 (*i)->set_group(NULL); 1425 (*i)->set_group(NULL);
1403 if ((*i)->opener() == tab) 1426 if ((*i)->opener() == tab)
1404 (*i)->set_opener(NULL); 1427 (*i)->set_opener(NULL);
1405 } 1428 }
1406 } 1429 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698