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_CHROME_AUTOMATION_EXTENSION_H_
6#define CHROME_TEST_CHROMEDRIVER_CHROME_AUTOMATION_EXTENSION_H_
7
8#include <string>
9
10#include "base/basictypes.h"
11#include "base/memory/scoped_ptr.h"
12
13namespace base {
14class DictionaryValue;
15}
16
17class Status;
18class WebView;
19
20// Automates Chrome through the extension APIs.
21class AutomationExtension {
22 public:
23  explicit AutomationExtension(scoped_ptr<WebView> web_view);
24  ~AutomationExtension();
25
26  // Captures the visible part of the current tab as a base64-encoded PNG.
27  // Returns |kForbidden| for security restricted pages.
28  Status CaptureScreenshot(std::string* screenshot);
29
30  // Launches an app with the specified id.
31  Status LaunchApp(std::string id);
32
33  // Gets the position of the current window.
34  Status GetWindowPosition(int* x, int* y);
35
36  // Sets the position of the current window.
37  Status SetWindowPosition(int x, int y);
38
39  // Gets the size of the current window.
40  Status GetWindowSize(int* width, int* height);
41
42  // Sets the size of the current window.
43  Status SetWindowSize(int width, int height);
44
45  // Maximizes the current window.
46  Status MaximizeWindow();
47
48 private:
49  Status GetWindowInfo(int* x, int* y, int* width, int* height);
50  Status UpdateWindow(const base::DictionaryValue& update_info);
51
52  scoped_ptr<WebView> web_view_;
53
54  DISALLOW_COPY_AND_ASSIGN(AutomationExtension);
55};
56
57#endif  // CHROME_TEST_CHROMEDRIVER_CHROME_AUTOMATION_EXTENSION_H_
58