| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // EditKeywordController provides text fields for editing a keyword: the title, | 5 // EditKeywordController provides text fields for editing a keyword: the title, |
| 6 // url and actual keyword. It is used by the KeywordEditorView of the Options | 6 // url and actual keyword. It is used by the KeywordEditorView of the Options |
| 7 // dialog, and also on its own to confirm the addition of a keyword added by | 7 // dialog, and also on its own to confirm the addition of a keyword added by |
| 8 // the ExternalJSObject via the RenderView. | 8 // the ExternalJSObject via the RenderView. |
| 9 | 9 |
| 10 #ifndef CHROME_BROWSER_VIEWS_EDIT_KEYWORD_CONTROLLER_H_ | 10 #ifndef CHROME_BROWSER_VIEWS_EDIT_KEYWORD_CONTROLLER_H_ |
| 11 #define CHROME_BROWSER_VIEWS_EDIT_KEYWORD_CONTROLLER_H_ | 11 #define CHROME_BROWSER_VIEWS_EDIT_KEYWORD_CONTROLLER_H_ |
| 12 | 12 |
| 13 #include <windows.h> | 13 #include <windows.h> |
| 14 | 14 |
| 15 #include "views/controls/text_field.h" | 15 #include "views/controls/textfield/textfield.h" |
| 16 #include "views/window/dialog_delegate.h" | 16 #include "views/window/dialog_delegate.h" |
| 17 | 17 |
| 18 namespace views { | 18 namespace views { |
| 19 class Label; | 19 class Label; |
| 20 class ImageView; | 20 class ImageView; |
| 21 class Window; | 21 class Window; |
| 22 } | 22 } |
| 23 | 23 |
| 24 class KeywordEditorView; | 24 class KeywordEditorView; |
| 25 class Profile; | 25 class Profile; |
| 26 class TemplateURL; | 26 class TemplateURL; |
| 27 class TemplateURLModel; | 27 class TemplateURLModel; |
| 28 | 28 |
| 29 class EditKeywordController : public views::TextField::Controller, | 29 class EditKeywordController : public views::Textfield::Controller, |
| 30 public views::DialogDelegate { | 30 public views::DialogDelegate { |
| 31 public: | 31 public: |
| 32 // The template_url and/or keyword_editor_view may be NULL. | 32 // The template_url and/or keyword_editor_view may be NULL. |
| 33 EditKeywordController(HWND parent, | 33 EditKeywordController(HWND parent, |
| 34 const TemplateURL* template_url, | 34 const TemplateURL* template_url, |
| 35 KeywordEditorView* keyword_editor_view, | 35 KeywordEditorView* keyword_editor_view, |
| 36 Profile* profile); | 36 Profile* profile); |
| 37 | 37 |
| 38 virtual ~EditKeywordController() {} | 38 virtual ~EditKeywordController() {} |
| 39 | 39 |
| 40 // Shows the dialog to the user. EditKeywordController takes care of | 40 // Shows the dialog to the user. EditKeywordController takes care of |
| 41 // deleting itself after show has been invoked. | 41 // deleting itself after show has been invoked. |
| 42 void Show(); | 42 void Show(); |
| 43 | 43 |
| 44 // DialogDelegate overrides. | 44 // DialogDelegate overrides. |
| 45 virtual bool IsModal() const; | 45 virtual bool IsModal() const; |
| 46 virtual std::wstring GetWindowTitle() const; | 46 virtual std::wstring GetWindowTitle() const; |
| 47 virtual bool IsDialogButtonEnabled( | 47 virtual bool IsDialogButtonEnabled( |
| 48 MessageBoxFlags::DialogButton button) const; | 48 MessageBoxFlags::DialogButton button) const; |
| 49 virtual void DeleteDelegate(); | 49 virtual void DeleteDelegate(); |
| 50 virtual bool Cancel(); | 50 virtual bool Cancel(); |
| 51 virtual bool Accept(); | 51 virtual bool Accept(); |
| 52 virtual views::View* GetContentsView(); | 52 virtual views::View* GetContentsView(); |
| 53 | 53 |
| 54 // views::TextField::Controller overrides. Updates whether the user can | 54 // views::Textfield::Controller overrides. Updates whether the user can |
| 55 // accept the dialog as well as updating image views showing whether value is | 55 // accept the dialog as well as updating image views showing whether value is |
| 56 // valid. | 56 // valid. |
| 57 virtual void ContentsChanged(views::TextField* sender, | 57 virtual void ContentsChanged(views::Textfield* sender, |
| 58 const std::wstring& new_contents); | 58 const std::wstring& new_contents); |
| 59 virtual bool HandleKeystroke(views::TextField* sender, | 59 virtual bool HandleKeystroke(views::Textfield* sender, |
| 60 const views::TextField::Keystroke& key); | 60 const views::Textfield::Keystroke& key); |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 void Init(); | 63 void Init(); |
| 64 | 64 |
| 65 // Create a Label containing the text with the specified message id. | 65 // Create a Label containing the text with the specified message id. |
| 66 views::Label* CreateLabel(int message_id); | 66 views::Label* CreateLabel(int message_id); |
| 67 | 67 |
| 68 // Creates a text field with the specified text. If |lowercase| is true, the | 68 // Creates a text field with the specified text. If |lowercase| is true, the |
| 69 // textfield is configured to map all input to lower case. | 69 // Textfield is configured to map all input to lower case. |
| 70 views::TextField* CreateTextField(const std::wstring& text, bool lowercase); | 70 views::Textfield* CreateTextfield(const std::wstring& text, bool lowercase); |
| 71 | 71 |
| 72 // Returns true if the currently input URL is valid. The URL is valid if it | 72 // Returns true if the currently input URL is valid. The URL is valid if it |
| 73 // contains no search terms and is a valid url, or if it contains a search | 73 // contains no search terms and is a valid url, or if it contains a search |
| 74 // term and replacing that search term with a character results in a valid | 74 // term and replacing that search term with a character results in a valid |
| 75 // url. | 75 // url. |
| 76 bool IsURLValid() const; | 76 bool IsURLValid() const; |
| 77 | 77 |
| 78 // Returns the URL the user has input. The returned URL is suitable for use | 78 // Returns the URL the user has input. The returned URL is suitable for use |
| 79 // by TemplateURL. | 79 // by TemplateURL. |
| 80 std::wstring GetURL() const; | 80 std::wstring GetURL() const; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 110 views::View* view_; | 110 views::View* view_; |
| 111 | 111 |
| 112 // We may have been created by this, in which case we will call back to it on | 112 // We may have been created by this, in which case we will call back to it on |
| 113 // success to add/modify the entry. May be NULL. | 113 // success to add/modify the entry. May be NULL. |
| 114 KeywordEditorView* keyword_editor_view_; | 114 KeywordEditorView* keyword_editor_view_; |
| 115 | 115 |
| 116 // Profile whose TemplateURLModel we're modifying. | 116 // Profile whose TemplateURLModel we're modifying. |
| 117 Profile* profile_; | 117 Profile* profile_; |
| 118 | 118 |
| 119 // Text fields. | 119 // Text fields. |
| 120 views::TextField* title_tf_; | 120 views::Textfield* title_tf_; |
| 121 views::TextField* keyword_tf_; | 121 views::Textfield* keyword_tf_; |
| 122 views::TextField* url_tf_; | 122 views::Textfield* url_tf_; |
| 123 | 123 |
| 124 // Shows error images. | 124 // Shows error images. |
| 125 views::ImageView* title_iv_; | 125 views::ImageView* title_iv_; |
| 126 views::ImageView* keyword_iv_; | 126 views::ImageView* keyword_iv_; |
| 127 views::ImageView* url_iv_; | 127 views::ImageView* url_iv_; |
| 128 | 128 |
| 129 DISALLOW_COPY_AND_ASSIGN(EditKeywordController); | 129 DISALLOW_COPY_AND_ASSIGN(EditKeywordController); |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 #endif // CHROME_BROWSER_VIEWS_EDIT_KEYWORD_CONTROLLER_H_ | 132 #endif // CHROME_BROWSER_VIEWS_EDIT_KEYWORD_CONTROLLER_H_ |
| OLD | NEW |