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_CHROME_DESKTOP_IMPL_H_
6#define CHROME_TEST_CHROMEDRIVER_CHROME_CHROME_DESKTOP_IMPL_H_
7
8#include <string>
9
10#include "base/command_line.h"
11#include "base/compiler_specific.h"
12#include "base/files/scoped_temp_dir.h"
13#include "base/memory/scoped_ptr.h"
14#include "base/process/process.h"
15#include "chrome/test/chromedriver/chrome/chrome_impl.h"
16
17namespace base {
18class TimeDelta;
19}
20
21class AutomationExtension;
22class DevToolsClient;
23class DevToolsHttpClient;
24class Status;
25class WebView;
26
27class ChromeDesktopImpl : public ChromeImpl {
28 public:
29  ChromeDesktopImpl(
30      scoped_ptr<DevToolsHttpClient> http_client,
31      scoped_ptr<DevToolsClient> websocket_client,
32      ScopedVector<DevToolsEventListener>& devtools_event_listeners,
33      scoped_ptr<PortReservation> port_reservation,
34      base::ProcessHandle process,
35      const base::CommandLine& command,
36      base::ScopedTempDir* user_data_dir,
37      base::ScopedTempDir* extension_dir);
38  virtual ~ChromeDesktopImpl();
39
40  // Waits for a page with the given URL to appear and finish loading.
41  // Returns an error if the timeout is exceeded.
42  Status WaitForPageToLoad(const std::string& url,
43                           const base::TimeDelta& timeout,
44                           scoped_ptr<WebView>* web_view);
45
46  // Gets the installed automation extension.
47  Status GetAutomationExtension(AutomationExtension** extension);
48
49  // Overridden from Chrome:
50  virtual ChromeDesktopImpl* GetAsDesktop() OVERRIDE;
51  virtual std::string GetOperatingSystemName() OVERRIDE;
52
53  // Overridden from ChromeImpl:
54  virtual bool IsMobileEmulationEnabled() const OVERRIDE;
55  virtual Status QuitImpl() OVERRIDE;
56
57  const base::CommandLine& command() const;
58
59 private:
60  base::ProcessHandle process_;
61  base::CommandLine command_;
62  base::ScopedTempDir user_data_dir_;
63  base::ScopedTempDir extension_dir_;
64
65  // Lazily initialized, may be null.
66  scoped_ptr<AutomationExtension> automation_extension_;
67};
68
69#endif  // CHROME_TEST_CHROMEDRIVER_CHROME_CHROME_DESKTOP_IMPL_H_
70