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

Side by Side 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 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_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_WEB_UI_H_
6 #define CONTENT_PUBLIC_BROWSER_WEB_UI_H_ 6 #define CONTENT_PUBLIC_BROWSER_WEB_UI_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 typedef base::Callback<void(const base::ListValue*)> MessageCallback; 84 typedef base::Callback<void(const base::ListValue*)> MessageCallback;
85 virtual void RegisterMessageCallback(const std::string& message, 85 virtual void RegisterMessageCallback(const std::string& message,
86 const MessageCallback& callback) = 0; 86 const MessageCallback& callback) = 0;
87 87
88 // This is only needed if an embedder overrides handling of a WebUIMessage and 88 // This is only needed if an embedder overrides handling of a WebUIMessage and
89 // then later wants to undo that, or to route it to a different WebUI object. 89 // then later wants to undo that, or to route it to a different WebUI object.
90 virtual void ProcessWebUIMessage(const GURL& source_url, 90 virtual void ProcessWebUIMessage(const GURL& source_url,
91 const std::string& message, 91 const std::string& message,
92 const base::ListValue& args) = 0; 92 const base::ListValue& args) = 0;
93 93
94 // Returns true if this WebUI can currently call JavaScript.
95 virtual bool CanCallJavascript() = 0;
96
97 // Calling these functions directly is discouraged. It's generally preferred
98 // to call WebUIMessageHandler::CallJavascriptFunction, as that has
99 // lifecycle controls to prevent calling JavaScript before the page is ready.
100 //
94 // Call a Javascript function by sending its name and arguments down to 101 // 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 102 // 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 103 // of the call, and should be thought of more like sending a message to
97 // the page. 104 // the page.
105 //
98 // All function names in WebUI must consist of only ASCII characters. 106 // All function names in WebUI must consist of only ASCII characters.
99 // There are variants for calls with more arguments. 107 // There are variants for calls with more arguments.
100 virtual void CallJavascriptFunction(const std::string& function_name) = 0; 108 virtual void CallJavascriptFunction(const std::string& function_name) = 0;
101 virtual void CallJavascriptFunction(const std::string& function_name, 109 virtual void CallJavascriptFunction(const std::string& function_name,
102 const base::Value& arg) = 0; 110 const base::Value& arg) = 0;
103 virtual void CallJavascriptFunction(const std::string& function_name, 111 virtual void CallJavascriptFunction(const std::string& function_name,
104 const base::Value& arg1, 112 const base::Value& arg1,
105 const base::Value& arg2) = 0; 113 const base::Value& arg2) = 0;
106 virtual void CallJavascriptFunction(const std::string& function_name, 114 virtual void CallJavascriptFunction(const std::string& function_name,
107 const base::Value& arg1, 115 const base::Value& arg1,
108 const base::Value& arg2, 116 const base::Value& arg2,
109 const base::Value& arg3) = 0; 117 const base::Value& arg3) = 0;
110 virtual void CallJavascriptFunction(const std::string& function_name, 118 virtual void CallJavascriptFunction(const std::string& function_name,
111 const base::Value& arg1, 119 const base::Value& arg1,
112 const base::Value& arg2, 120 const base::Value& arg2,
113 const base::Value& arg3, 121 const base::Value& arg3,
114 const base::Value& arg4) = 0; 122 const base::Value& arg4) = 0;
115 virtual void CallJavascriptFunction( 123 virtual void CallJavascriptFunction(
116 const std::string& function_name, 124 const std::string& function_name,
117 const std::vector<const base::Value*>& args) = 0; 125 const std::vector<const base::Value*>& args) = 0;
118 }; 126 };
119 127
120 } // namespace content 128 } // namespace content
121 129
122 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_H_ 130 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698