Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_SERVICE_COMMANDS_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_SERVICE_COMMANDS_H_ |
| 6 #define CHROME_BROWSER_SESSIONS_SESSION_SERVICE_COMMANDS_H_ | 6 #define CHROME_BROWSER_SESSIONS_SESSION_SERVICE_COMMANDS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/task/cancelable_task_tracker.h" | 15 #include "base/task/cancelable_task_tracker.h" |
| 16 #include "chrome/browser/sessions/base_session_service.h" | 16 #include "chrome/browser/sessions/base_session_service.h" |
| 17 #include "chrome/browser/sessions/session_types.h" | 17 #include "chrome/browser/sessions/session_types.h" |
| 18 #include "ui/base/ui_base_types.h" | 18 #include "ui/base/ui_base_types.h" |
| 19 | 19 |
| 20 class SessionCommand; | 20 class SessionCommand; |
| 21 | 21 |
| 22 // The following functions create sequentialized change commands which are | 22 // The following functions create sequentialized change commands which are |
| 23 // used to reconstruct the current/previous session state. | 23 // used to reconstruct the current/previous session state. |
| 24 // It is up to the caller to delete the returned SessionCommand* object. | 24 // It is up to the caller to delete the returned SessionCommand* object. |
| 25 SessionCommand* CreateSetSelectedTabInWindowCommand( | 25 scoped_ptr<SessionCommand> CreateSetSelectedTabInWindowCommand( |
| 26 const SessionID& window_id, | 26 const SessionID& window_id, |
| 27 int index); | 27 int index); |
| 28 SessionCommand* CreateSetTabWindowCommand(const SessionID& window_id, | 28 scoped_ptr<SessionCommand> CreateSetTabWindowCommand(const SessionID& window_id, |
| 29 const SessionID& tab_id); | 29 const SessionID& tab_id); |
| 30 SessionCommand* CreateSetWindowBoundsCommand(const SessionID& window_id, | 30 scoped_ptr<SessionCommand> CreateSetWindowBoundsCommand( |
| 31 const gfx::Rect& bounds, | 31 const SessionID& window_id, |
| 32 ui::WindowShowState show_state); | 32 const gfx::Rect& bounds, |
| 33 SessionCommand* CreateSetTabIndexInWindowCommand(const SessionID& tab_id, | 33 ui::WindowShowState show_state); |
| 34 int new_index); | 34 scoped_ptr<SessionCommand> CreateSetTabIndexInWindowCommand( |
| 35 SessionCommand* CreateTabClosedCommand(SessionID::id_type tab_id); | 35 const SessionID& tab_id, |
| 36 SessionCommand* CreateWindowClosedCommand(SessionID::id_type tab_id); | 36 int new_index); |
| 37 SessionCommand* CreateSetSelectedNavigationIndexCommand( | 37 scoped_ptr<SessionCommand> CreateTabClosedCommand(SessionID::id_type tab_id); |
| 38 scoped_ptr<SessionCommand> CreateWindowClosedCommand(SessionID::id_type tab_id); | |
| 39 scoped_ptr<SessionCommand> CreateSetSelectedNavigationIndexCommand( | |
| 38 const SessionID& tab_id, | 40 const SessionID& tab_id, |
| 39 int index); | 41 int index); |
| 40 SessionCommand* CreateSetWindowTypeCommand(const SessionID& window_id, | 42 scoped_ptr<SessionCommand> CreateSetWindowTypeCommand( |
| 41 SessionWindow::WindowType type); | 43 const SessionID& window_id, |
| 42 SessionCommand* CreatePinnedStateCommand(const SessionID& tab_id, | 44 SessionWindow::WindowType type); |
| 45 scoped_ptr<SessionCommand> CreatePinnedStateCommand(const SessionID& tab_id, | |
| 43 bool is_pinned); | 46 bool is_pinned); |
| 44 SessionCommand* CreateSessionStorageAssociatedCommand( | 47 scoped_ptr<SessionCommand> CreateSessionStorageAssociatedCommand( |
| 45 const SessionID& tab_id, | 48 const SessionID& tab_id, |
| 46 const std::string& session_storage_persistent_id); | 49 const std::string& session_storage_persistent_id); |
| 47 SessionCommand* CreateSetActiveWindowCommand(const SessionID& window_id); | 50 scoped_ptr<SessionCommand> CreateSetActiveWindowCommand( |
| 48 SessionCommand* CreateTabNavigationPathPrunedFromBackCommand( | 51 const SessionID& window_id); |
| 52 scoped_ptr<SessionCommand> CreateTabNavigationPathPrunedFromBackCommand( | |
| 49 const SessionID& tab_id, | 53 const SessionID& tab_id, |
| 50 int count); | 54 int count); |
| 51 SessionCommand* CreateTabNavigationPathPrunedFromFrontCommand( | 55 scoped_ptr<SessionCommand> CreateTabNavigationPathPrunedFromFrontCommand( |
| 52 const SessionID& tab_id, | 56 const SessionID& tab_id, |
| 53 int count); | 57 int count); |
| 54 SessionCommand* CreateUpdateTabNavigationCommand( | 58 scoped_ptr<SessionCommand> CreateUpdateTabNavigationCommand( |
| 55 const SessionID& tab_id, | 59 const SessionID& tab_id, |
| 56 const sessions::SerializedNavigationEntry& navigation); | 60 const sessions::SerializedNavigationEntry& navigation); |
| 57 SessionCommand* CreateSetTabExtensionAppIDCommand( | 61 scoped_ptr<SessionCommand> CreateSetTabExtensionAppIDCommand( |
| 58 const SessionID& tab_id, | 62 const SessionID& tab_id, |
| 59 const std::string& extension_id); | 63 const std::string& extension_id); |
| 60 SessionCommand* CreateSetTabUserAgentOverrideCommand( | 64 scoped_ptr<SessionCommand> CreateSetTabUserAgentOverrideCommand( |
| 61 const SessionID& tab_id, | 65 const SessionID& tab_id, |
| 62 const std::string& user_agent_override); | 66 const std::string& user_agent_override); |
| 63 SessionCommand* CreateSetWindowAppNameCommand(const SessionID& window_id, | 67 scoped_ptr<SessionCommand> CreateSetWindowAppNameCommand( |
| 64 const std::string& app_name); | 68 const SessionID& window_id, |
| 69 const std::string& app_name); | |
| 65 | 70 |
| 66 // Searches for a pending command in |pending_commands| that can be replaced | 71 // Searches for a pending command in |pending_commands| that can be replaced |
| 67 // with |command|. If one is found, pending command is removed, command is | 72 // with |command|. If one is found, pending command is removed, the command |
| 68 // added to the pending commands and true is returned. | 73 // is added to the pending commands (taken ownership) and true is returned. |
| 69 bool ReplacePendingCommand(SessionCommand* command, | 74 bool ReplacePendingCommand( |
| 70 std::vector<SessionCommand*>& pending_commands); | 75 scoped_ptr<SessionCommand>* command, |
|
sky
2014/10/30 22:51:07
out type params should be last.
Mr4D (OOO till 08-26)
2014/10/30 23:31:21
Done.
| |
| 76 ScopedVector<SessionCommand>& pending_commands); | |
| 71 | 77 |
| 72 // Returns true if provided |command| either closes a window or a tab. | 78 // Returns true if provided |command| either closes a window or a tab. |
| 73 bool IsClosingCommand(SessionCommand* command); | 79 bool IsClosingCommand(SessionCommand* command); |
| 74 | 80 |
| 75 // Converts a list of commands into SessionWindows. On return any valid | 81 // Converts a list of commands into SessionWindows. On return any valid |
| 76 // windows are added to valid_windows. It is up to the caller to delete | 82 // windows are added to valid_windows. It is up to the caller to delete |
| 77 // the windows added to valid_windows. |active_window_id| will be set with the | 83 // the windows added to valid_windows. |active_window_id| will be set with the |
| 78 // id of the last active window, but it's only valid when this id corresponds | 84 // id of the last active window, but it's only valid when this id corresponds |
| 79 // to the id of one of the windows in valid_windows. | 85 // to the id of one of the windows in valid_windows. |
| 80 void RestoreSessionFromCommands(const std::vector<SessionCommand*>& commands, | 86 void RestoreSessionFromCommands(const ScopedVector<SessionCommand>& commands, |
| 81 std::vector<SessionWindow*>* valid_windows, | 87 std::vector<SessionWindow*>* valid_windows, |
| 82 SessionID::id_type* active_window_id); | 88 SessionID::id_type* active_window_id); |
| 83 | 89 |
| 84 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_COMMANDS_H_ | 90 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_COMMANDS_H_ |
| OLD | NEW |