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 #ifndef CHROME_BROWSER_UI_VIEWS_ASH_TAB_SCRUBBER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_ASH_TAB_SCRUBBER_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_ASH_TAB_SCRUBBER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_ASH_TAB_SCRUBBER_H_ |
7 | 7 |
8 #include "base/timer.h" | |
8 #include "content/public/browser/notification_observer.h" | 9 #include "content/public/browser/notification_observer.h" |
9 #include "content/public/browser/notification_registrar.h" | 10 #include "content/public/browser/notification_registrar.h" |
11 #include "ui/base/animation/animation_delegate.h" | |
10 #include "ui/base/events/event_handler.h" | 12 #include "ui/base/events/event_handler.h" |
11 | 13 |
12 class Browser; | 14 class Browser; |
13 class Tab; | 15 class TabStrip; |
16 | |
17 namespace gfx { | |
18 class Point; | |
19 } | |
14 | 20 |
15 // Class to enable quick tab switching via Ctrl-left-drag. | 21 // Class to enable quick tab switching via Ctrl-left-drag. |
16 // Notes: this is experimental, and disables ctrl-clicks. It should not be | 22 // Notes: this is experimental, and disables ctrl-clicks. It should not be |
17 // enabled other than through flags until we implement 3 finger drag as the | 23 // enabled other than through flags until we implement 3 finger drag as the |
18 // mechanism to invoke it. At that point we will add test coverage. | 24 // mechanism to invoke it. At that point we will add test coverage. |
19 class TabScrubber : public ui::EventHandler, | 25 class TabScrubber : public ui::EventHandler, |
20 public content::NotificationObserver { | 26 public content::NotificationObserver { |
21 public: | 27 public: |
22 static TabScrubber* GetInstance(); | 28 static TabScrubber* GetInstance(); |
23 | 29 |
30 enum Direction {LEFT, RIGHT}; | |
sky
2013/01/22 18:05:01
enums before methods. Also, how does this with whe
DaveMoore
2013/01/27 21:21:54
Moved declaration, but I think RIGHT / LEFT here m
| |
31 | |
32 // Returns the virtual position of a swipe starting in the tab at |index|, | |
33 // base on the |direction|. | |
34 static const gfx::Point GetStartPoint(TabStrip* tab_strip, | |
sky
2013/01/22 18:05:01
No point in a const return type.
DaveMoore
2013/01/27 21:21:54
Done.
| |
35 int index, | |
36 TabScrubber::Direction direction); | |
37 void set_activation_delay(base::TimeDelta activation_delay) { | |
38 activation_delay_ = activation_delay; | |
39 } | |
40 base::TimeDelta activation_delay() const { return activation_delay_; } | |
41 | |
24 private: | 42 private: |
25 TabScrubber(); | 43 TabScrubber(); |
26 virtual ~TabScrubber(); | 44 virtual ~TabScrubber(); |
27 | 45 |
28 // ui::EventHandler overrides: | 46 // ui::EventHandler overrides: |
29 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | 47 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; |
30 | 48 |
31 // content::NotificationObserver overrides: | 49 // content::NotificationObserver overrides: |
32 virtual void Observe(int type, | 50 virtual void Observe(int type, |
33 const content::NotificationSource& source, | 51 const content::NotificationSource& source, |
34 const content::NotificationDetails& details) OVERRIDE; | 52 const content::NotificationDetails& details) OVERRIDE; |
35 | 53 |
36 Browser* GetActiveBrowser(); | 54 Browser* GetActiveBrowser(); |
37 void StartScrubbing(); | 55 void FinishScrub(bool activate); |
38 void StopScrubbing(); | 56 void CancelImmersiveReveal(); |
39 | 57 |
40 // Indicates that we are currently scrubbing. | 58 // The browser that we are scrubbing. |
sky
2013/01/22 18:05:01
Update comments for members below. Not all members
DaveMoore
2013/01/27 21:21:54
Done.
| |
41 bool scrubbing_; | 59 bool scrubbing_; |
42 // The browser that we are scrubbing. | |
43 Browser* browser_; | 60 Browser* browser_; |
44 // The x value of the event that initiated scrubbing. | 61 float swipe_x_; |
45 float scroll_x_; | 62 float swipe_y_; |
46 float scroll_y_; | 63 Direction swipe_direction_; |
sky
2013/01/22 18:05:01
You don't member initialize this.
DaveMoore
2013/01/27 21:21:54
Done.
DaveMoore
2013/01/27 21:21:54
Done.
| |
47 | |
48 content::NotificationRegistrar registrar_; | 64 content::NotificationRegistrar registrar_; |
49 | 65 |
66 int overridden_tab_; | |
67 base::Timer activate_timer_; | |
68 // Time to wait before newly selected tab becomes active. | |
69 base::TimeDelta activation_delay_; | |
70 bool should_cancel_immersive_reveal_; | |
71 base::Timer cancel_immersive_reveal_timer_; | |
72 // Note: This should remain the last member so it'll be destroyed and | |
73 // invalidate its weak pointers before any other members are destroyed. | |
74 base::WeakPtrFactory<TabScrubber> weak_ptr_factory_; | |
50 DISALLOW_COPY_AND_ASSIGN(TabScrubber); | 75 DISALLOW_COPY_AND_ASSIGN(TabScrubber); |
sky
2013/01/22 18:05:01
nit: newline between 74/75
DaveMoore
2013/01/27 21:21:54
Done.
| |
51 }; | 76 }; |
52 | 77 |
53 #endif // CHROME_BROWSER_UI_VIEWS_ASH_TAB_SCRUBBER_H_ | 78 #endif // CHROME_BROWSER_UI_VIEWS_ASH_TAB_SCRUBBER_H_ |
OLD | NEW |