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

Unified Diff: content/public/browser/web_ui.h

Issue 1896463003: WebUI: Add JavaScript lifecycle-control to WebUIMessageHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/public/browser/web_ui.h
diff --git a/content/public/browser/web_ui.h b/content/public/browser/web_ui.h
index 663afd1fc45d1c25c287bc63f8e3ab4db1cab345..8d45e28b8bdc64ae842bfa6d46d9979b0fab6e37 100644
--- a/content/public/browser/web_ui.h
+++ b/content/public/browser/web_ui.h
@@ -91,10 +91,18 @@ class CONTENT_EXPORT WebUI {
const std::string& message,
const base::ListValue& args) = 0;
+ // Returns true if this WebUI can currently call JavaScript.
+ virtual bool CanCallJavascript() = 0;
+
+ // Calling these functions directly is discouraged. It's generally preferred
+ // to call WebUIMessageHandler::CallJavascriptFunction, as that has
+ // lifecycle controls to prevent calling JavaScript before the page is ready.
+ //
// Call a Javascript function by sending its name and arguments down to
// the renderer. This is asynchronous; there's no way to get the result
// of the call, and should be thought of more like sending a message to
// the page.
+ //
// All function names in WebUI must consist of only ASCII characters.
// There are variants for calls with more arguments.
virtual void CallJavascriptFunction(const std::string& function_name) = 0;

Powered by Google App Engine
This is Rietveld 408576698