Chromium Code Reviews| Index: headless/public/web_frame.h |
| diff --git a/headless/public/web_frame.h b/headless/public/web_frame.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..59cc88cb61fa00b12f58d6fce87b01a5ce044644 |
| --- /dev/null |
| +++ b/headless/public/web_frame.h |
| @@ -0,0 +1,47 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef HEADLESS_PUBLIC_WEB_FRAME_H_ |
| +#define HEADLESS_PUBLIC_WEB_FRAME_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/values.h" |
| +#include "headless/public/headless_export.h" |
| + |
| +namespace headless { |
| + |
| +class WebDocument; |
| + |
| +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.
|
| + public: |
| + virtual ~WebFrame() {} |
| + |
| + using ScriptExecutionCallback = |
| + base::Callback<void(const std::vector<scoped_ptr<base::Value>>&)>; |
| + |
| + // 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
|
| + virtual void ExecuteScript(const std::string& source_code) = 0; |
| + |
| + // 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.
|
| + // Returned value will be converted to json (base::Value). |
| + // Special effects to bear in mind: |
| + // - Boolean will be converted to base::FundamentalValue (no surprises here). |
| + // - Number will be converted to base::FundamentalValue. |
| + // - Array will be converted to base::ListValue. |
| + // Note: All non-numerical properties will be omitted |
| + // (e.g. "array = [1, 2, 3]; array['property'] = 'value'; return array" |
| + // will return [1, 2, 3]). |
| + // - Object will be converted to base::DictionaryValue |
| + // Note: Only string can be key in base::DictionaryValue, so all non-string |
| + // properties will be omitted |
| + // (e.g. "obj = Object(); obj['key'] = 'value'; obj[0] = 42;" will return |
| + // {"key":"value"}). |
| + 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.
|
| + const std::string& source_code, |
| + const ScriptExecutionCallback& callback) = 0; |
| +}; |
| + |
| +} // namespace headless |
| + |
| +#endif // HEADLESS_PUBLIC_WEB_FRAME_H_ |