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