summaryrefslogtreecommitdiff
path: root/chromium/headless/app/shell_navigation_request.cc
blob: 3c419bce8ec8800be86feec5ebd0ce7cc3a44b91 (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
// Copyright 2017 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.

#include "headless/app/shell_navigation_request.h"

#include "headless/app/headless_shell.h"

namespace headless {

ShellNavigationRequest::ShellNavigationRequest(
    base::WeakPtr<HeadlessShell> headless_shell,
    const page::NavigationRequestedParams& params)
    : headless_shell_(headless_shell),
      navigation_id_(params.GetNavigationId()) {}

ShellNavigationRequest::~ShellNavigationRequest() {}

void ShellNavigationRequest::StartProcessing(base::Closure done_callback) {
  if (!headless_shell_)
    return;

  // Allow the navigation to proceed.
  headless_shell_->devtools_client()
      ->GetPage()
      ->GetExperimental()
      ->ProcessNavigation(
          headless::page::ProcessNavigationParams::Builder()
              .SetNavigationId(navigation_id_)
              .SetResponse(headless::page::NavigationResponse::PROCEED)
              .Build(),
          base::Bind(&ShellNavigationRequest::ProcessNavigationResult,
                     done_callback));
}

// static
void ShellNavigationRequest::ProcessNavigationResult(
    base::Closure done_callback,
    std::unique_ptr<page::ProcessNavigationResult>) {
  done_callback.Run();
}

}  // namespace headless