Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Side by Side Diff: content/public/browser/web_ui_message_handler.h

Issue 2041993002: WebUI: Fix lifecycle-bug when RenderFrameHost is swapped out (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/webui/web_ui_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 class WebUIImpl; 28 class WebUIImpl;
29 29
30 // Messages sent from the DOM are forwarded via the WebUI to handler 30 // Messages sent from the DOM are forwarded via the WebUI to handler
31 // classes. These objects are owned by WebUI and destroyed when the 31 // classes. These objects are owned by WebUI and destroyed when the
32 // host is destroyed. 32 // host is destroyed.
33 class CONTENT_EXPORT WebUIMessageHandler { 33 class CONTENT_EXPORT WebUIMessageHandler {
34 public: 34 public:
35 WebUIMessageHandler() : javascript_allowed_(false), web_ui_(nullptr) {} 35 WebUIMessageHandler() : javascript_allowed_(false), web_ui_(nullptr) {}
36 virtual ~WebUIMessageHandler() {} 36 virtual ~WebUIMessageHandler() {}
37 37
38 // Call this when a page should not receive JavaScript messages.
39 void DisallowJavascript();
40
38 protected: 41 protected:
39 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractIntegerValue); 42 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractIntegerValue);
40 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractDoubleValue); 43 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractDoubleValue);
41 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractStringValue); 44 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractStringValue);
42 45
43 // Subclasses must call this once the page is ready for JavaScript calls 46 // Subclasses must call this once the page is ready for JavaScript calls
44 // from this handler. 47 // from this handler.
45 void AllowJavascript(); 48 void AllowJavascript();
46 49
47 // Call this when a page should not receive JavaScript messages.
48 void DisallowJavascript();
49
50 bool IsJavascriptAllowed() const; 50 bool IsJavascriptAllowed() const;
51 51
52 // Helper methods: 52 // Helper methods:
53 53
54 // Extract an integer value from a list Value. 54 // Extract an integer value from a list Value.
55 static bool ExtractIntegerValue(const base::ListValue* value, int* out_int); 55 static bool ExtractIntegerValue(const base::ListValue* value, int* out_int);
56 56
57 // Extract a floating point (double) value from a list Value. 57 // Extract a floating point (double) value from a list Value.
58 static bool ExtractDoubleValue(const base::ListValue* value, 58 static bool ExtractDoubleValue(const base::ListValue* value,
59 double* out_value); 59 double* out_value);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 // True if the page is for JavaScript calls from this handler. 112 // True if the page is for JavaScript calls from this handler.
113 bool javascript_allowed_; 113 bool javascript_allowed_;
114 114
115 WebUI* web_ui_; 115 WebUI* web_ui_;
116 }; 116 };
117 117
118 } // namespace content 118 } // namespace content
119 119
120 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_ 120 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_
OLDNEW
« no previous file with comments | « content/browser/webui/web_ui_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698