Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_EXTENSIONS_API_SESSION_RESTORE_SESSION_RESTORE_API_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSIONS_API_H__ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_SESSION_RESTORE_SESSION_RESTORE_API_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSIONS_API_H__ |
| 7 | 7 |
| 8 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 8 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
| 9 #include "chrome/browser/extensions/extension_function.h" | 9 #include "chrome/browser/extensions/extension_function.h" |
| 10 #include "chrome/browser/sessions/tab_restore_service.h" | 10 #include "chrome/browser/sessions/tab_restore_service.h" |
| 11 #include "chrome/common/extensions/api/session_restore.h" | 11 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
| 12 #include "chrome/common/extensions/api/sessions.h" | |
| 12 #include "chrome/common/extensions/api/tabs.h" | 13 #include "chrome/common/extensions/api/tabs.h" |
| 13 #include "chrome/common/extensions/api/windows.h" | 14 #include "chrome/common/extensions/api/windows.h" |
| 14 | 15 |
| 15 class Profile; | 16 class Profile; |
| 16 | 17 |
| 18 namespace browser_sync { | |
| 19 struct SyncedSession; | |
| 20 } | |
| 21 | |
| 17 namespace extensions { | 22 namespace extensions { |
| 18 | 23 |
| 19 class SessionRestoreGetRecentlyClosedFunction : public SyncExtensionFunction { | 24 class SessionsGetRecentlyClosedFunction : public SyncExtensionFunction { |
| 20 protected: | 25 protected: |
| 21 virtual ~SessionRestoreGetRecentlyClosedFunction() {} | 26 virtual ~SessionsGetRecentlyClosedFunction() {} |
| 22 virtual bool RunImpl() OVERRIDE; | 27 virtual bool RunImpl() OVERRIDE; |
| 23 DECLARE_EXTENSION_FUNCTION("sessionRestore.getRecentlyClosed", | 28 DECLARE_EXTENSION_FUNCTION("sessions.getRecentlyClosed", |
| 24 SESSIONRESTORE_GETRECENTLYCLOSED) | 29 SESSIONS_GETRECENTLYCLOSED) |
|
not at google - send to devlin
2013/08/06 19:04:09
style nit: align vertically with the first argumen
Kristen Dwan
2013/08/12 15:11:30
Done.
| |
| 25 | 30 |
| 26 private: | 31 private: |
| 27 scoped_ptr<api::tabs::Tab> CreateTabModel( | 32 scoped_ptr<api::tabs::Tab> CreateTabModel( |
| 28 const TabRestoreService::Tab& tab, int selected_index); | 33 const TabRestoreService::Tab& tab, const int* const session_id, |
| 34 int selected_index); | |
| 29 scoped_ptr<api::windows::Window> CreateWindowModel( | 35 scoped_ptr<api::windows::Window> CreateWindowModel( |
| 30 const TabRestoreService::Window& window); | 36 const TabRestoreService::Window& window, int session_id); |
| 31 scoped_ptr<api::session_restore::ClosedEntry> CreateEntryModel( | 37 scoped_ptr<api::sessions::Session> CreateSessionModel( |
| 32 const TabRestoreService::Entry* entry); | 38 const TabRestoreService::Entry* entry); |
| 33 }; | 39 }; |
| 34 | 40 |
| 35 class SessionRestoreRestoreFunction : public SyncExtensionFunction { | 41 class SessionsGetDevicesFunction : public SyncExtensionFunction { |
| 36 protected: | 42 protected: |
| 37 virtual ~SessionRestoreRestoreFunction() {} | 43 virtual ~SessionsGetDevicesFunction() {} |
| 38 virtual bool RunImpl() OVERRIDE; | 44 virtual bool RunImpl() OVERRIDE; |
| 39 DECLARE_EXTENSION_FUNCTION("sessionRestore.restore", SESSIONRESTORE_RESTORE) | 45 DECLARE_EXTENSION_FUNCTION("sessions.getDevices", SESSIONS_GETDEVICES) |
| 46 | |
| 47 private: | |
| 48 scoped_ptr<api::tabs::Tab> CreateTabModel( | |
| 49 const SessionTab& tab, int selected_index, int tab_index, | |
| 50 const std::string& session_tag); | |
| 51 scoped_ptr<api::windows::Window> CreateWindowModel( | |
| 52 const SessionWindow& window, const std::string& session_tag); | |
| 53 scoped_ptr<api::sessions::Session> CreateSessionModel( | |
| 54 const SessionWindow& window, const std::string& session_tag); | |
| 55 scoped_ptr<api::sessions::Device> CreateDeviceModel( | |
| 56 const browser_sync::SyncedSession* session); | |
| 40 }; | 57 }; |
| 41 | 58 |
| 42 class SessionRestoreAPI : public ProfileKeyedAPI { | 59 class SessionsRestoreFunction : public SyncExtensionFunction { |
| 60 protected: | |
| 61 virtual ~SessionsRestoreFunction() {} | |
| 62 virtual bool RunImpl() OVERRIDE; | |
| 63 DECLARE_EXTENSION_FUNCTION("sessions.restore", SESSIONS_RESTORE) | |
| 64 | |
| 65 private: | |
| 66 bool RestoreMostRecentlyClosed(Browser* browser); | |
| 67 bool RestoreLocalSession(int id, Browser* browser); | |
| 68 bool RestoreForeignSession(const std::string& session_tag, | |
| 69 int id, Browser* browser); | |
| 70 }; | |
| 71 | |
| 72 class SessionsAPI : public ProfileKeyedAPI { | |
| 43 public: | 73 public: |
| 44 explicit SessionRestoreAPI(Profile* profile); | 74 explicit SessionsAPI(Profile* profile); |
| 45 virtual ~SessionRestoreAPI(); | 75 virtual ~SessionsAPI(); |
| 46 | 76 |
| 47 // ProfileKeyedAPI implementation. | 77 // ProfileKeyedAPI implementation. |
| 48 static ProfileKeyedAPIFactory<SessionRestoreAPI>* GetFactoryInstance(); | 78 static ProfileKeyedAPIFactory<SessionsAPI>* GetFactoryInstance(); |
| 49 private: | 79 private: |
| 50 friend class ProfileKeyedAPIFactory<SessionRestoreAPI>; | 80 friend class ProfileKeyedAPIFactory<SessionsAPI>; |
| 51 | 81 |
| 52 // ProfileKeyedAPI implementation. | 82 // ProfileKeyedAPI implementation. |
| 53 static const char* service_name() { | 83 static const char* service_name() { |
| 54 return "SessionRestoreAPI"; | 84 return "SessionsAPI"; |
| 55 } | 85 } |
| 56 static const bool kServiceIsNULLWhileTesting = true; | 86 static const bool kServiceIsNULLWhileTesting = true; |
| 57 }; | 87 }; |
| 58 | 88 |
| 59 } // namespace extensions | 89 } // namespace extensions |
| 60 | 90 |
| 61 #endif // CHROME_BROWSER_EXTENSIONS_API_SESSION_RESTORE_SESSION_RESTORE_API_H__ | 91 #endif // CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSIONS_API_H__ |
| OLD | NEW |