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

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

Issue 1995113002: Rename WebUI::CallJavascriptFunction to WebUI::CallJavascriptFunctionUnsafe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // the renderer. This is asynchronous; there's no way to get the result 81 // the renderer. This is asynchronous; there's no way to get the result
82 // of the call, and should be thought of more like sending a message to 82 // of the call, and should be thought of more like sending a message to
83 // the page. 83 // the page.
84 // All function names in WebUI must consist of only ASCII characters. 84 // All function names in WebUI must consist of only ASCII characters.
85 // These functions will crash if JavaScript is not currently allowed. 85 // These functions will crash if JavaScript is not currently allowed.
86 template <typename... Values> 86 template <typename... Values>
87 void CallJavascriptFunction(const std::string& function_name, 87 void CallJavascriptFunction(const std::string& function_name,
88 const Values&... values) { 88 const Values&... values) {
89 CHECK(IsJavascriptAllowed()) << "Cannot CallJavascriptFunction before " 89 CHECK(IsJavascriptAllowed()) << "Cannot CallJavascriptFunction before "
90 "explicitly allowing JavaScript."; 90 "explicitly allowing JavaScript.";
91 web_ui()->CallJavascriptFunction(function_name, values...); 91 web_ui()->CallJavascriptFunctionUnsafe(function_name, values...);
Charlie Reis 2016/05/23 20:26:00 Maybe put a comment here saying that the check abo
tommycli 2016/06/03 17:52:44 Done.
92 } 92 }
93 93
94 // Returns the attached WebUI for this handler. 94 // Returns the attached WebUI for this handler.
95 WebUI* web_ui() const { return web_ui_; } 95 WebUI* web_ui() const { return web_ui_; }
96 96
97 // Sets the attached WebUI - exposed to subclasses for testing purposes. 97 // Sets the attached WebUI - exposed to subclasses for testing purposes.
98 void set_web_ui(WebUI* web_ui) { web_ui_ = web_ui; } 98 void set_web_ui(WebUI* web_ui) { web_ui_ = web_ui; }
99 99
100 private: 100 private:
101 // Provide external classes access to web_ui(), set_web_ui(), and 101 // Provide external classes access to web_ui(), set_web_ui(), and
102 // RenderViewReused. 102 // RenderViewReused.
103 friend class WebUIImpl; 103 friend class WebUIImpl;
104 friend class ::WebUIBrowserTest; 104 friend class ::WebUIBrowserTest;
105 105
106 // 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).
107 void RenderViewReused(); 107 void RenderViewReused();
108 108
109 // TODO(dbeam): disallow JavaScript when a renderer process crashes. 109 // TODO(dbeam): disallow JavaScript when a renderer process crashes.
110 // http://crbug.com/610450 110 // http://crbug.com/610450
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

Powered by Google App Engine
This is Rietveld 408576698