| 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_FIND_BAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "chrome/browser/ui/views/dropdown_bar_host_delegate.h" | 13 #include "chrome/browser/ui/views/dropdown_bar_host_delegate.h" |
| 14 #include "ui/views/controls/button/vector_icon_button_delegate.h" | 14 #include "ui/views/controls/button/button.h" |
| 15 #include "ui/views/controls/textfield/textfield_controller.h" | 15 #include "ui/views/controls/textfield/textfield_controller.h" |
| 16 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
| 17 #include "ui/views/view_targeter_delegate.h" | 17 #include "ui/views/view_targeter_delegate.h" |
| 18 | 18 |
| 19 class FindBarHost; | 19 class FindBarHost; |
| 20 class FindNotificationDetails; | 20 class FindNotificationDetails; |
| 21 | 21 |
| 22 namespace gfx { | 22 namespace gfx { |
| 23 class Range; | 23 class Range; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace views { | 26 namespace views { |
| 27 class ImageButton; |
| 27 class Label; | 28 class Label; |
| 28 class Painter; | 29 class Painter; |
| 29 class Separator; | 30 class Separator; |
| 30 class Textfield; | 31 class Textfield; |
| 31 class VectorIconButton; | |
| 32 } | 32 } |
| 33 | 33 |
| 34 //////////////////////////////////////////////////////////////////////////////// | 34 //////////////////////////////////////////////////////////////////////////////// |
| 35 // | 35 // |
| 36 // The FindBarView is responsible for drawing the UI controls of the | 36 // The FindBarView is responsible for drawing the UI controls of the |
| 37 // FindBar, the find text box, the 'Find' button and the 'Close' | 37 // FindBar, the find text box, the 'Find' button and the 'Close' |
| 38 // button. It communicates the user search words to the FindBarHost. | 38 // button. It communicates the user search words to the FindBarHost. |
| 39 // | 39 // |
| 40 //////////////////////////////////////////////////////////////////////////////// | 40 //////////////////////////////////////////////////////////////////////////////// |
| 41 class FindBarView : public views::View, | 41 class FindBarView : public views::View, |
| 42 public DropdownBarHostDelegate, | 42 public DropdownBarHostDelegate, |
| 43 public views::VectorIconButtonDelegate, | 43 public views::ButtonListener, |
| 44 public views::TextfieldController, | 44 public views::TextfieldController, |
| 45 public views::ViewTargeterDelegate { | 45 public views::ViewTargeterDelegate { |
| 46 public: | 46 public: |
| 47 explicit FindBarView(FindBarHost* host); | 47 explicit FindBarView(FindBarHost* host); |
| 48 ~FindBarView() override; | 48 ~FindBarView() override; |
| 49 | 49 |
| 50 // Accessors for the text and selection displayed in the text box. | 50 // Accessors for the text and selection displayed in the text box. |
| 51 void SetFindTextAndSelectedRange(const base::string16& find_text, | 51 void SetFindTextAndSelectedRange(const base::string16& find_text, |
| 52 const gfx::Range& selected_range); | 52 const gfx::Range& selected_range); |
| 53 base::string16 GetFindText() const; | 53 base::string16 GetFindText() const; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 67 // Clears the current Match Count value in the Find text box. | 67 // Clears the current Match Count value in the Find text box. |
| 68 void ClearMatchCount(); | 68 void ClearMatchCount(); |
| 69 | 69 |
| 70 // views::View: | 70 // views::View: |
| 71 void Layout() override; | 71 void Layout() override; |
| 72 gfx::Size GetPreferredSize() const override; | 72 gfx::Size GetPreferredSize() const override; |
| 73 | 73 |
| 74 // DropdownBarHostDelegate: | 74 // DropdownBarHostDelegate: |
| 75 void SetFocusAndSelection(bool select_all) override; | 75 void SetFocusAndSelection(bool select_all) override; |
| 76 | 76 |
| 77 // views::VectorIconButtonDelegate: | 77 // views::ButtonListener: |
| 78 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 78 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 79 SkColor GetVectorIconBaseColor() const override; | |
| 80 | 79 |
| 81 // views::TextfieldController: | 80 // views::TextfieldController: |
| 82 bool HandleKeyEvent(views::Textfield* sender, | 81 bool HandleKeyEvent(views::Textfield* sender, |
| 83 const ui::KeyEvent& key_event) override; | 82 const ui::KeyEvent& key_event) override; |
| 84 void OnAfterUserAction(views::Textfield* sender) override; | 83 void OnAfterUserAction(views::Textfield* sender) override; |
| 85 void OnAfterPaste() override; | 84 void OnAfterPaste() override; |
| 86 | 85 |
| 87 // views::ViewTargeterDelegate: | 86 // views::ViewTargeterDelegate: |
| 88 views::View* TargetForRect(View* root, const gfx::Rect& rect) override; | 87 views::View* TargetForRect(View* root, const gfx::Rect& rect) override; |
| 89 | 88 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 108 // Used to detect if the input text, not including the IME composition text, | 107 // Used to detect if the input text, not including the IME composition text, |
| 109 // has changed or not. | 108 // has changed or not. |
| 110 base::string16 last_searched_text_; | 109 base::string16 last_searched_text_; |
| 111 | 110 |
| 112 // The controls in the window. | 111 // The controls in the window. |
| 113 views::Textfield* find_text_; | 112 views::Textfield* find_text_; |
| 114 std::unique_ptr<views::Painter> find_text_border_; | 113 std::unique_ptr<views::Painter> find_text_border_; |
| 115 views::Label* match_count_text_; | 114 views::Label* match_count_text_; |
| 116 views::View* focus_forwarder_view_; | 115 views::View* focus_forwarder_view_; |
| 117 views::Separator* separator_; | 116 views::Separator* separator_; |
| 118 views::VectorIconButton* find_previous_button_; | 117 views::ImageButton* find_previous_button_; |
| 119 views::VectorIconButton* find_next_button_; | 118 views::ImageButton* find_next_button_; |
| 120 views::VectorIconButton* close_button_; | 119 views::ImageButton* close_button_; |
| 121 | 120 |
| 122 // The preferred height of the find bar. | 121 // The preferred height of the find bar. |
| 123 int preferred_height_; | 122 int preferred_height_; |
| 124 | 123 |
| 125 DISALLOW_COPY_AND_ASSIGN(FindBarView); | 124 DISALLOW_COPY_AND_ASSIGN(FindBarView); |
| 126 }; | 125 }; |
| 127 | 126 |
| 128 #endif // CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ | 127 #endif // CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ |
| OLD | NEW |