| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // EditSearchEngineDialog provides text fields for editing a keyword: the title, | |
| 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 | |
| 8 // the ExternalJSObject via the RenderView. | |
| 9 | |
| 10 #ifndef CHROME_BROWSER_UI_VIEWS_EDIT_SEARCH_ENGINE_DIALOG_H_ | |
| 11 #define CHROME_BROWSER_UI_VIEWS_EDIT_SEARCH_ENGINE_DIALOG_H_ | |
| 12 | |
| 13 #include "base/macros.h" | |
| 14 #include "ui/views/controls/textfield/textfield_controller.h" | |
| 15 #include "ui/views/window/dialog_delegate.h" | |
| 16 | |
| 17 namespace views { | |
| 18 class Label; | |
| 19 class ImageView; | |
| 20 } | |
| 21 | |
| 22 class EditSearchEngineController; | |
| 23 class EditSearchEngineControllerDelegate; | |
| 24 class Profile; | |
| 25 class TemplateURL; | |
| 26 | |
| 27 class EditSearchEngineDialog : public views::TextfieldController, | |
| 28 public views::DialogDelegateView { | |
| 29 public: | |
| 30 // The |template_url| and/or |delegate| may be NULL. | |
| 31 EditSearchEngineDialog(TemplateURL* template_url, | |
| 32 EditSearchEngineControllerDelegate* delegate, | |
| 33 Profile* profile); | |
| 34 ~EditSearchEngineDialog() override; | |
| 35 | |
| 36 // Shows the dialog to the user. | |
| 37 static void Show(gfx::NativeWindow parent, | |
| 38 TemplateURL* template_url, | |
| 39 EditSearchEngineControllerDelegate* delegate, | |
| 40 Profile* profile); | |
| 41 | |
| 42 // views::DialogDelegate: | |
| 43 ui::ModalType GetModalType() const override; | |
| 44 base::string16 GetWindowTitle() const override; | |
| 45 bool IsDialogButtonEnabled(ui::DialogButton button) const override; | |
| 46 bool Cancel() override; | |
| 47 bool Accept() override; | |
| 48 | |
| 49 // views::TextfieldController: | |
| 50 // Updates whether the user can accept the dialog as well as updating image | |
| 51 // views showing whether value is valid. | |
| 52 void ContentsChanged(views::Textfield* sender, | |
| 53 const base::string16& new_contents) override; | |
| 54 bool HandleKeyEvent(views::Textfield* sender, | |
| 55 const ui::KeyEvent& key_event) override; | |
| 56 | |
| 57 private: | |
| 58 void Init(); | |
| 59 | |
| 60 // Create a Label containing the text with the specified message id. | |
| 61 views::Label* CreateLabel(int message_id); | |
| 62 | |
| 63 // Creates a text field with the specified text. | |
| 64 views::Textfield* CreateTextfield(const base::string16& text); | |
| 65 | |
| 66 // Invokes UpdateImageView for each of the images views. | |
| 67 void UpdateImageViews(); | |
| 68 | |
| 69 // Updates the tooltip and image of the image view based on is_valid. If | |
| 70 // is_valid is false the tooltip of the image view is set to the message with | |
| 71 // id invalid_message_id, otherwise the tooltip is set to the empty text. | |
| 72 void UpdateImageView(views::ImageView* image_view, | |
| 73 bool is_valid, | |
| 74 int invalid_message_id); | |
| 75 | |
| 76 // Text fields. | |
| 77 views::Textfield* title_tf_; | |
| 78 views::Textfield* keyword_tf_; | |
| 79 views::Textfield* url_tf_; | |
| 80 | |
| 81 // Shows error images. | |
| 82 views::ImageView* title_iv_; | |
| 83 views::ImageView* keyword_iv_; | |
| 84 views::ImageView* url_iv_; | |
| 85 | |
| 86 std::unique_ptr<EditSearchEngineController> controller_; | |
| 87 | |
| 88 DISALLOW_COPY_AND_ASSIGN(EditSearchEngineDialog); | |
| 89 }; | |
| 90 | |
| 91 #endif // CHROME_BROWSER_UI_VIEWS_EDIT_SEARCH_ENGINE_DIALOG_H_ | |
| OLD | NEW |