File: tab_strip_api.mojom

package info (click to toggle)
chromium 140.0.7339.185-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,193,740 kB
  • sloc: cpp: 35,093,945; ansic: 7,161,670; javascript: 4,199,694; python: 1,441,797; asm: 949,904; xml: 747,515; pascal: 187,748; perl: 88,691; sh: 88,248; objc: 79,953; sql: 52,714; cs: 44,599; fortran: 24,137; makefile: 22,114; tcl: 15,277; php: 13,980; yacc: 9,000; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (91 lines) | stat: -rw-r--r-- 3,600 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
83
84
85
86
87
88
89
90
91
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module tabs_api.mojom;

import "chrome/browser/ui/tabs/tab_strip_api/tab_strip_api_data_model.mojom";
import "chrome/browser/ui/tabs/tab_strip_api/tab_strip_api_events.mojom";
import "chrome/browser/ui/tabs/tab_strip_api/tab_strip_api_types.mojom";
import "mojo/public/mojom/base/empty.mojom";
import "mojo/public/mojom/base/error.mojom";
import "url/mojom/url.mojom";

// A snapshot of the current tabs in the tab strip.
struct TabsSnapshot {
  TabCollectionContainer tab_strip;
  // Updates to tabs would be sent through this update stream. Clients may
  // subscribe to this stream to receive update events.
  // The interface is associated with the interface used to retrieve this
  // stream. This means that the ordering of the message between the remote
  // and the observation stream is preserved.
  pending_associated_receiver<TabsObserver> stream;
};

// The TabStripService is an object that lives alongside the
// TabstripModel. It acts as the bridge between the model and any UI Dialog
// or client.
interface TabStripService {
  // Gets the current state of the tab tree. This also returns a stream of
  // future update events. Clients can implement the |TabsObserver| interface
  // and receive all future updates from the snapshot. Note that all messages
  // since the snapshot will be present in the stream, even if the client
  // does not immediately register to the update stream.
  [Sync]
  GetTabs() => result<TabsSnapshot, mojo_base.mojom.Error>;

  // Get a single tab.
  [Sync]
  GetTab(NodeId id) => result<Tab, mojo_base.mojom.Error>;

  // Creates a new tab.
  // Position specifies the location of the Tab after creation. If position is
  // empty, the new tab will be appended to the end of the Tabstrip.
  // Url specifies what is loaded in the Tab. If url is empty, then the new
  // tab-page is loaded instead.
  // The newly created tab is immediately activated.
  [Sync]
  CreateTabAt(Position? pos, url.mojom.Url? url)
      => result<Tab, mojo_base.mojom.Error>;

  // Closes a list of tabs. The accepted tab types are content and collection
  // types. All the provided IDs must exist. If an ID could not be found, the
  // invocation will be rejected with a |Code.kNotFound| error.
  // If the method call succeeds, all of the tabs will have been closed.
  [Sync]
  CloseTabs(array<NodeId> id)
      => result<mojo_base.mojom.Empty, mojo_base.mojom.Error>;

  // Activates a tab. The only accepted id type for this method are |kContent|
  // ids.
  [Sync]
  ActivateTab(NodeId id)
      => result<mojo_base.mojom.Empty, mojo_base.mojom.Error>;

  // Moves a tab identified by id to a specified position.
  [Sync]
  MoveTab(NodeId id, Position position)
      => result<mojo_base.mojom.Empty, mojo_base.mojom.Error>;
};

// TabsObserver is an interface a client can implement to receive events
// about changes to the tab strip.
interface TabsObserver {
  // When new tabs have been created on the tab strip.
  OnTabsCreated(OnTabsCreatedEvent event);

  // When tabs have been closed on the tab strip.
  OnTabsClosed(OnTabsClosedEvent event);

  // When a tab has been moved.
  OnTabMoved(OnTabMovedEvent event);

  // When tab data has been updated.
  OnTabDataChanged(OnTabDataChangedEvent tab);

  // When a new tab group has been created.
  OnTabGroupCreated(OnTabGroupCreatedEvent event);

  // When a tab group's visuals have been changed.
  OnTabGroupVisualsChanged(OnTabGroupVisualsChangedEvent event);
};