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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 74133003: linux-aura: Restore middle-click on new-tab button behaviour. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge-nit Created 7 years, 1 month 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/views/tabs/tab_strip.h" 5 #include "chrome/browser/ui/views/tabs/tab_strip.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windowsx.h> 8 #include <windowsx.h>
9 #endif 9 #endif
10 10
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 case ui::LAYOUT_TOUCH: 232 case ui::LAYOUT_TOUCH:
233 value = 26; 233 value = 26;
234 break; 234 break;
235 default: 235 default:
236 NOTREACHED(); 236 NOTREACHED();
237 } 237 }
238 } 238 }
239 return value; 239 return value;
240 } 240 }
241 241
242 base::string16 GetClipboardText() {
243 if (!ui::Clipboard::IsSupportedClipboardType(ui::CLIPBOARD_TYPE_SELECTION))
244 return base::string16();
245 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
246 CHECK(clipboard);
247 base::string16 clipboard_text;
248 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &clipboard_text);
249 return clipboard_text;
250 }
251
242 // Animation delegate used when a dragged tab is released. When done sets the 252 // Animation delegate used when a dragged tab is released. When done sets the
243 // dragging state to false. 253 // dragging state to false.
244 class ResetDraggingStateDelegate 254 class ResetDraggingStateDelegate
245 : public views::BoundsAnimator::OwnedAnimationDelegate { 255 : public views::BoundsAnimator::OwnedAnimationDelegate {
246 public: 256 public:
247 explicit ResetDraggingStateDelegate(Tab* tab) : tab_(tab) { 257 explicit ResetDraggingStateDelegate(Tab* tab) : tab_(tab) {
248 } 258 }
249 259
250 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE { 260 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE {
251 tab_->set_dragging(false); 261 tab_->set_dragging(false);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // were we destroyed? 349 // were we destroyed?
340 bool* destroyed_; 350 bool* destroyed_;
341 351
342 DISALLOW_COPY_AND_ASSIGN(NewTabButton); 352 DISALLOW_COPY_AND_ASSIGN(NewTabButton);
343 }; 353 };
344 354
345 NewTabButton::NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener) 355 NewTabButton::NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener)
346 : views::ImageButton(listener), 356 : views::ImageButton(listener),
347 tab_strip_(tab_strip), 357 tab_strip_(tab_strip),
348 destroyed_(NULL) { 358 destroyed_(NULL) {
359 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
360 set_triggerable_event_flags(triggerable_event_flags() |
361 ui::EF_MIDDLE_MOUSE_BUTTON);
362 #endif
349 } 363 }
350 364
351 NewTabButton::~NewTabButton() { 365 NewTabButton::~NewTabButton() {
352 if (destroyed_) 366 if (destroyed_)
353 *destroyed_ = true; 367 *destroyed_ = true;
354 } 368 }
355 369
356 bool NewTabButton::HasHitTestMask() const { 370 bool NewTabButton::HasHitTestMask() const {
357 // When the button is sized to the top of the tab strip we want the user to 371 // When the button is sized to the top of the tab strip we want the user to
358 // be able to click on complete bounds, and so don't return a custom hit 372 // be able to click on complete bounds, and so don't return a custom hit
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 } 1518 }
1505 1519
1506 /////////////////////////////////////////////////////////////////////////////// 1520 ///////////////////////////////////////////////////////////////////////////////
1507 // TabStrip, views::ButtonListener implementation: 1521 // TabStrip, views::ButtonListener implementation:
1508 1522
1509 void TabStrip::ButtonPressed(views::Button* sender, const ui::Event& event) { 1523 void TabStrip::ButtonPressed(views::Button* sender, const ui::Event& event) {
1510 if (sender == newtab_button_) { 1524 if (sender == newtab_button_) {
1511 content::RecordAction(UserMetricsAction("NewTab_Button")); 1525 content::RecordAction(UserMetricsAction("NewTab_Button"));
1512 UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", TabStripModel::NEW_TAB_BUTTON, 1526 UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", TabStripModel::NEW_TAB_BUTTON,
1513 TabStripModel::NEW_TAB_ENUM_COUNT); 1527 TabStripModel::NEW_TAB_ENUM_COUNT);
1528 if (event.IsMouseEvent()) {
1529 const ui::MouseEvent& mouse = static_cast<const ui::MouseEvent&>(event);
1530 if (mouse.IsOnlyMiddleMouseButton()) {
1531 base::string16 clipboard_text = GetClipboardText();
1532 if (!clipboard_text.empty())
1533 controller()->CreateNewTabWithLocation(clipboard_text);
1534 return;
1535 }
1536 }
1537
1514 controller()->CreateNewTab(); 1538 controller()->CreateNewTab();
1515 if (event.type() == ui::ET_GESTURE_TAP) 1539 if (event.type() == ui::ET_GESTURE_TAP)
1516 TouchUMA::RecordGestureAction(TouchUMA::GESTURE_NEWTAB_TAP); 1540 TouchUMA::RecordGestureAction(TouchUMA::GESTURE_NEWTAB_TAP);
1517 } 1541 }
1518 } 1542 }
1519 1543
1520 /////////////////////////////////////////////////////////////////////////////// 1544 ///////////////////////////////////////////////////////////////////////////////
1521 // TabStrip, protected: 1545 // TabStrip, protected:
1522 1546
1523 // Overridden to support automation. See automation_proxy_uitest.cc. 1547 // Overridden to support automation. See automation_proxy_uitest.cc.
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2731 #if defined(USE_AURA) 2755 #if defined(USE_AURA)
2732 return chrome::GetHostDesktopTypeForNativeView( 2756 return chrome::GetHostDesktopTypeForNativeView(
2733 GetWidget()->GetNativeView()) == chrome::HOST_DESKTOP_TYPE_ASH; 2757 GetWidget()->GetNativeView()) == chrome::HOST_DESKTOP_TYPE_ASH;
2734 #else 2758 #else
2735 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) 2759 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH)
2736 return false; 2760 return false;
2737 #endif 2761 #endif
2738 2762
2739 return true; 2763 return true;
2740 } 2764 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.cc ('k') | chrome/browser/ui/views/tabs/tab_strip_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698