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