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

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

Powered by Google App Engine
This is Rietveld 408576698