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

Side by Side Diff: chrome/browser/views/tabs/tab.cc

Issue 1725006: Changes the tab menu to use pin and unpin instead of a check. The mac (Closed)
Patch Set: Merged with tip of tree and updated unit tests Created 10 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
« no previous file with comments | « chrome/browser/tab_menu_model_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/tabs/tab.h" 5 #include "chrome/browser/views/tabs/tab.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/menus/simple_menu_model.h" 8 #include "app/menus/simple_menu_model.h"
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 11 matching lines...) Expand all
22 22
23 const std::string Tab::kTabClassName = "browser/tabs/Tab"; 23 const std::string Tab::kTabClassName = "browser/tabs/Tab";
24 24
25 static const SkScalar kTabCapWidth = 15; 25 static const SkScalar kTabCapWidth = 15;
26 static const SkScalar kTabTopCurveWidth = 4; 26 static const SkScalar kTabTopCurveWidth = 4;
27 static const SkScalar kTabBottomCurveWidth = 3; 27 static const SkScalar kTabBottomCurveWidth = 3;
28 28
29 class Tab::TabContextMenuContents : public menus::SimpleMenuModel::Delegate { 29 class Tab::TabContextMenuContents : public menus::SimpleMenuModel::Delegate {
30 public: 30 public:
31 explicit TabContextMenuContents(Tab* tab) 31 explicit TabContextMenuContents(Tab* tab)
32 : ALLOW_THIS_IN_INITIALIZER_LIST(model_(this)), 32 : ALLOW_THIS_IN_INITIALIZER_LIST(
33 model_(this, tab->delegate()->IsTabPinned(tab))),
33 tab_(tab), 34 tab_(tab),
34 last_command_(TabStripModel::CommandFirst) { 35 last_command_(TabStripModel::CommandFirst) {
35 Build(); 36 Build();
36 } 37 }
37 virtual ~TabContextMenuContents() { 38 virtual ~TabContextMenuContents() {
38 menu_->CancelMenu(); 39 menu_->CancelMenu();
39 tab_->delegate()->StopAllHighlighting(); 40 tab_->delegate()->StopAllHighlighting();
40 } 41 }
41 42
42 void RunMenuAt(const gfx::Point& point) { 43 void RunMenuAt(const gfx::Point& point) {
43 // Save a pointer to delegate before we call RunMenuAt, because it runs a 44 // Save a pointer to delegate before we call RunMenuAt, because it runs a
44 // nested message loop that may not return until after we are deleted. 45 // nested message loop that may not return until after we are deleted.
45 Tab::TabDelegate* delegate = tab_->delegate(); 46 Tab::TabDelegate* delegate = tab_->delegate();
46 menu_->RunMenuAt(point, views::Menu2::ALIGN_TOPLEFT); 47 menu_->RunMenuAt(point, views::Menu2::ALIGN_TOPLEFT);
47 // We could be gone now. Assume |this| is junk! 48 // We could be gone now. Assume |this| is junk!
48 if (delegate) 49 if (delegate)
49 delegate->StopAllHighlighting(); 50 delegate->StopAllHighlighting();
50 } 51 }
51 52
52 // Overridden from menus::SimpleMenuModel::Delegate: 53 // Overridden from menus::SimpleMenuModel::Delegate:
53 virtual bool IsCommandIdChecked(int command_id) const { 54 virtual bool IsCommandIdChecked(int command_id) const {
54 if (!tab_ || command_id != TabStripModel::CommandTogglePinned) 55 return false;
55 return false;
56 return tab_->delegate()->IsTabPinned(tab_);
57 } 56 }
58 virtual bool IsCommandIdEnabled(int command_id) const { 57 virtual bool IsCommandIdEnabled(int command_id) const {
59 return tab_ && tab_->delegate()->IsCommandEnabledForTab( 58 return tab_ && tab_->delegate()->IsCommandEnabledForTab(
60 static_cast<TabStripModel::ContextMenuCommand>(command_id), 59 static_cast<TabStripModel::ContextMenuCommand>(command_id),
61 tab_); 60 tab_);
62 } 61 }
63 virtual bool GetAcceleratorForCommandId( 62 virtual bool GetAcceleratorForCommandId(
64 int command_id, 63 int command_id,
65 menus::Accelerator* accelerator) { 64 menus::Accelerator* accelerator) {
66 return tab_->GetWidget()->GetAccelerator(command_id, accelerator); 65 return tab_->GetWidget()->GetAccelerator(command_id, accelerator);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 *role = AccessibilityTypes::ROLE_PAGETAB; 194 *role = AccessibilityTypes::ROLE_PAGETAB;
196 return true; 195 return true;
197 } 196 }
198 197
199 /////////////////////////////////////////////////////////////////////////////// 198 ///////////////////////////////////////////////////////////////////////////////
200 // Tab, views::ContextMenuController implementation: 199 // Tab, views::ContextMenuController implementation:
201 200
202 void Tab::ShowContextMenu(views::View* source, 201 void Tab::ShowContextMenu(views::View* source,
203 const gfx::Point& p, 202 const gfx::Point& p,
204 bool is_mouse_gesture) { 203 bool is_mouse_gesture) {
205 if (!context_menu_contents_.get()) 204 context_menu_contents_.reset(new TabContextMenuContents(this));
206 context_menu_contents_.reset(new TabContextMenuContents(this));
207 context_menu_contents_->RunMenuAt(p); 205 context_menu_contents_->RunMenuAt(p);
208 } 206 }
209 207
210 /////////////////////////////////////////////////////////////////////////////// 208 ///////////////////////////////////////////////////////////////////////////////
211 // views::ButtonListener implementation: 209 // views::ButtonListener implementation:
212 210
213 void Tab::ButtonPressed(views::Button* sender, const views::Event& event) { 211 void Tab::ButtonPressed(views::Button* sender, const views::Event& event) {
214 if (sender == close_button()) 212 if (sender == close_button())
215 delegate_->CloseTab(this); 213 delegate_->CloseTab(this);
216 } 214 }
(...skipping 19 matching lines...) Expand all
236 234
237 // Right end cap. 235 // Right end cap.
238 path->lineTo(w - kTabCapWidth + kTabTopCurveWidth, kTabTopCurveWidth); 236 path->lineTo(w - kTabCapWidth + kTabTopCurveWidth, kTabTopCurveWidth);
239 path->lineTo(w - kTabBottomCurveWidth, h - kTabBottomCurveWidth); 237 path->lineTo(w - kTabBottomCurveWidth, h - kTabBottomCurveWidth);
240 path->lineTo(w, h); 238 path->lineTo(w, h);
241 239
242 // Close out the path. 240 // Close out the path.
243 path->lineTo(0, h); 241 path->lineTo(0, h);
244 path->close(); 242 path->close();
245 } 243 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_menu_model_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698