File: window_info.h

package info (click to toggle)
chromium 139.0.7258.127-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,122,156 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (118 lines) | stat: -rw-r--r-- 4,268 bytes parent folder | download | duplicates (6)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_APP_RESTORE_WINDOW_INFO_H_
#define COMPONENTS_APP_RESTORE_WINDOW_INFO_H_

#include <optional>

#include "base/memory/raw_ptr.h"
#include "base/uuid.h"
#include "chromeos/ui/base/window_state_type.h"
#include "components/tab_groups/tab_group_info.h"
#include "ui/aura/window.h"
#include "ui/base/mojom/window_show_state.mojom-forward.h"
#include "ui/base/ui_base_types.h"
#include "ui/gfx/geometry/rect.h"
#include "url/gurl.h"

namespace app_restore {

// Browser specific info. It is used for creating new browsers for saved desks,
// or displaying browser info in the pine dialog.
struct COMPONENT_EXPORT(APP_RESTORE) BrowserExtraInfo {
  BrowserExtraInfo();
  BrowserExtraInfo(BrowserExtraInfo&&);
  BrowserExtraInfo(const BrowserExtraInfo&);
  BrowserExtraInfo& operator=(BrowserExtraInfo&&);
  BrowserExtraInfo& operator=(const BrowserExtraInfo&);
  ~BrowserExtraInfo();

  bool operator==(const BrowserExtraInfo& other) const;

  std::vector<GURL> urls;
  std::optional<int32_t> active_tab_index;
  std::optional<int32_t> first_non_pinned_tab_index;
  // True if the browser was `Browser::TYPE_APP` or `Browser::TYPE_APP_POPUP`.
  // (PWA or SWA).
  std::optional<bool> app_type_browser;
  std::optional<std::string> app_name;
  // Represents tab groups associated with this browser instance if there are
  // any. This is only used in Desks Storage, tab groups in full restore are
  // persisted by sessions. This field is not converted to base::Value in base
  // value conversions.
  std::vector<tab_groups::TabGroupInfo> tab_group_infos;
  // Lacros only, the ID of the lacros profile that this browser uses.
  // TODO(crbug.com/381216377): remove this once usages of this member have
  // been removed from outside the //components/app_restore.
  std::optional<uint64_t> lacros_profile_id;
};

// This struct is the parameter for the interface SaveWindowInfo, to save the
// window information.
struct COMPONENT_EXPORT(APP_RESTORE) WindowInfo {
 public:
  // This struct is the ARC specific window info.
  struct ArcExtraInfo {
    bool operator==(const ArcExtraInfo& other) const = default;
    std::optional<gfx::Size> maximum_size;
    std::optional<gfx::Size> minimum_size;
    std::optional<gfx::Rect> bounds_in_root;
  };

  WindowInfo();
  WindowInfo(WindowInfo&&);
  WindowInfo(const WindowInfo&);
  WindowInfo& operator=(WindowInfo&&);
  WindowInfo& operator=(const WindowInfo&);
  ~WindowInfo();

  bool operator==(const WindowInfo& other) const;

  raw_ptr<aura::Window, DanglingUntriaged> window;

  // Index in MruWindowTracker to restore window stack. A lower index
  // indicates a more recently used window.
  std::optional<int32_t> activation_index;

  // Virtual desk id.
  std::optional<int32_t> desk_id;

  // The GUID of the virtual desk that this window was on.
  base::Uuid desk_guid;

  // Current bounds in screen in coordinates. If the window has restore bounds,
  // then this contains the restore bounds.
  std::optional<gfx::Rect> current_bounds;

  // Window state, minimized, maximized, inactive, etc.
  std::optional<chromeos::WindowStateType> window_state_type;

  // Show state of a window before it was minimized. Empty for non-minimized
  // windows.
  std::optional<ui::mojom::WindowShowState> pre_minimized_show_state_type;

  // The snap percentage of a window, if it is snapped. For instance a snap
  // percentage of 75 means the window takes up three quarters of the work area.
  // The primary axis is determined when restoring; if it is portrait, it will
  // be three quarters of the height.
  std::optional<uint32_t> snap_percentage;

  // Display id to launch an app.
  std::optional<int64_t> display_id;

  // The title of the app window. Used for saved desks in case one of the
  // windows in the template is uninstalled, we can show a nice error message.
  // Also used for the ARC ghost window.
  std::optional<std::u16string> app_title;

  // Extra window info of ARC app window.
  std::optional<ArcExtraInfo> arc_extra_info;

  std::string ToString() const;
};

}  // namespace app_restore

#endif  // COMPONENTS_APP_RESTORE_WINDOW_INFO_H_