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

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

Issue 2561963002: base: Remove the string logging from CHECK(). (Closed)
Patch Set: checkstring: rebase Created 4 years 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
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 // Call a Javascript function by sending its name and arguments down to 94 // Call a Javascript function by sending its name and arguments down to
95 // the renderer. This is asynchronous; there's no way to get the result 95 // the renderer. This is asynchronous; there's no way to get the result
96 // of the call, and should be thought of more like sending a message to 96 // of the call, and should be thought of more like sending a message to
97 // the page. 97 // the page.
98 // All function names in WebUI must consist of only ASCII characters. 98 // All function names in WebUI must consist of only ASCII characters.
99 // These functions will crash if JavaScript is not currently allowed. 99 // These functions will crash if JavaScript is not currently allowed.
100 template <typename... Values> 100 template <typename... Values>
101 void CallJavascriptFunction(const std::string& function_name, 101 void CallJavascriptFunction(const std::string& function_name,
102 const Values&... values) { 102 const Values&... values) {
103 CHECK(IsJavascriptAllowed()) << "Cannot CallJavascriptFunction before " 103 // Cannot CallJavascriptFunction before explicitly allowing JavaScript.
104 "explicitly allowing JavaScript."; 104 CHECK(IsJavascriptAllowed());
105 105
106 // The CHECK above makes this call safe. 106 // The CHECK above makes this call safe.
107 web_ui()->CallJavascriptFunctionUnsafe(function_name, values...); 107 web_ui()->CallJavascriptFunctionUnsafe(function_name, values...);
108 } 108 }
109 109
110 // Returns the attached WebUI for this handler. 110 // Returns the attached WebUI for this handler.
111 WebUI* web_ui() const { return web_ui_; } 111 WebUI* web_ui() const { return web_ui_; }
112 112
113 // Sets the attached WebUI - exposed to subclasses for testing purposes. 113 // Sets the attached WebUI - exposed to subclasses for testing purposes.
114 void set_web_ui(WebUI* web_ui) { web_ui_ = web_ui; } 114 void set_web_ui(WebUI* web_ui) { web_ui_ = web_ui; }
115 115
116 private: 116 private:
117 // Provide external classes access to web_ui(), set_web_ui(), and 117 // Provide external classes access to web_ui(), set_web_ui(), and
118 // RenderViewReused. 118 // RenderViewReused.
119 friend class WebUIImpl; 119 friend class WebUIImpl;
120 friend class ::WebUIBrowserTest; 120 friend class ::WebUIBrowserTest;
121 121
122 // TODO(dbeam): disallow JavaScript when a renderer process crashes. 122 // TODO(dbeam): disallow JavaScript when a renderer process crashes.
123 // http://crbug.com/610450 123 // http://crbug.com/610450
124 124
125 // True if the page is for JavaScript calls from this handler. 125 // True if the page is for JavaScript calls from this handler.
126 bool javascript_allowed_; 126 bool javascript_allowed_;
127 127
128 WebUI* web_ui_; 128 WebUI* web_ui_;
129 }; 129 };
130 130
131 } // namespace content 131 } // namespace content
132 132
133 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_ 133 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698