Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / views / ash / tab_scrubber.h
blobd423cca6cf9d0f9a3143cac49e8c172f72e81a99
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_ASH_TAB_SCRUBBER_H_
6 #define CHROME_BROWSER_UI_VIEWS_ASH_TAB_SCRUBBER_H_
8 #include "base/timer/timer.h"
9 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
10 #include "chrome/browser/ui/views/tabs/tab_strip_observer.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
13 #include "ui/events/event_handler.h"
15 class Browser;
16 class Tab;
17 class TabStrip;
19 namespace gfx {
20 class Point;
23 // Class to enable quick tab switching via Ctrl-left-drag.
24 // Notes: this is experimental, and disables ctrl-clicks. It should not be
25 // enabled other than through flags until we implement 3 finger drag as the
26 // mechanism to invoke it. At that point we will add test coverage.
27 class TabScrubber : public ui::EventHandler,
28 public content::NotificationObserver,
29 public TabStripObserver {
30 public:
31 enum Direction {LEFT, RIGHT};
33 // Returns a the single instance of a TabScrubber.
34 static TabScrubber* GetInstance();
36 // Returns the virtual position of a swipe starting in the tab at |index|,
37 // base on the |direction|.
38 static gfx::Point GetStartPoint(TabStrip* tab_strip,
39 int index,
40 TabScrubber::Direction direction);
42 void set_activation_delay(int activation_delay) {
43 activation_delay_ = activation_delay;
44 use_default_activation_delay_ = false;
46 int activation_delay() const { return activation_delay_; }
47 int highlighted_tab() const { return highlighted_tab_; }
48 bool IsActivationPending();
50 private:
51 TabScrubber();
52 ~TabScrubber() override;
54 // ui::EventHandler overrides:
55 void OnScrollEvent(ui::ScrollEvent* event) override;
57 // content::NotificationObserver overrides:
58 void Observe(int type,
59 const content::NotificationSource& source,
60 const content::NotificationDetails& details) override;
62 // TabStripObserver overrides.
63 void TabStripAddedTabAt(TabStrip* tab_strip, int index) override;
64 void TabStripMovedTab(TabStrip* tab_strip,
65 int from_index,
66 int to_index) override;
67 void TabStripRemovedTabAt(TabStrip* tab_strip, int index) override;
68 void TabStripDeleted(TabStrip* tab_strip) override;
70 Browser* GetActiveBrowser();
72 void BeginScrub(Browser* browser, BrowserView* browser_view, float x_offset);
73 void FinishScrub(bool activate);
75 void ScheduleFinishScrubIfNeeded();
77 // Updates the direction and the starting point of the swipe.
78 void ScrubDirectionChanged(Direction direction);
80 // Updates the X co-ordinate of the swipe taking into account RTL layouts if
81 // any.
82 void UpdateSwipeX(float x_offset);
84 void UpdateHighlightedTab(Tab* new_tab, int new_index);
86 // Are we currently scrubbing?.
87 bool scrubbing_;
88 // The last browser we used for scrubbing, NULL if |scrubbing_| is
89 // false and there is no pending work.
90 Browser* browser_;
91 // The TabStrip of the active browser we're scrubbing.
92 TabStrip* tab_strip_;
93 // The current accumulated x and y positions of a swipe, in
94 // the coordinates of the TabStrip of |browser_|
95 float swipe_x_;
96 float swipe_y_;
97 // The direction the current swipe is headed.
98 Direction swipe_direction_;
99 // The index of the tab that is currently highlighted.
100 int highlighted_tab_;
101 // Timer to control a delayed activation of the |highlighted_tab_|.
102 base::Timer activate_timer_;
103 // Time to wait in ms before newly selected tab becomes active.
104 int activation_delay_;
105 // Set if activation_delay had been explicitly set.
106 bool use_default_activation_delay_;
107 // Forces the tabs to be revealed if we are in immersive fullscreen.
108 scoped_ptr<ImmersiveRevealedLock> immersive_reveal_lock_;
110 content::NotificationRegistrar registrar_;
111 base::WeakPtrFactory<TabScrubber> weak_ptr_factory_;
113 DISALLOW_COPY_AND_ASSIGN(TabScrubber);
116 #endif // CHROME_BROWSER_UI_VIEWS_ASH_TAB_SCRUBBER_H_