OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013 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 CHROME_TEST_CHROMEDRIVER_WEB_VIEW_H_ | |
6 #define CHROME_TEST_CHROMEDRIVER_WEB_VIEW_H_ | |
7 | |
8 #include <list> | |
9 #include <string> | |
10 | |
11 #include "base/memory/scoped_ptr.h" | |
12 | |
13 namespace base { | |
14 class ListValue; | |
15 class Value; | |
16 } | |
17 | |
18 class JavaScriptDialogManager; | |
19 struct KeyEvent; | |
20 struct MouseEvent; | |
21 class Status; | |
22 | |
23 class WebView { | |
24 public: | |
25 virtual ~WebView() {} | |
26 | |
27 // Return the id for this WebView. | |
28 virtual std::string GetId() = 0; | |
29 | |
30 // Make DevToolsCient connect to DevTools if it is disconnected. | |
31 virtual Status ConnectIfNecessary() = 0; | |
32 | |
33 // Close the WebView itself. | |
34 virtual Status Close() = 0; | |
35 | |
36 // Load a given URL in the main frame. | |
37 virtual Status Load(const std::string& url) = 0; | |
38 | |
39 // Reload the current page. | |
40 virtual Status Reload() = 0; | |
41 | |
42 // Evaluates a JavaScript expression in a specified frame and returns | |
43 // the result. |frame| is a frame ID or an empty string for the main frame. | |
44 // If the expression evaluates to a element, it will be bound to a unique ID | |
45 // (per frame) and the ID will be returned. | |
46 virtual Status EvaluateScript(const std::string& frame, | |
47 const std::string& expression, | |
48 scoped_ptr<base::Value>* result) = 0; | |
49 | |
50 // Calls a JavaScript function in a specified frame with the given args and | |
51 // returns the result. |frame| is a frame ID or an empty string for the main | |
52 // frame. |args| may contain IDs that refer to previously returned elements. | |
53 // These will be translated back to their referred objects before invoking the | |
54 // function. | |
55 virtual Status CallFunction(const std::string& frame, | |
56 const std::string& function, | |
57 const base::ListValue& args, | |
58 scoped_ptr<base::Value>* result) = 0; | |
59 | |
60 // Gets the frame ID for a frame element returned by invoking the given | |
61 // JavaScript function. |frame| is a frame ID or an empty string for the main | |
62 // frame. | |
63 virtual Status GetFrameByFunction(const std::string& frame, | |
64 const std::string& function, | |
65 const base::ListValue& args, | |
66 std::string* out_frame) = 0; | |
67 | |
68 // Dispatch a sequence of mouse events. | |
69 virtual Status DispatchMouseEvents(const std::list<MouseEvent>& events) = 0; | |
70 | |
71 // Dispatch a sequence of key events. | |
72 virtual Status DispatchKeyEvents(const std::list<KeyEvent>& events) = 0; | |
73 | |
74 // Return all the cookies visible to the current page. | |
75 virtual Status GetCookies(scoped_ptr<base::ListValue>* cookies) = 0; | |
76 | |
77 // Delete the cookie with the given name. | |
78 virtual Status DeleteCookie(const std::string& name, | |
79 const std::string& url) = 0; | |
80 | |
81 // Waits until all pending navigations have completed in the given frame. | |
82 // If |frame_id| is "", waits for navigations on the main frame. | |
83 virtual Status WaitForPendingNavigations(const std::string& frame_id) = 0; | |
84 | |
85 // Returns whether the frame is pending navigation. | |
86 virtual Status IsPendingNavigation( | |
87 const std::string& frame_id, bool* is_pending) = 0; | |
88 | |
89 // Returns the frame id for the main frame. | |
90 virtual Status GetMainFrame(std::string* out_frame) = 0; | |
91 | |
92 // Returns the JavaScriptDialogManager. Never null. | |
93 virtual JavaScriptDialogManager* GetJavaScriptDialogManager() = 0; | |
94 | |
95 // Captures the visible portions of the web view as a base64-encoded PNG. | |
96 virtual Status CaptureScreenshot(std::string* screenshot) = 0; | |
97 }; | |
98 | |
99 #endif // CHROME_TEST_CHROMEDRIVER_WEB_VIEW_H_ | |
OLD | NEW |