File: session_service_commands.h

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (105 lines) | stat: -rw-r--r-- 4,786 bytes parent folder | download | duplicates (2)
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
// Copyright 2014 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.

#ifndef COMPONENTS_SESSIONS_CORE_SESSION_SERVICE_COMMANDS_H_
#define COMPONENTS_SESSIONS_CORE_SESSION_SERVICE_COMMANDS_H_

#include <map>
#include <memory>
#include <string>

#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/task/cancelable_task_tracker.h"
#include "components/sessions/core/base_session_service.h"
#include "components/sessions/core/session_types.h"
#include "components/sessions/core/sessions_export.h"
#include "ui/base/ui_base_types.h"

namespace sessions {

class SessionCommand;

// The following functions create sequentialized change commands which are
// used to reconstruct the current/previous session state.
// It is up to the caller to delete the returned SessionCommand* object.
SESSIONS_EXPORT std::unique_ptr<SessionCommand>
CreateSetSelectedTabInWindowCommand(const SessionID& window_id, int index);
SESSIONS_EXPORT std::unique_ptr<SessionCommand> CreateSetTabWindowCommand(
    const SessionID& window_id,
    const SessionID& tab_id);
SESSIONS_EXPORT std::unique_ptr<SessionCommand> CreateSetWindowBoundsCommand(
    const SessionID& window_id,
    const gfx::Rect& bounds,
    ui::WindowShowState show_state);
SESSIONS_EXPORT std::unique_ptr<SessionCommand>
CreateSetTabIndexInWindowCommand(const SessionID& tab_id, int new_index);
SESSIONS_EXPORT std::unique_ptr<SessionCommand> CreateTabClosedCommand(
    SessionID::id_type tab_id);
SESSIONS_EXPORT std::unique_ptr<SessionCommand> CreateWindowClosedCommand(
    SessionID::id_type tab_id);
SESSIONS_EXPORT std::unique_ptr<SessionCommand>
CreateSetSelectedNavigationIndexCommand(const SessionID& tab_id, int index);
SESSIONS_EXPORT std::unique_ptr<SessionCommand> CreateSetWindowTypeCommand(
    const SessionID& window_id,
    SessionWindow::WindowType type);
SESSIONS_EXPORT std::unique_ptr<SessionCommand> CreatePinnedStateCommand(
    const SessionID& tab_id,
    bool is_pinned);
SESSIONS_EXPORT std::unique_ptr<SessionCommand>
CreateSessionStorageAssociatedCommand(
    const SessionID& tab_id,
    const std::string& session_storage_persistent_id);
SESSIONS_EXPORT std::unique_ptr<SessionCommand> CreateSetActiveWindowCommand(
    const SessionID& window_id);
SESSIONS_EXPORT std::unique_ptr<SessionCommand>
CreateTabNavigationPathPrunedFromBackCommand(const SessionID& tab_id,
                                             int count);
SESSIONS_EXPORT std::unique_ptr<SessionCommand>
CreateTabNavigationPathPrunedFromFrontCommand(const SessionID& tab_id,
                                              int count);
SESSIONS_EXPORT std::unique_ptr<SessionCommand>
CreateUpdateTabNavigationCommand(
    const SessionID& tab_id,
    const sessions::SerializedNavigationEntry& navigation);
SESSIONS_EXPORT std::unique_ptr<SessionCommand>
CreateSetTabExtensionAppIDCommand(const SessionID& tab_id,
                                  const std::string& extension_id);
SESSIONS_EXPORT std::unique_ptr<SessionCommand>
CreateSetTabUserAgentOverrideCommand(const SessionID& tab_id,
                                     const std::string& user_agent_override);
SESSIONS_EXPORT std::unique_ptr<SessionCommand> CreateSetWindowAppNameCommand(
    const SessionID& window_id,
    const std::string& app_name);
SESSIONS_EXPORT std::unique_ptr<SessionCommand> CreateLastActiveTimeCommand(
    const SessionID& tab_id,
    base::TimeTicks last_active_time);

SESSIONS_EXPORT std::unique_ptr<SessionCommand> CreateSetWindowWorkspaceCommand(
    const SessionID& window_id,
    const std::string& workspace);

// Searches for a pending command using |base_session_service| that can be
// replaced with |command|. If one is found, pending command is removed, the
// command is added to the pending commands (taken ownership) and true is
// returned.
SESSIONS_EXPORT bool ReplacePendingCommand(
    BaseSessionService* base_session_service,
    std::unique_ptr<SessionCommand>* command);

// Returns true if provided |command| either closes a window or a tab.
SESSIONS_EXPORT bool IsClosingCommand(SessionCommand* command);

// Converts a list of commands into SessionWindows. On return any valid
// windows are added to |valid_windows|. |active_window_id| will be set with the
// id of the last active window, but it's only valid when this id corresponds
// to the id of one of the windows in |valid_windows|.
SESSIONS_EXPORT void RestoreSessionFromCommands(
    const std::vector<std::unique_ptr<SessionCommand>>& commands,
    std::vector<std::unique_ptr<SessionWindow>>* valid_windows,
    SessionID::id_type* active_window_id);

}  // namespace sessions

#endif  // COMPONENTS_SESSIONS_CORE_SESSION_SERVICE_COMMANDS_H_