Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: headless/app/headless_shell.h

Issue 2687083002: Headless: make URLRequestDispatcher aware of navigations (Closed)
Patch Set: Address nits Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « headless/BUILD.gn ('k') | headless/app/headless_shell.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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 #include "base/memory/weak_ptr.h"
6 #include "headless/app/shell_navigation_request.h"
7 #include "headless/public/devtools/domains/emulation.h"
8 #include "headless/public/devtools/domains/inspector.h"
9 #include "headless/public/devtools/domains/page.h"
10 #include "headless/public/devtools/domains/runtime.h"
11 #include "headless/public/headless_browser.h"
12 #include "headless/public/headless_devtools_client.h"
13 #include "headless/public/headless_web_contents.h"
14 #include "headless/public/util/deterministic_dispatcher.h"
15 #include "net/base/file_stream.h"
16
17 namespace headless {
18
19 // An application which implements a simple headless browser.
20 class HeadlessShell : public HeadlessWebContents::Observer,
21 emulation::ExperimentalObserver,
22 inspector::ExperimentalObserver,
23 page::ExperimentalObserver {
24 public:
25 HeadlessShell();
26 ~HeadlessShell() override;
27
28 // HeadlessWebContents::Observer implementation:
29 void DevToolsTargetReady() override;
30 void OnTargetCrashed(const inspector::TargetCrashedParams& params) override;
31
32 // emulation::Observer implementation:
33 void OnVirtualTimeBudgetExpired(
34 const emulation::VirtualTimeBudgetExpiredParams& params) override;
35
36 // page::Observer implementation:
37 void OnLoadEventFired(const page::LoadEventFiredParams& params) override;
38 void OnNavigationRequested(
39 const headless::page::NavigationRequestedParams& params) override;
40
41 void OnStart(HeadlessBrowser* browser);
42 void Shutdown();
43
44 void FetchTimeout();
45
46 void PollReadyState();
47
48 void OnReadyState(std::unique_ptr<runtime::EvaluateResult> result);
49
50 void OnPageReady();
51
52 void FetchDom();
53
54 void OnDomFetched(std::unique_ptr<runtime::EvaluateResult> result);
55
56 void InputExpression();
57
58 void OnExpressionResult(std::unique_ptr<runtime::EvaluateResult> result);
59
60 void CaptureScreenshot();
61
62 void OnScreenshotCaptured(
63 std::unique_ptr<page::CaptureScreenshotResult> result);
64
65 void OnScreenshotFileOpened(
66 std::unique_ptr<page::CaptureScreenshotResult> result,
67 const base::FilePath file_name,
68 const int open_result);
69
70 void OnScreenshotFileWritten(const base::FilePath file_name,
71 const int length,
72 const int write_result);
73
74 void OnScreenshotFileClosed(const int close_result);
75
76 bool RemoteDebuggingEnabled() const;
77
78 HeadlessDevToolsClient* devtools_client() const {
79 return devtools_client_.get();
80 }
81
82 private:
83 GURL url_;
84 HeadlessBrowser* browser_; // Not owned.
85 std::unique_ptr<HeadlessDevToolsClient> devtools_client_;
86 HeadlessWebContents* web_contents_;
87 bool processed_page_ready_;
88 std::unique_ptr<net::FileStream> screenshot_file_stream_;
89 HeadlessBrowserContext* browser_context_;
90 std::unique_ptr<DeterministicDispatcher> deterministic_dispatcher_;
91 base::WeakPtrFactory<HeadlessShell> weak_factory_;
92
93 DISALLOW_COPY_AND_ASSIGN(HeadlessShell);
94 };
95
96 } // namespace headless
OLDNEW
« no previous file with comments | « headless/BUILD.gn ('k') | headless/app/headless_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698