1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_COMPACT_LOCATION_BAR_HOST_H_
#define CHROME_BROWSER_CHROMEOS_COMPACT_LOCATION_BAR_HOST_H_
#include "app/animation.h"
#include "app/gfx/native_widget_types.h"
#include "base/gfx/rect.h"
#include "base/timer.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/views/dropdown_bar_host.h"
#include "views/controls/textfield/textfield.h"
class BrowserView;
class TabContents;
class Tab;
class ToolbarStarToggle;
namespace chromeos {
class CompactLocationBarView;
class MouseObserver;
////////////////////////////////////////////////////////////////////////////////
//
// The CompactLocationBarHost implements the container window for the
// floating location bar. It uses the appropriate implementation from
// compact_location_bar_host_gtk.cc to draw its content and is
// responsible for showing, hiding, closing, and moving the window.
//
// There is one CompactLocationBarHost per BrowserView, and its state
// is updated whenever the selected Tab is changed. The
// CompactLocationBarHost is created when the BrowserView is attached
// to the frame's Widget for the first time, and enabled/disabled
// when the compact navigation bar is toggled.
//
////////////////////////////////////////////////////////////////////////////////
class CompactLocationBarHost : public DropdownBarHost,
public TabStripModelObserver {
public:
explicit CompactLocationBarHost(::BrowserView* browser_view);
virtual ~CompactLocationBarHost();
// Returns the bounds to locale the compact location bar under the tab.
gfx::Rect GetBoundsUnderTab(int tab_index) const;
// Updates the content and the position of the compact location bar.
// |index| is the index of the tab the compact location bar
// will be attached to and |animate| specifies if the location bar
// should animate when shown.
void Update(int index, bool animate);
// (Re)Starts the popup timer that hides the popup after X seconds.
void StartAutoHideTimer();
// Cancels the popup timer.
void CancelAutoHideTimer();
// Enable/disable the compact location bar.
void SetEnabled(bool enabled);
// Returns the star button for compact location bar.
ToolbarStarToggle* GetStarButton();
// Overridehden from DropdownBarhost.
virtual void Show(bool animate);
virtual void Hide(bool animate);
// Overridden from views::AcceleratorTarget in DropdownBarHost class.
virtual bool AcceleratorPressed(const views::Accelerator& accelerator);
// Overridden from DropdownBarHost class.
virtual gfx::Rect GetDialogPosition(gfx::Rect avoid_overlapping_rect);
virtual void SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw);
// Overriden from TabStripModelObserver class.
virtual void TabInsertedAt(TabContents* contents,
int index,
bool foreground);
virtual void TabClosingAt(TabContents* contents, int index);
virtual void TabSelectedAt(TabContents* old_contents,
TabContents* new_contents,
int index,
bool user_gesture);
virtual void TabMoved(TabContents* contents,
int from_index,
int to_index);
virtual void TabChangedAt(TabContents* contents, int index,
TabChangeType change_type);
private:
friend class MouseObserver;
void HideCallback() {
Hide(true);
}
// Returns CompactLocationBarView.
CompactLocationBarView* GetClbView();
bool IsCurrentTabIndex(int index);
// The index of the tab that the compact location bar is attached to.
int current_tab_index_;
scoped_ptr<base::OneShotTimer<CompactLocationBarHost> > auto_hide_timer_;
scoped_ptr<MouseObserver> mouse_observer_;
DISALLOW_COPY_AND_ASSIGN(CompactLocationBarHost);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_COMPACT_LOCATION_BAR_HOST_H_
|