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

Side by Side Diff: chrome/browser/ui/views/compact_nav/compact_location_bar_view_host.h

Issue 6913026: Compact Navigation prototype (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Clang build fix. After commit/revert. Created 9 years, 7 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 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.
4
5 #ifndef CHROME_BROWSER_UI_VIEWS_COMPACT_NAV_COMPACT_LOCATION_BAR_VIEW_HOST_H_
6 #define CHROME_BROWSER_UI_VIEWS_COMPACT_NAV_COMPACT_LOCATION_BAR_VIEW_HOST_H_
7
8 #include "base/timer.h"
9 #include "chrome/browser/tabs/tab_strip_model.h"
10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
11
12 class BrowserView;
13 class CompactLocationBarView;
14 class DropdownBarHost;
15 class MouseObserver;
16 class NotificationObserver;
17 class NotificationRegistrar;
18 class TabContents;
19
20 namespace gfx {
21 class Rect;
22 }
23
24 ////////////////////////////////////////////////////////////////////////////////
25 //
26 // The CompactLocationBarViewHost implements the container window for the
27 // floating location bar.
28 //
29 // There is one CompactLocationBarViewHost per BrowserView, and its state
30 // is updated whenever the selected Tab is changed. The
31 // CompactLocationBarViewHost is created when the BrowserView is attached
32 // to the frame's Widget for the first time, and enabled/disabled
33 // when the compact navigation bar is toggled.
34 //
35 ////////////////////////////////////////////////////////////////////////////////
36 class CompactLocationBarViewHost : public DropdownBarHost,
37 public TabStripModelObserver,
38 public NotificationObserver,
39 public LocationBarView::Delegate {
40 public:
41 explicit CompactLocationBarViewHost(BrowserView* browser_view);
42 virtual ~CompactLocationBarViewHost();
43
44 // Returns the bounds to locate the compact location bar under the tab. The
45 // coordinate system is the browser frame for Windows, otherwise the browser
46 // view.
47 gfx::Rect GetBoundsUnderTab(int model_index) const;
48
49 // Updates the content and the position of the compact location bar.
50 // |model_index| is the index of the tab the compact location bar
51 // will be attached to and |animate| specifies if the location bar
52 // should animate when shown. The second version gets the actual |contents|
53 // instead of the |model_index|.
54 void UpdateOnTabChange(int model_index, bool animate);
55 void Update(TabContents* contents, bool animate);
56
57 // (Re)Starts the popup timer that hides the popup after X seconds.
58 void StartAutoHideTimer();
59
60 // Cancels the popup timer.
61 void CancelAutoHideTimer();
62
63 // Enable/disable the compact location bar.
64 void SetEnabled(bool enabled);
65
66 CompactLocationBarView* GetCompactLocationBarView();
67
68 // Readjust the position of the host window while avoiding |selection_rect|.
69 // |selection_rect| is expected to have coordinates relative to the top of
70 // the web page area. If |no_redraw| is true, the window will be moved without
71 // redrawing siblings.
72 virtual void MoveWindowIfNecessary(const gfx::Rect& selection_rect,
73 bool no_redraw);
74
75 // Overridden from DropdownBarhost.
76 virtual void Show(bool animate) OVERRIDE;
77 virtual void Hide(bool animate) OVERRIDE;
78 virtual gfx::Rect GetDialogPosition(
79 gfx::Rect avoid_overlapping_rect) OVERRIDE;
80 virtual void SetDialogPosition(const gfx::Rect& new_pos,
81 bool no_redraw) OVERRIDE;
82
83 // Overridden from views::AcceleratorTarget in DropdownBarHost class.
84 virtual bool AcceleratorPressed(
85 const views::Accelerator& accelerator) OVERRIDE;
86
87 // Overridden from TabStripModelObserver class.
88 virtual void TabClosingAt(TabStripModel* tab_strip_model,
89 TabContentsWrapper* contents,
90 int index) OVERRIDE;
91 virtual void TabSelectedAt(TabContentsWrapper* old_contents,
92 TabContentsWrapper* new_contents,
93 int index,
94 bool user_gesture) OVERRIDE;
95 virtual void TabMoved(TabContentsWrapper* contents,
96 int from_index,
97 int to_index) OVERRIDE;
98 virtual void TabChangedAt(TabContentsWrapper* contents, int index,
99 TabChangeType change_type) OVERRIDE;
100 virtual void ActiveTabClicked(int index) OVERRIDE;
101
102 // Overridden from NotificationObserver.
103 virtual void Observe(NotificationType type,
104 const NotificationSource& source,
105 const NotificationDetails& details) OVERRIDE;
106
107 // LocationBarView::Delegate overrides
108 virtual TabContentsWrapper* GetTabContentsWrapper() const OVERRIDE;
109 virtual InstantController* GetInstant() OVERRIDE;
110 virtual void OnInputInProgress(bool in_progress) OVERRIDE;
111
112 private:
113 friend class MouseObserver;
114 friend class CompactLocationBarViewHostTest;
115
116 bool HasFocus();
117 void HideCallback();
118 bool IsCurrentTabIndex(int index);
119 bool IsCurrentTab(TabContents* contents);
120
121 // We use this to be notified of the end of a page load so we can hide.
122 NotificationRegistrar registrar_;
123
124 // The index of the tab, in terms of the model, that the compact location bar
125 // is attached to.
126 int current_tab_model_index_;
127
128 scoped_ptr<base::OneShotTimer<CompactLocationBarViewHost> > auto_hide_timer_;
129
130 scoped_ptr<MouseObserver> mouse_observer_;
131
132 // Track if we are currently observing the tabstrip model.
133 bool is_observing_;
134
135 DISALLOW_COPY_AND_ASSIGN(CompactLocationBarViewHost);
136 };
137
138 #endif // CHROME_BROWSER_UI_VIEWS_COMPACT_NAV_COMPACT_LOCATION_BAR_VIEW_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698