| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_WEBUI_EDIT_SEARCH_ENGINE_DIALOG_WEBUI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_EDIT_SEARCH_ENGINE_DIALOG_WEBUI_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_EDIT_SEARCH_ENGINE_DIALOG_WEBUI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_EDIT_SEARCH_ENGINE_DIALOG_WEBUI_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 13 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
| 14 #include "content/public/browser/web_ui_message_handler.h" |
| 14 | 15 |
| 15 class EditSearchEngineController; | 16 class EditSearchEngineController; |
| 16 class Profile; | 17 class Profile; |
| 17 class TemplateURL; | 18 class TemplateURL; |
| 18 class EditSearchEngineDialogHandlerWebUI; | 19 class EditSearchEngineDialogHandlerWebUI; |
| 19 | 20 |
| 20 // EditSearchEngineDialogWebUI is the WebUI HTML dialog version of the edit | 21 // EditSearchEngineDialogWebUI is the WebUI HTML dialog version of the edit |
| 21 // search engine dialog. | 22 // search engine dialog. |
| 22 class EditSearchEngineDialogWebUI : private HtmlDialogUIDelegate { | 23 class EditSearchEngineDialogWebUI : private HtmlDialogUIDelegate { |
| 23 public: | 24 public: |
| 24 static void ShowEditSearchEngineDialog(const TemplateURL* template_url, | 25 static void ShowEditSearchEngineDialog(const TemplateURL* template_url, |
| 25 Profile* profile); | 26 Profile* profile); |
| 26 | 27 |
| 27 private: | 28 private: |
| 28 explicit EditSearchEngineDialogWebUI( | 29 explicit EditSearchEngineDialogWebUI( |
| 29 EditSearchEngineDialogHandlerWebUI* handler); | 30 EditSearchEngineDialogHandlerWebUI* handler); |
| 30 | 31 |
| 31 // Shows the dialog | 32 // Shows the dialog |
| 32 void ShowDialog(); | 33 void ShowDialog(); |
| 33 | 34 |
| 34 // HtmlDialogUIDelegate methods | 35 // HtmlDialogUIDelegate methods |
| 35 virtual bool IsDialogModal() const OVERRIDE; | 36 virtual bool IsDialogModal() const OVERRIDE; |
| 36 virtual string16 GetDialogTitle() const OVERRIDE; | 37 virtual string16 GetDialogTitle() const OVERRIDE; |
| 37 virtual GURL GetDialogContentURL() const OVERRIDE; | 38 virtual GURL GetDialogContentURL() const OVERRIDE; |
| 38 virtual void GetWebUIMessageHandlers( | 39 virtual void GetWebUIMessageHandlers( |
| 39 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE; | 40 std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE; |
| 40 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; | 41 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; |
| 41 virtual std::string GetDialogArgs() const OVERRIDE; | 42 virtual std::string GetDialogArgs() const OVERRIDE; |
| 42 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; | 43 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; |
| 43 virtual void OnCloseContents(content::WebContents* source, | 44 virtual void OnCloseContents(content::WebContents* source, |
| 44 bool* out_close_dialog) OVERRIDE; | 45 bool* out_close_dialog) OVERRIDE; |
| 45 virtual bool ShouldShowDialogTitle() const OVERRIDE; | 46 virtual bool ShouldShowDialogTitle() const OVERRIDE; |
| 46 | 47 |
| 47 // The message handler for this dialog. | 48 // The message handler for this dialog. |
| 48 EditSearchEngineDialogHandlerWebUI* handler_; | 49 EditSearchEngineDialogHandlerWebUI* handler_; |
| 49 | 50 |
| 50 DISALLOW_COPY_AND_ASSIGN(EditSearchEngineDialogWebUI); | 51 DISALLOW_COPY_AND_ASSIGN(EditSearchEngineDialogWebUI); |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 // EditSearchEngineDialogHandlerWebUI is the message handling component of the | 54 // EditSearchEngineDialogHandlerWebUI is the message handling component of the |
| 54 // EditSearchEngineDialogWebUI. It handles messages from JavaScript, and it | 55 // EditSearchEngineDialogWebUI. It handles messages from JavaScript, and it |
| 55 // handles the closing of the dialog. | 56 // handles the closing of the dialog. |
| 56 class EditSearchEngineDialogHandlerWebUI : public WebUIMessageHandler { | 57 class EditSearchEngineDialogHandlerWebUI : public content::WebUIMessageHandler { |
| 57 public: | 58 public: |
| 58 EditSearchEngineDialogHandlerWebUI(const TemplateURL* template_url, | 59 EditSearchEngineDialogHandlerWebUI(const TemplateURL* template_url, |
| 59 Profile* profile); | 60 Profile* profile); |
| 60 virtual ~EditSearchEngineDialogHandlerWebUI(); | 61 virtual ~EditSearchEngineDialogHandlerWebUI(); |
| 61 | 62 |
| 62 // Overridden from WebUIMessageHandler | 63 // Overridden from WebUIMessageHandler |
| 63 virtual void RegisterMessages() OVERRIDE; | 64 virtual void RegisterMessages() OVERRIDE; |
| 64 | 65 |
| 65 // Returns true if adding, and false if editing, based on the template_url. | 66 // Returns true if adding, and false if editing, based on the template_url. |
| 66 bool IsAdding(); | 67 bool IsAdding(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 79 // The profile. | 80 // The profile. |
| 80 Profile* profile_; | 81 Profile* profile_; |
| 81 | 82 |
| 82 // The controller. | 83 // The controller. |
| 83 scoped_ptr<EditSearchEngineController> controller_; | 84 scoped_ptr<EditSearchEngineController> controller_; |
| 84 | 85 |
| 85 DISALLOW_COPY_AND_ASSIGN(EditSearchEngineDialogHandlerWebUI); | 86 DISALLOW_COPY_AND_ASSIGN(EditSearchEngineDialogHandlerWebUI); |
| 86 }; | 87 }; |
| 87 | 88 |
| 88 #endif // CHROME_BROWSER_UI_WEBUI_EDIT_SEARCH_ENGINE_DIALOG_WEBUI_H_ | 89 #endif // CHROME_BROWSER_UI_WEBUI_EDIT_SEARCH_ENGINE_DIALOG_WEBUI_H_ |
| OLD | NEW |