Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / sessions / base_session_service_commands.h
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.
4
5 #ifndef CHROME_BROWSER_SESSIONS_BASE_SESSION_SERVICE_COMMANDS_H_
6 #define CHROME_BROWSER_SESSIONS_BASE_SESSION_SERVICE_COMMANDS_H_
7
8 #include <string>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "components/sessions/session_id.h"
12
13 class SessionCommand;
14
15 namespace sessions {
16 class SerializedNavigationEntry;
17 }
18
19 // These commands create and read common base commands for SessionService and
20 // PersistentTabRestoreService.
21
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);
27
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);
33
34 // Creates a SessionCommand that containing user agent override used by a
35 // tab's navigations.
36 scoped_ptr<SessionCommand> CreateSetTabUserAgentOverrideCommand(
37     SessionID::id_type command_id,
38     SessionID::id_type tab_id,
39     const std::string& user_agent_override);
40
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);
46
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);
55
56 // Extracts a SessionCommand as previously created by
57 // CreateSetTabExtensionAppIDCommand into the tab id and application
58 // extension id.
59 bool RestoreSetTabExtensionAppIDCommand(const SessionCommand& command,
60                                         SessionID::id_type* tab_id,
61                                         std::string* extension_app_id);
62
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);
68
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);
74
75 #endif  // CHROME_BROWSER_SESSIONS_BASE_SESSION_SERVICE_COMMANDS_H_