OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef HEADLESS_PUBLIC_WEB_FRAME_H_ | |
6 #define HEADLESS_PUBLIC_WEB_FRAME_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/values.h" | |
10 #include "headless/public/headless_export.h" | |
11 | |
12 namespace headless { | |
13 | |
14 class WebDocument; | |
15 | |
16 class HEADLESS_EXPORT WebFrame { | |
Sami
2015/12/01 14:03:58
nit: Add a description and say that this also belo
altimin
2015/12/01 15:17:29
Done.
| |
17 public: | |
18 virtual ~WebFrame() {} | |
19 | |
20 using ScriptExecutionCallback = | |
21 base::Callback<void(const std::vector<scoped_ptr<base::Value>>&)>; | |
22 | |
23 // Schedule given script for execution. | |
Sami
2015/12/01 14:03:58
Maybe: Execute the given script, ignoring its retu
altimin
2015/12/01 15:17:29
There are two different methods in underlying Blin
| |
24 virtual void ExecuteScript(const std::string& source_code) = 0; | |
25 | |
26 // Execute given script and return value. | |
Sami
2015/12/01 14:03:58
s/value/its result/.
altimin
2015/12/01 15:17:29
Done.
| |
27 // Returned value will be converted to json (base::Value). | |
28 // Special effects to bear in mind: | |
29 // - Boolean will be converted to base::FundamentalValue (no surprises here). | |
30 // - Number will be converted to base::FundamentalValue. | |
31 // - Array will be converted to base::ListValue. | |
32 // Note: All non-numerical properties will be omitted | |
33 // (e.g. "array = [1, 2, 3]; array['property'] = 'value'; return array" | |
34 // will return [1, 2, 3]). | |
35 // - Object will be converted to base::DictionaryValue | |
36 // Note: Only string can be key in base::DictionaryValue, so all non-string | |
37 // properties will be omitted | |
38 // (e.g. "obj = Object(); obj['key'] = 'value'; obj[0] = 42;" will return | |
39 // {"key":"value"}). | |
40 virtual void ExecuteScriptAndReturnValue( | |
Sami
2015/12/01 14:03:58
Since this is all running on the renderer main thr
altimin
2015/12/01 15:17:29
No, we can't. Underlying API returns a callback so
Sami
2015/12/01 17:47:33
Are you sure? This one looks synchronous:
https:/
altimin
2015/12/01 18:42:46
But it is deprecated and async version should be u
Sami
2015/12/01 18:53:53
Ah, I missed that. This is fine then.
| |
41 const std::string& source_code, | |
42 const ScriptExecutionCallback& callback) = 0; | |
43 }; | |
44 | |
45 } // namespace headless | |
46 | |
47 #endif // HEADLESS_PUBLIC_WEB_FRAME_H_ | |
OLD | NEW |