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" |
15 #include "ui/gfx/range/range.h" | 16 #include "ui/gfx/range/range.h" |
16 #include "ui/views/controls/textfield/textfield.h" | 17 #include "ui/views/controls/textfield/textfield.h" |
17 #include "ui/views/controls/textfield/textfield_controller.h" | 18 #include "ui/views/controls/textfield/textfield_controller.h" |
18 | 19 |
19 #if defined(OS_CHROMEOS) | 20 #if defined(OS_CHROMEOS) |
20 #include "chromeos/ime/input_method_manager.h" | 21 #include "chromeos/ime/input_method_manager.h" |
21 #endif | 22 #endif |
22 | 23 |
23 class LocationBarView; | 24 class LocationBarView; |
24 class OmniboxPopupView; | 25 class OmniboxPopupView; |
25 class Profile; | 26 class Profile; |
26 | 27 |
| 28 namespace gfx { |
| 29 class SlideAnimation; |
| 30 } |
| 31 |
27 namespace ui { | 32 namespace ui { |
28 class OSExchangeData; | 33 class OSExchangeData; |
29 } // namespace ui | 34 } // namespace ui |
30 | 35 |
31 // Views-implementation of OmniboxView, based on the gtk implementation. | 36 // Views-implementation of OmniboxView, based on the gtk implementation. |
32 class OmniboxViewViews | 37 class OmniboxViewViews |
33 : public views::Textfield, | 38 : public views::Textfield, |
34 public OmniboxView, | 39 public OmniboxView, |
| 40 public gfx::AnimationDelegate, |
35 #if defined(OS_CHROMEOS) | 41 #if defined(OS_CHROMEOS) |
36 public | 42 public |
37 chromeos::input_method::InputMethodManager::CandidateWindowObserver, | 43 chromeos::input_method::InputMethodManager::CandidateWindowObserver, |
38 #endif | 44 #endif |
39 public views::TextfieldController { | 45 public views::TextfieldController { |
40 public: | 46 public: |
41 // The internal view class name. | 47 // The internal view class name. |
42 static const char kViewClassName[]; | 48 static const char kViewClassName[]; |
43 | 49 |
44 OmniboxViewViews(OmniboxEditController* controller, | 50 OmniboxViewViews(OmniboxEditController* controller, |
45 Profile* profile, | 51 Profile* profile, |
46 CommandUpdater* command_updater, | 52 CommandUpdater* command_updater, |
47 bool popup_window_mode, | 53 bool popup_window_mode, |
48 LocationBarView* location_bar, | 54 LocationBarView* location_bar, |
49 const gfx::FontList& font_list); | 55 const gfx::FontList& font_list); |
50 virtual ~OmniboxViewViews(); | 56 virtual ~OmniboxViewViews(); |
51 | 57 |
52 // Initialize, create the underlying views, etc; | 58 // Initialize, create the underlying views, etc; |
53 void Init(); | 59 void Init(); |
54 | 60 |
| 61 // Starts an animation that fades in the entire OmniboxView. |
| 62 void FadeIn(); |
| 63 |
55 // views::Textfield: | 64 // views::Textfield: |
56 virtual const char* GetClassName() const OVERRIDE; | 65 virtual const char* GetClassName() const OVERRIDE; |
| 66 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
57 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 67 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
58 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; | 68 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; |
59 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 69 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
60 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; | 70 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; |
61 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; | 71 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; |
62 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 72 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
63 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; | 73 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; |
64 virtual bool SkipDefaultKeyEventProcessing( | 74 virtual bool SkipDefaultKeyEventProcessing( |
65 const ui::KeyEvent& event) OVERRIDE; | 75 const ui::KeyEvent& event) OVERRIDE; |
66 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 76 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 virtual int GetTextWidth() const OVERRIDE; | 118 virtual int GetTextWidth() const OVERRIDE; |
109 virtual int GetWidth() const OVERRIDE; | 119 virtual int GetWidth() const OVERRIDE; |
110 virtual bool IsImeComposing() const OVERRIDE; | 120 virtual bool IsImeComposing() const OVERRIDE; |
111 virtual bool IsImeShowingPopup() const OVERRIDE; | 121 virtual bool IsImeShowingPopup() const OVERRIDE; |
112 virtual void ShowImeIfNeeded() OVERRIDE; | 122 virtual void ShowImeIfNeeded() OVERRIDE; |
113 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 123 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
114 virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE; | 124 virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE; |
115 virtual base::string16 GetLabelForCommandId(int command_id) const OVERRIDE; | 125 virtual base::string16 GetLabelForCommandId(int command_id) const OVERRIDE; |
116 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | 126 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
117 | 127 |
| 128 // gfx::AnimationDelegate: |
| 129 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 130 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
| 131 |
118 // views::TextfieldController: | 132 // views::TextfieldController: |
119 virtual void ContentsChanged(views::Textfield* sender, | 133 virtual void ContentsChanged(views::Textfield* sender, |
120 const base::string16& new_contents) OVERRIDE; | 134 const base::string16& new_contents) OVERRIDE; |
121 virtual bool HandleKeyEvent(views::Textfield* sender, | 135 virtual bool HandleKeyEvent(views::Textfield* sender, |
122 const ui::KeyEvent& key_event) OVERRIDE; | 136 const ui::KeyEvent& key_event) OVERRIDE; |
123 virtual void OnBeforeUserAction(views::Textfield* sender) OVERRIDE; | 137 virtual void OnBeforeUserAction(views::Textfield* sender) OVERRIDE; |
124 virtual void OnAfterUserAction(views::Textfield* sender) OVERRIDE; | 138 virtual void OnAfterUserAction(views::Textfield* sender) OVERRIDE; |
125 virtual void OnAfterCutOrCopy() OVERRIDE; | 139 virtual void OnAfterCutOrCopy() OVERRIDE; |
126 virtual void OnWriteDragData(ui::OSExchangeData* data) OVERRIDE; | 140 virtual void OnWriteDragData(ui::OSExchangeData* data) OVERRIDE; |
127 virtual void OnGetDragOperationsForTextfield(int* drag_operations) OVERRIDE; | 141 virtual void OnGetDragOperationsForTextfield(int* drag_operations) OVERRIDE; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // We select in response to a click that focuses the omnibox, but we defer | 211 // We select in response to a click that focuses the omnibox, but we defer |
198 // until release, setting this variable back to false if we saw a drag, to | 212 // until release, setting this variable back to false if we saw a drag, to |
199 // allow the user to select just a portion of the text. | 213 // allow the user to select just a portion of the text. |
200 bool select_all_on_mouse_release_; | 214 bool select_all_on_mouse_release_; |
201 | 215 |
202 // Indicates if we want to select all text in the omnibox when we get a | 216 // Indicates if we want to select all text in the omnibox when we get a |
203 // GESTURE_TAP. We want to select all only when the textfield is not in focus | 217 // GESTURE_TAP. We want to select all only when the textfield is not in focus |
204 // and gets a tap. So we use this variable to remember focus state before tap. | 218 // and gets a tap. So we use this variable to remember focus state before tap. |
205 bool select_all_on_gesture_tap_; | 219 bool select_all_on_gesture_tap_; |
206 | 220 |
| 221 scoped_ptr<gfx::SlideAnimation> fade_in_animation_; |
| 222 |
207 DISALLOW_COPY_AND_ASSIGN(OmniboxViewViews); | 223 DISALLOW_COPY_AND_ASSIGN(OmniboxViewViews); |
208 }; | 224 }; |
209 | 225 |
210 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ | 226 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ |
OLD | NEW |