1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SESSIONS_BASE_SESSION_SERVICE_COMMANDS_H_
6 #define CHROME_BROWSER_SESSIONS_BASE_SESSION_SERVICE_COMMANDS_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "components/sessions/session_id.h"
16 class SerializedNavigationEntry;
19 // These commands create and read common base commands for SessionService and
20 // PersistentTabRestoreService.
22 // Creates a SessionCommand that represents a navigation.
23 scoped_ptr<SessionCommand> CreateUpdateTabNavigationCommand(
24 SessionID::id_type command_id,
25 SessionID::id_type tab_id,
26 const sessions::SerializedNavigationEntry& navigation);
28 // Creates a SessionCommand that represents marking a tab as an application.
29 scoped_ptr<SessionCommand> CreateSetTabExtensionAppIDCommand(
30 SessionID::id_type command_id,
31 SessionID::id_type tab_id,
32 const std::string& extension_id);
34 // Creates a SessionCommand that containing user agent override used by a
36 scoped_ptr<SessionCommand> CreateSetTabUserAgentOverrideCommand(
37 SessionID::id_type command_id,
38 SessionID::id_type tab_id,
39 const std::string& user_agent_override);
41 // Creates a SessionCommand stores a browser window's app name.
42 scoped_ptr<SessionCommand> CreateSetWindowAppNameCommand(
43 SessionID::id_type command_id,
44 SessionID::id_type window_id,
45 const std::string& app_name);
47 // Converts a SessionCommand previously created by
48 // CreateUpdateTabNavigationCommand into a
49 // sessions::SerializedNavigationEntry. Returns true on success. If
50 // successful |tab_id| is set to the id of the restored tab.
51 bool RestoreUpdateTabNavigationCommand(
52 const SessionCommand& command,
53 sessions::SerializedNavigationEntry* navigation,
54 SessionID::id_type* tab_id);
56 // Extracts a SessionCommand as previously created by
57 // CreateSetTabExtensionAppIDCommand into the tab id and application
59 bool RestoreSetTabExtensionAppIDCommand(const SessionCommand& command,
60 SessionID::id_type* tab_id,
61 std::string* extension_app_id);
63 // Extracts a SessionCommand as previously created by
64 // CreateSetTabUserAgentOverrideCommand into the tab id and user agent.
65 bool RestoreSetTabUserAgentOverrideCommand(const SessionCommand& command,
66 SessionID::id_type* tab_id,
67 std::string* user_agent_override);
69 // Extracts a SessionCommand as previously created by
70 // CreateSetWindowAppNameCommand into the window id and application name.
71 bool RestoreSetWindowAppNameCommand(const SessionCommand& command,
72 SessionID::id_type* window_id,
73 std::string* app_name);
75 #endif // CHROME_BROWSER_SESSIONS_BASE_SESSION_SERVICE_COMMANDS_H_