OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_TEST_CHROMEDRIVER_CHROME_IMPL_H_ | |
6 #define CHROME_TEST_CHROMEDRIVER_CHROME_IMPL_H_ | |
7 | |
8 #include <list> | |
9 #include <map> | |
10 #include <string> | |
11 | |
12 #include "base/compiler_specific.h" | |
13 #include "base/memory/linked_ptr.h" | |
14 #include "base/memory/ref_counted.h" | |
15 #include "chrome/test/chromedriver/chrome.h" | |
16 #include "chrome/test/chromedriver/net/sync_websocket_factory.h" | |
17 #include "chrome/test/chromedriver/web_view_delegate.h" | |
18 | |
19 class JavaScriptDialogManager; | |
20 class Status; | |
21 class URLRequestContextGetter; | |
22 class WebView; | |
23 class WebViewImpl; | |
24 | |
25 class ChromeImpl : public Chrome, public WebViewDelegate { | |
26 public: | |
27 ChromeImpl(URLRequestContextGetter* context_getter, | |
28 int port, | |
29 const SyncWebSocketFactory& socket_factory); | |
30 virtual ~ChromeImpl(); | |
31 | |
32 // Overridden from Chrome: | |
33 virtual std::string GetVersion() OVERRIDE; | |
34 virtual Status GetWebViews(std::list<WebView*>* web_views) OVERRIDE; | |
35 virtual Status IsJavaScriptDialogOpen(bool* is_open) OVERRIDE; | |
36 virtual Status GetJavaScriptDialogMessage(std::string* message) OVERRIDE; | |
37 virtual Status HandleJavaScriptDialog( | |
38 bool accept, | |
39 const std::string& prompt_text) OVERRIDE; | |
40 | |
41 // Overridden from WebViewDelegate: | |
42 virtual void OnWebViewClose(WebView* web_view) OVERRIDE; | |
43 | |
44 protected: | |
45 Status Init(); | |
46 int GetPort() const; | |
47 | |
48 private: | |
49 typedef std::map<std::string, linked_ptr<WebViewImpl> > WebViewMap; | |
50 | |
51 Status GetDialogManagerForOpenDialog(JavaScriptDialogManager** manager); | |
52 Status ParseAndCheckVersion(const std::string& version); | |
53 | |
54 scoped_refptr<URLRequestContextGetter> context_getter_; | |
55 int port_; | |
56 SyncWebSocketFactory socket_factory_; | |
57 std::string version_; | |
58 int build_no_; | |
59 WebViewMap web_view_map_; | |
60 }; | |
61 | |
62 namespace internal { | |
63 | |
64 struct WebViewInfo { | |
65 enum Type { | |
66 kPage, | |
67 kOther | |
68 }; | |
69 | |
70 WebViewInfo(const std::string& id, | |
71 const std::string& debugger_url, | |
72 const std::string& url, | |
73 Type type); | |
74 | |
75 bool IsFrontend() const; | |
76 | |
77 std::string id; | |
78 std::string debugger_url; | |
79 std::string url; | |
80 Type type; | |
81 }; | |
82 | |
83 Status ParsePagesInfo(const std::string& data, | |
84 std::list<WebViewInfo>* info_list); | |
85 | |
86 Status ParseVersionInfo(const std::string& data, | |
87 std::string* version); | |
88 | |
89 } // namespace internal | |
90 | |
91 #endif // CHROME_TEST_CHROMEDRIVER_CHROME_IMPL_H_ | |
OLD | NEW |