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

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: 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
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/dropdown_bar_host.h"
11 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
12 #include "content/common/notification_observer.h"
13 #include "content/common/notification_registrar.h"
14 #include "ui/base/animation/animation.h"
15 #include "ui/gfx/native_widget_types.h"
16 #include "ui/gfx/rect.h"
17 #include "views/controls/textfield/textfield.h"
sky 2011/05/03 18:38:32 Looks like some of your includes aren't needed (at
SteveT 2011/05/06 18:48:43 Done.
18
19 class BrowserView;
20 class CompactLocationBarView;
21 class MouseObserver;
22 class TabContents;
23
24 ////////////////////////////////////////////////////////////////////////////////
25 //
26 // The CompactLocationBarViewHost implements the container window for the
27 // floating location bar. It uses the appropriate implementation from
28 // compact_location_bar_view_host.cc to draw its content and is
sky 2011/05/03 18:38:32 Nuke the part about compact_location_bar_view.cc.
SteveT 2011/05/06 18:48:43 Done.
29 // responsible for showing, hiding, closing, and moving the window.
30 //
31 // There is one CompactLocationBarViewHost per BrowserView, and its state
32 // is updated whenever the selected Tab is changed. The
33 // CompactLocationBarViewHost is created when the BrowserView is attached
34 // to the frame's Widget for the first time, and enabled/disabled
35 // when the compact navigation bar is toggled.
36 //
37 ////////////////////////////////////////////////////////////////////////////////
38 class CompactLocationBarViewHost : public DropdownBarHost,
39 public TabStripModelObserver,
sky 2011/05/03 18:38:32 indentation is off.
SteveT 2011/05/06 18:48:43 Done.
40 public NotificationObserver,
41 public LocationBarView::Delegate {
42 public:
43 explicit CompactLocationBarViewHost(::BrowserView* browser_view);
sky 2011/05/03 18:38:32 Is the :: really needed there?
SteveT 2011/05/06 18:48:43 Nope. Sorry, that was a missed artifact from the o
44 virtual ~CompactLocationBarViewHost();
45
46 // LocationBarView::Delegate overrides
47 virtual TabContentsWrapper* GetTabContentsWrapper() const OVERRIDE;
48 virtual InstantController* GetInstant() OVERRIDE;
49 virtual void OnInputInProgress(bool in_progress) OVERRIDE;
50
51 // Returns the bounds to locale the compact location bar under the tab.
sky 2011/05/03 18:38:32 locale -> locate Also, document what coordinate sy
SteveT 2011/05/06 18:48:43 Done.
52 gfx::Rect GetBoundsUnderTab(int model_index) const;
53
54 // Updates the content and the position of the compact location bar.
55 // |model_index| is the index of the tab the compact location bar
56 // will be attached to and |animate| specifies if the location bar
57 // should animate when shown. The second version gets the actual |contents|
58 // instead of the |model_index|.
59 void Update(int model_index, bool animate);
sky 2011/05/03 18:38:32 Do these really need to be public? They seem like
SteveT 2011/05/06 18:48:43 Yeah - Update is called by BrowserView when it get
60 void Update(TabContents* contents, bool animate);
61
62 // (Re)Starts the popup timer that hides the popup after X seconds.
63 void StartAutoHideTimer();
64
65 // Cancels the popup timer.
66 void CancelAutoHideTimer();
67
68 // Enable/disable the compact location bar.
69 void SetEnabled(bool enabled);
70
71 // Overridden from NotificationObserver.
72 virtual void Observe(NotificationType type,
73 const NotificationSource& source,
74 const NotificationDetails& details) OVERRIDE;
75
76 // Overridden from DropdownBarhost.
77 virtual void Show(bool animate) OVERRIDE;
78 virtual void Hide(bool animate) OVERRIDE;
79
80 // Overridden from views::AcceleratorTarget in DropdownBarHost class.
81 virtual bool AcceleratorPressed(
82 const views::Accelerator& accelerator) OVERRIDE;
83
84 // Overridden from DropdownBarHost class.
85 virtual gfx::Rect GetDialogPosition(
86 gfx::Rect avoid_overlapping_rect) OVERRIDE;
87 virtual void SetDialogPosition(const gfx::Rect& new_pos,
88 bool no_redraw) OVERRIDE;
89
90 // Overriden from TabStripModelObserver class.
91 virtual void TabInsertedAt(TabContentsWrapper* contents,
92 int index,
93 bool foreground) OVERRIDE;
94 virtual void TabClosingAt(TabStripModel* tab_strip_model,
95 TabContentsWrapper* contents,
96 int index) OVERRIDE;
97 virtual void TabSelectedAt(TabContentsWrapper* old_contents,
98 TabContentsWrapper* new_contents,
99 int index,
100 bool user_gesture) OVERRIDE;
101 virtual void TabMoved(TabContentsWrapper* contents,
102 int from_index,
103 int to_index) OVERRIDE;
104 virtual void TabChangedAt(TabContentsWrapper* contents, int index,
105 TabChangeType change_type) OVERRIDE;
106 virtual void TabReselected(int index) OVERRIDE;
107
108 CompactLocationBarView* GetCompactLocationBarView();
109
110 virtual void MoveWindowIfNecessary(const gfx::Rect& selection_rect,
111 bool no_redraw);
sky 2011/05/03 18:38:32 OVERRIDE and document where it comes from.
SteveT 2011/05/06 18:48:43 Not actually overridden from somewhere else, just
112
113 private:
114 friend class MouseObserver;
115 friend class CompactLocationBarViewHostTest;
116
117 bool HasFocus();
118 void HideCallback();
119 bool IsCurrentTabIndex(int index);
120 bool IsCurrentTab(TabContents* contents);
121
122 // We use this to be notified of the end of a page load so we can hide.
123 NotificationRegistrar registrar_;
124
125 // The index of the tab, in terms of the model, that the compact location bar
126 // is attached to.
127 int current_tab_model_index_;
128
129 scoped_ptr<base::OneShotTimer<CompactLocationBarViewHost> > auto_hide_timer_;
130
131 scoped_ptr<MouseObserver> mouse_observer_;
132
133 DISALLOW_COPY_AND_ASSIGN(CompactLocationBarViewHost);
134 };
135
136 #endif // CHROME_BROWSER_UI_VIEWS_COMPACT_NAV_COMPACT_LOCATION_BAR_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698