OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 12 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
13 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 13 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
14 #include "ui/base/window_open_disposition.h" | 14 #include "ui/base/window_open_disposition.h" |
15 #include "ui/gfx/animation/animation_delegate.h" | |
16 #include "ui/gfx/range/range.h" | 15 #include "ui/gfx/range/range.h" |
17 #include "ui/views/controls/textfield/textfield.h" | 16 #include "ui/views/controls/textfield/textfield.h" |
18 #include "ui/views/controls/textfield/textfield_controller.h" | 17 #include "ui/views/controls/textfield/textfield_controller.h" |
19 | 18 |
20 #if defined(OS_CHROMEOS) | 19 #if defined(OS_CHROMEOS) |
21 #include "chromeos/ime/input_method_manager.h" | 20 #include "chromeos/ime/input_method_manager.h" |
22 #endif | 21 #endif |
23 | 22 |
24 class LocationBarView; | 23 class LocationBarView; |
25 class OmniboxPopupView; | 24 class OmniboxPopupView; |
26 class Profile; | 25 class Profile; |
27 | 26 |
28 namespace gfx { | 27 namespace gfx { |
29 class RenderText; | 28 class RenderText; |
30 class SlideAnimation; | |
31 } | 29 } |
32 | 30 |
33 namespace ui { | 31 namespace ui { |
34 class OSExchangeData; | 32 class OSExchangeData; |
35 } // namespace ui | 33 } // namespace ui |
36 | 34 |
37 // Views-implementation of OmniboxView. | 35 // Views-implementation of OmniboxView. |
38 class OmniboxViewViews | 36 class OmniboxViewViews |
39 : public OmniboxView, | 37 : public OmniboxView, |
40 public views::Textfield, | 38 public views::Textfield, |
41 public gfx::AnimationDelegate, | |
42 #if defined(OS_CHROMEOS) | 39 #if defined(OS_CHROMEOS) |
43 public | 40 public |
44 chromeos::input_method::InputMethodManager::CandidateWindowObserver, | 41 chromeos::input_method::InputMethodManager::CandidateWindowObserver, |
45 #endif | 42 #endif |
46 public views::TextfieldController { | 43 public views::TextfieldController { |
47 public: | 44 public: |
48 // The internal view class name. | 45 // The internal view class name. |
49 static const char kViewClassName[]; | 46 static const char kViewClassName[]; |
50 | 47 |
51 OmniboxViewViews(OmniboxEditController* controller, | 48 OmniboxViewViews(OmniboxEditController* controller, |
52 Profile* profile, | 49 Profile* profile, |
53 CommandUpdater* command_updater, | 50 CommandUpdater* command_updater, |
54 bool popup_window_mode, | 51 bool popup_window_mode, |
55 LocationBarView* location_bar, | 52 LocationBarView* location_bar, |
56 const gfx::FontList& font_list); | 53 const gfx::FontList& font_list); |
57 virtual ~OmniboxViewViews(); | 54 virtual ~OmniboxViewViews(); |
58 | 55 |
59 // Initialize, create the underlying views, etc; | 56 // Initialize, create the underlying views, etc. |
60 void Init(); | 57 void Init(); |
61 | 58 |
62 // Starts an animation that fades in the entire OmniboxView. | |
63 void FadeIn(); | |
64 | |
65 // Exposes the RenderText for tests. | 59 // Exposes the RenderText for tests. |
66 #if defined(UNIT_TEST) | 60 #if defined(UNIT_TEST) |
67 gfx::RenderText* GetRenderText() { | 61 gfx::RenderText* GetRenderText() { |
68 return views::Textfield::GetRenderText(); | 62 return views::Textfield::GetRenderText(); |
69 } | 63 } |
70 #endif | 64 #endif |
71 | 65 |
72 // OmniboxView: | 66 // OmniboxView: |
73 virtual void SaveStateToTab(content::WebContents* tab) OVERRIDE; | 67 virtual void SaveStateToTab(content::WebContents* tab) OVERRIDE; |
74 virtual void OnTabChanged(const content::WebContents* web_contents) OVERRIDE; | 68 virtual void OnTabChanged(const content::WebContents* web_contents) OVERRIDE; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 virtual const char* GetClassName() const OVERRIDE; | 146 virtual const char* GetClassName() const OVERRIDE; |
153 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 147 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
154 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; | 148 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; |
155 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 149 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
156 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; | 150 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; |
157 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 151 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
158 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; | 152 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; |
159 virtual bool SkipDefaultKeyEventProcessing( | 153 virtual bool SkipDefaultKeyEventProcessing( |
160 const ui::KeyEvent& event) OVERRIDE; | 154 const ui::KeyEvent& event) OVERRIDE; |
161 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 155 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; |
162 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | |
163 virtual void OnFocus() OVERRIDE; | 156 virtual void OnFocus() OVERRIDE; |
164 virtual void OnBlur() OVERRIDE; | 157 virtual void OnBlur() OVERRIDE; |
165 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 158 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
166 virtual base::string16 GetSelectionClipboardText() const OVERRIDE; | 159 virtual base::string16 GetSelectionClipboardText() const OVERRIDE; |
167 | 160 |
168 // gfx::AnimationDelegate: | |
169 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | |
170 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; | |
171 | |
172 // chromeos::input_method::InputMethodManager::CandidateWindowObserver: | 161 // chromeos::input_method::InputMethodManager::CandidateWindowObserver: |
173 #if defined(OS_CHROMEOS) | 162 #if defined(OS_CHROMEOS) |
174 virtual void CandidateWindowOpened( | 163 virtual void CandidateWindowOpened( |
175 chromeos::input_method::InputMethodManager* manager) OVERRIDE; | 164 chromeos::input_method::InputMethodManager* manager) OVERRIDE; |
176 virtual void CandidateWindowClosed( | 165 virtual void CandidateWindowClosed( |
177 chromeos::input_method::InputMethodManager* manager) OVERRIDE; | 166 chromeos::input_method::InputMethodManager* manager) OVERRIDE; |
178 #endif | 167 #endif |
179 | 168 |
180 // views::TextfieldController: | 169 // views::TextfieldController: |
181 virtual void ContentsChanged(views::Textfield* sender, | 170 virtual void ContentsChanged(views::Textfield* sender, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // We select in response to a click that focuses the omnibox, but we defer | 215 // We select in response to a click that focuses the omnibox, but we defer |
227 // until release, setting this variable back to false if we saw a drag, to | 216 // until release, setting this variable back to false if we saw a drag, to |
228 // allow the user to select just a portion of the text. | 217 // allow the user to select just a portion of the text. |
229 bool select_all_on_mouse_release_; | 218 bool select_all_on_mouse_release_; |
230 | 219 |
231 // Indicates if we want to select all text in the omnibox when we get a | 220 // Indicates if we want to select all text in the omnibox when we get a |
232 // GESTURE_TAP. We want to select all only when the textfield is not in focus | 221 // GESTURE_TAP. We want to select all only when the textfield is not in focus |
233 // and gets a tap. So we use this variable to remember focus state before tap. | 222 // and gets a tap. So we use this variable to remember focus state before tap. |
234 bool select_all_on_gesture_tap_; | 223 bool select_all_on_gesture_tap_; |
235 | 224 |
236 scoped_ptr<gfx::SlideAnimation> fade_in_animation_; | |
237 | |
238 DISALLOW_COPY_AND_ASSIGN(OmniboxViewViews); | 225 DISALLOW_COPY_AND_ASSIGN(OmniboxViewViews); |
239 }; | 226 }; |
240 | 227 |
241 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ | 228 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ |
OLD | NEW |