| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_SETTINGS_SETTINGS_PAGE_UI_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_PAGE_UI_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_PAGE_UI_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_PAGE_UI_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "content/public/browser/web_ui_message_handler.h" | 10 #include "content/public/browser/web_ui_message_handler.h" |
| 11 | 11 |
| 12 namespace settings { | 12 namespace settings { |
| 13 | 13 |
| 14 // The base class handler of Javascript messages of settings pages. | 14 // The base class handler of Javascript messages of settings pages. |
| 15 class SettingsPageUIHandler : public content::WebUIMessageHandler { | 15 class SettingsPageUIHandler : public content::WebUIMessageHandler { |
| 16 public: | 16 public: |
| 17 SettingsPageUIHandler(); | 17 SettingsPageUIHandler(); |
| 18 ~SettingsPageUIHandler() override; | 18 ~SettingsPageUIHandler() override; |
| 19 | 19 |
| 20 protected: | |
| 21 // Helper method for responding to JS requests initiated with | |
| 22 // cr.sendWithPromise(), for the case where the returned promise should be | |
| 23 // resolved (request succeeded). | |
| 24 void ResolveJavascriptCallback(const base::Value& callback_id, | |
| 25 const base::Value& response); | |
| 26 | |
| 27 // Helper method for responding to JS requests initiated with | |
| 28 // cr.sendWithPromise(), for the case where the returned promise should be | |
| 29 // rejected (request failed). | |
| 30 void RejectJavascriptCallback(const base::Value& callback_id, | |
| 31 const base::Value& response); | |
| 32 | |
| 33 private: | 20 private: |
| 34 // SettingsPageUIHandler subclasses must be JavaScript-lifecycle safe. | 21 // SettingsPageUIHandler subclasses must be JavaScript-lifecycle safe. |
| 35 void OnJavascriptAllowed() override = 0; | 22 void OnJavascriptAllowed() override = 0; |
| 36 void OnJavascriptDisallowed() override = 0; | 23 void OnJavascriptDisallowed() override = 0; |
| 37 | 24 |
| 38 DISALLOW_COPY_AND_ASSIGN(SettingsPageUIHandler); | 25 DISALLOW_COPY_AND_ASSIGN(SettingsPageUIHandler); |
| 39 }; | 26 }; |
| 40 | 27 |
| 41 } // namespace settings | 28 } // namespace settings |
| 42 | 29 |
| 43 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_PAGE_UI_HANDLER_H_ | 30 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_PAGE_UI_HANDLER_H_ |
| OLD | NEW |