File: web_launch_service_impl.cc

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (82 lines) | stat: -rw-r--r-- 3,379 bytes parent folder | download | duplicates (5)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/modules/launch/web_launch_service_impl.h"

#include "base/time/time.h"
#include "third_party/blink/public/mojom/file_system_access/file_system_access_directory_handle.mojom-blink.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/modules/launch/dom_window_launch_queue.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"

namespace blink {
// static
const char WebLaunchServiceImpl::kSupplementName[] = "WebLaunchServiceImpl";

// static
WebLaunchServiceImpl* WebLaunchServiceImpl::From(LocalDOMWindow& window) {
  return Supplement<LocalDOMWindow>::From<WebLaunchServiceImpl>(window);
}

// static
void WebLaunchServiceImpl::BindReceiver(
    LocalFrame* frame,
    mojo::PendingAssociatedReceiver<mojom::blink::WebLaunchService> receiver) {
  DCHECK(frame);
  auto* service = WebLaunchServiceImpl::From(*frame->DomWindow());
  if (!service) {
    service = MakeGarbageCollected<WebLaunchServiceImpl>(
        base::PassKey<WebLaunchServiceImpl>(), *frame->DomWindow());
    Supplement<LocalDOMWindow>::ProvideTo(*frame->DomWindow(), service);
  }
  service->Bind(std::move(receiver));
}

WebLaunchServiceImpl::WebLaunchServiceImpl(base::PassKey<WebLaunchServiceImpl>,
                                           LocalDOMWindow& window)
    : Supplement<LocalDOMWindow>(window), receiver_(this, &window) {}

WebLaunchServiceImpl::~WebLaunchServiceImpl() = default;

void WebLaunchServiceImpl::Bind(
    mojo::PendingAssociatedReceiver<mojom::blink::WebLaunchService> receiver) {
  // This interface only has a single method with no reply. The calling side
  // doesn't keep this around, so it is re-requested on demand every time;
  // however, there should never be multiple callers bound at a time.
  receiver_.reset();
  receiver_.Bind(std::move(receiver), GetSupplementable()->GetTaskRunner(
                                          TaskType::kMiscPlatformAPI));
}

void WebLaunchServiceImpl::Trace(Visitor* visitor) const {
  visitor->Trace(receiver_);
  Supplement<LocalDOMWindow>::Trace(visitor);
}

void WebLaunchServiceImpl::SetLaunchFiles(
    WTF::Vector<mojom::blink::FileSystemAccessEntryPtr> entries) {
  HeapVector<Member<FileSystemHandle>> files;
  for (auto& entry : entries) {
    files.push_back(FileSystemHandle::CreateFromMojoEntry(
        std::move(entry), GetSupplementable()->GetExecutionContext()));
  }

  UseCounter::Count(GetSupplementable()->GetExecutionContext(),
                    WebFeature::kFileHandlingLaunch);
  DOMWindowLaunchQueue::UpdateLaunchFiles(GetSupplementable(),
                                          std::move(files));
}

void WebLaunchServiceImpl::EnqueueLaunchParams(
    const KURL& launch_url,
    base::TimeTicks time_navigation_started_in_browser,
    bool navigation_started) {
  DOMWindowLaunchQueue::EnqueueLaunchParams(GetSupplementable(), launch_url,
                                            time_navigation_started_in_browser,
                                            navigation_started);
}

}  // namespace blink