File: app_restore_utils.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; 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,811; 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 (92 lines) | stat: -rw-r--r-- 3,859 bytes parent folder | download | duplicates (4)
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
// Copyright 2021 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_APP_RESTORE_UTILS_H_
#define COMPONENTS_APP_RESTORE_APP_RESTORE_UTILS_H_

#include "base/component_export.h"
#include "ui/views/widget/widget.h"

namespace app_restore {
class RestoreData;
struct WindowInfo;

// For ARC session id, 1 ~ 1000000000 is used as the window id for all new app
// launching. 1000000001 - INT_MAX is used as the session id for all restored
// app launching read from the full restore file.
//
// Assuming each day the new windows launched account is 1M, the above scope is
// enough for 3 years (1000 days). So there should be enough number to be
// assigned for ARC session ids.
constexpr int32_t kArcSessionIdOffsetForRestoredLaunching = 1000000000;

// If the ARC task is not created when the window is initialized, set the
// restore window id as -1, to add the ARC app window to the hidden container.
constexpr int32_t kParentToHiddenContainer = -1;

// Returns true if `window` is an ARC window. Otherwise, returns false.
bool IsArcWindow(aura::Window* window);

// Returns true if there is a window info for `restore_window_id` from desk
// templates or full restore, depending on which one is thought to be launching
// apps currently. Otherwise, returns false. This interface can't be used for
// ARC app windows.
COMPONENT_EXPORT(APP_RESTORE)
bool HasWindowInfo(int32_t restore_window_id);

// Applies properties from `window_info` to the given `property_handler`.
// This is called from `GetWindowInfo()` when window is
// created, or from the ArcReadHandler when a task is ready for a full
// restore window that has already been created.
// TODO(dandersson): Change the two arguments to references.
COMPONENT_EXPORT(APP_RESTORE)
void ApplyProperties(WindowInfo* window_info,
                     ui::PropertyHandler* property_handler);

// Modifies `out_params` based on the window info associated with
// `restore_window_id`.
COMPONENT_EXPORT(APP_RESTORE)
void ModifyWidgetParams(int32_t restore_window_id,
                        views::Widget::InitParams* out_params);

// Fetches the restore window id from the restore data for the given `app_id`.
// `app_id` should be a Chrome app id.
COMPONENT_EXPORT(APP_RESTORE)
int32_t FetchRestoreWindowId(const std::string& app_id);

// Generates the ARC session id (1,000,000,001 - INT_MAX) for restored ARC
// apps.
COMPONENT_EXPORT(APP_RESTORE) int32_t CreateArcSessionId();

// Sets `arc_session_id` for `window_id`. `arc session id` is assigned when ARC
// apps are restored.
COMPONENT_EXPORT(APP_RESTORE)
void SetArcSessionIdForWindowId(int32_t arc_session_id, int32_t window_id);

// Associates `desk_template_launch_id` with `arc_session_id`.
COMPONENT_EXPORT(APP_RESTORE)
void SetDeskTemplateLaunchIdForArcSessionId(int32_t arc_session_id,
                                            int32_t desk_template_launch_id);

// Returns the restore window id for the ARC app's `task_id`.
COMPONENT_EXPORT(APP_RESTORE)
int32_t GetArcRestoreWindowIdForTaskId(int32_t task_id);

// Returns the restore window id for the ARC app's `session_id`.
COMPONENT_EXPORT(APP_RESTORE)
int32_t GetArcRestoreWindowIdForSessionId(int32_t session_id);

// Remove the "_crx_" prefix from a given `app_name` to get the app id.
COMPONENT_EXPORT(APP_RESTORE)
std::string GetAppIdFromAppName(const std::string& app_name);

// Returns a tuple containing the window count, tab count, and total count, in
// that order. Note that tab count data is not saved for full restore, which
// relies on session restore to restore tabs.
COMPONENT_EXPORT(APP_RESTORE)
std::tuple<int, int, int> GetWindowAndTabCount(const RestoreData& restore_data);

}  // namespace app_restore

#endif  // COMPONENTS_APP_RESTORE_APP_RESTORE_UTILS_H_