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 "headless/public/headless_export.h" |
| 10 #include "base/values.h" |
| 11 |
| 12 namespace headless { |
| 13 |
| 14 class WebDocument; |
| 15 |
| 16 class HEADLESS_EXPORT WebFrame { |
| 17 public: |
| 18 virtual ~WebFrame() {} |
| 19 |
| 20 virtual WebDocument document() = 0; |
| 21 |
| 22 using ScriptExecutionCallback = |
| 23 base::Callback<void(const std::vector<scoped_ptr<base::Value>>&)>; |
| 24 |
| 25 // Schedule given script for execution. |
| 26 virtual void ExecuteScript( |
| 27 const std::string& source_code) = 0; |
| 28 |
| 29 // Execute given script and return value. |
| 30 // Returned value will be converted to json (base::Value). |
| 31 // Special effects to bear in mind: |
| 32 // - Boolean will be converted to base::FundamentalValue (no surprises here). |
| 33 // - Number will be converted to base::FundamentalValue. |
| 34 // - Array will be converted to base::ListValue. |
| 35 // Note: All non-numerical properties will be omitted |
| 36 // (e.g. "array = [1, 2, 3]; array['property'] = 'value'; return array" |
| 37 // will return [1, 2, 3]). |
| 38 // - Object will be converted to base::DictionaryValue |
| 39 // Note: Only string can be key in base::DictionaryValue, so all non-string |
| 40 // properties will be omitted |
| 41 // (e.g. "obj = Object(); obj['key'] = 'value'; obj[0] = 42;" will return |
| 42 // {"key":"value"}). |
| 43 virtual void ExecuteScriptAndReturnValue( |
| 44 const std::string& source_code, |
| 45 const ScriptExecutionCallback& callback) = 0; |
| 46 }; |
| 47 |
| 48 } // namespace headless |
| 49 |
| 50 #endif // HEADLESS_PUBLIC_WEB_FRAME_H_ |
OLD | NEW |