| 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 CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 protected: | 38 protected: |
| 39 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractIntegerValue); | 39 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractIntegerValue); |
| 40 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractDoubleValue); | 40 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractDoubleValue); |
| 41 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractStringValue); | 41 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractStringValue); |
| 42 | 42 |
| 43 // Subclasses must call this once the page is ready for JavaScript calls | 43 // Subclasses must call this once the page is ready for JavaScript calls |
| 44 // from this handler. | 44 // from this handler. |
| 45 void AllowJavascript(); | 45 void AllowJavascript(); |
| 46 | 46 |
| 47 // Call this when a page should not receive JavaScript messages. |
| 48 void DisallowJavascript(); |
| 49 |
| 47 bool IsJavascriptAllowed() const; | 50 bool IsJavascriptAllowed() const; |
| 48 | 51 |
| 49 // Helper methods: | 52 // Helper methods: |
| 50 | 53 |
| 51 // Extract an integer value from a list Value. | 54 // Extract an integer value from a list Value. |
| 52 static bool ExtractIntegerValue(const base::ListValue* value, int* out_int); | 55 static bool ExtractIntegerValue(const base::ListValue* value, int* out_int); |
| 53 | 56 |
| 54 // Extract a floating point (double) value from a list Value. | 57 // Extract a floating point (double) value from a list Value. |
| 55 static bool ExtractDoubleValue(const base::ListValue* value, | 58 static bool ExtractDoubleValue(const base::ListValue* value, |
| 56 double* out_value); | 59 double* out_value); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 99 |
| 97 private: | 100 private: |
| 98 // Provide external classes access to web_ui(), set_web_ui(), and | 101 // Provide external classes access to web_ui(), set_web_ui(), and |
| 99 // RenderViewReused. | 102 // RenderViewReused. |
| 100 friend class WebUIImpl; | 103 friend class WebUIImpl; |
| 101 friend class ::WebUIBrowserTest; | 104 friend class ::WebUIBrowserTest; |
| 102 | 105 |
| 103 // Called when a RenderView is reused to display a page (i.e. reload). | 106 // Called when a RenderView is reused to display a page (i.e. reload). |
| 104 void RenderViewReused(); | 107 void RenderViewReused(); |
| 105 | 108 |
| 109 // TODO(dbeam): disallow JavaScript when a renderer process crashes. |
| 110 |
| 106 // True if the page is for JavaScript calls from this handler. | 111 // True if the page is for JavaScript calls from this handler. |
| 107 bool javascript_allowed_; | 112 bool javascript_allowed_; |
| 108 | 113 |
| 109 WebUI* web_ui_; | 114 WebUI* web_ui_; |
| 110 }; | 115 }; |
| 111 | 116 |
| 112 } // namespace content | 117 } // namespace content |
| 113 | 118 |
| 114 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_ | 119 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_ |
| OLD | NEW |