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

Side by Side Diff: chrome/browser/ui/views/ash/tab_scrubber.cc

Issue 11568006: events: Update scroll and touch handlers to not return EventResult. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: self-nit Created 8 years 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/ash/tab_scrubber.h" 5 #include "chrome/browser/ui/views/ash/tab_scrubber.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/wm/window_util.h" 8 #include "ash/wm/window_util.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h" 10 #include "chrome/browser/ui/browser_finder.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 : scrubbing_(false), 43 : scrubbing_(false),
44 browser_(NULL), 44 browser_(NULL),
45 scroll_x_(-1), 45 scroll_x_(-1),
46 scroll_y_(-1) { 46 scroll_y_(-1) {
47 ash::Shell::GetInstance()->AddPreTargetHandler(this); 47 ash::Shell::GetInstance()->AddPreTargetHandler(this);
48 } 48 }
49 49
50 TabScrubber::~TabScrubber() { 50 TabScrubber::~TabScrubber() {
51 } 51 }
52 52
53 ui::EventResult TabScrubber::OnScrollEvent(ui::ScrollEvent* event) { 53 void TabScrubber::OnScrollEvent(ui::ScrollEvent* event) {
54 if (event->type() == ui::ET_SCROLL_FLING_CANCEL) { 54 if (event->type() == ui::ET_SCROLL_FLING_CANCEL) {
55 if (scrubbing_) 55 if (scrubbing_)
56 StopScrubbing(); 56 StopScrubbing();
57 return ui::ER_UNHANDLED; 57 return;
58 } 58 }
59 59
60 if (event->finger_count() != 3 || 60 if (event->finger_count() != 3 ||
61 event->type() != ui::ET_SCROLL) 61 event->type() != ui::ET_SCROLL)
62 return ui::ER_UNHANDLED; 62 return;
63 63
64 Browser* browser = GetActiveBrowser(); 64 Browser* browser = GetActiveBrowser();
65 if (!browser || (browser_ && browser != browser_)) { 65 if (!browser || (browser_ && browser != browser_)) {
66 if (scrubbing_) 66 if (scrubbing_)
67 StopScrubbing(); 67 StopScrubbing();
68 return ui::ER_UNHANDLED; 68 return;
69 } 69 }
70 70
71 BrowserView* browser_view = 71 BrowserView* browser_view =
72 BrowserView::GetBrowserViewForNativeWindow( 72 BrowserView::GetBrowserViewForNativeWindow(
73 browser->window()->GetNativeWindow()); 73 browser->window()->GetNativeWindow());
74 TabStrip* tab_strip = browser_view->tabstrip(); 74 TabStrip* tab_strip = browser_view->tabstrip();
75 75
76 float x_offset = -event->x_offset(); 76 float x_offset = -event->x_offset();
77 if (!scrubbing_) { 77 if (!scrubbing_) {
78 scrubbing_ = true; 78 scrubbing_ = true;
(...skipping 20 matching lines...) Expand all
99 if (scroll_x_ > last_tab->bounds().right()) 99 if (scroll_x_ > last_tab->bounds().right())
100 scroll_x_ = last_tab->bounds().right(); 100 scroll_x_ = last_tab->bounds().right();
101 101
102 gfx::Point tab_point(scroll_x_, scroll_y_); 102 gfx::Point tab_point(scroll_x_, scroll_y_);
103 Tab* new_tab = GetTabAt(tab_strip, tab_point); 103 Tab* new_tab = GetTabAt(tab_strip, tab_point);
104 if (new_tab && !new_tab->IsActive()) { 104 if (new_tab && !new_tab->IsActive()) {
105 int new_index = tab_strip->GetModelIndexOfTab(new_tab); 105 int new_index = tab_strip->GetModelIndexOfTab(new_tab);
106 browser->tab_strip_model()->ActivateTabAt(new_index, true); 106 browser->tab_strip_model()->ActivateTabAt(new_index, true);
107 } 107 }
108 108
109 return ui::ER_CONSUMED; 109 event->StopPropagation();
110 } 110 }
111 111
112 void TabScrubber::Observe(int type, 112 void TabScrubber::Observe(int type,
113 const content::NotificationSource& source, 113 const content::NotificationSource& source,
114 const content::NotificationDetails& details) { 114 const content::NotificationDetails& details) {
115 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSING && 115 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSING &&
116 content::Source<Browser>(source).ptr() == browser_); 116 content::Source<Browser>(source).ptr() == browser_);
117 StopScrubbing(); 117 StopScrubbing();
118 } 118 }
119 119
(...skipping 13 matching lines...) Expand all
133 if (!scrubbing_) 133 if (!scrubbing_)
134 return; 134 return;
135 135
136 registrar_.Remove( 136 registrar_.Remove(
137 this, 137 this,
138 chrome::NOTIFICATION_BROWSER_CLOSING, 138 chrome::NOTIFICATION_BROWSER_CLOSING,
139 content::Source<Browser>(browser_)); 139 content::Source<Browser>(browser_));
140 scrubbing_ = false; 140 scrubbing_ = false;
141 browser_ = NULL; 141 browser_ = NULL;
142 } 142 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/ash/tab_scrubber.h ('k') | content/browser/renderer_host/render_widget_host_view_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698