| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_SESSIONS_SESSIONS_API_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSIONS_API_H__ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSIONS_API_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSIONS_API_H__ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/extensions/chrome_extension_function.h" | 10 #include "chrome/browser/extensions/chrome_extension_function.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 class SessionId; | 27 class SessionId; |
| 28 | 28 |
| 29 class SessionsGetRecentlyClosedFunction : public ChromeSyncExtensionFunction { | 29 class SessionsGetRecentlyClosedFunction : public ChromeSyncExtensionFunction { |
| 30 protected: | 30 protected: |
| 31 ~SessionsGetRecentlyClosedFunction() override {} | 31 ~SessionsGetRecentlyClosedFunction() override {} |
| 32 bool RunSync() override; | 32 bool RunSync() override; |
| 33 DECLARE_EXTENSION_FUNCTION("sessions.getRecentlyClosed", | 33 DECLARE_EXTENSION_FUNCTION("sessions.getRecentlyClosed", |
| 34 SESSIONS_GETRECENTLYCLOSED) | 34 SESSIONS_GETRECENTLYCLOSED) |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 scoped_ptr<api::tabs::Tab> CreateTabModel(const TabRestoreService::Tab& tab, | 37 scoped_ptr<api::tabs::Tab> CreateTabModel( |
| 38 int session_id, | 38 const sessions::TabRestoreService::Tab& tab, |
| 39 int selected_index); | 39 int session_id, |
| 40 int selected_index); |
| 40 scoped_ptr<api::windows::Window> CreateWindowModel( | 41 scoped_ptr<api::windows::Window> CreateWindowModel( |
| 41 const TabRestoreService::Window& window, | 42 const sessions::TabRestoreService::Window& window, |
| 42 int session_id); | 43 int session_id); |
| 43 scoped_ptr<api::sessions::Session> CreateSessionModel( | 44 scoped_ptr<api::sessions::Session> CreateSessionModel( |
| 44 const TabRestoreService::Entry* entry); | 45 const sessions::TabRestoreService::Entry* entry); |
| 45 }; | 46 }; |
| 46 | 47 |
| 47 class SessionsGetDevicesFunction : public ChromeSyncExtensionFunction { | 48 class SessionsGetDevicesFunction : public ChromeSyncExtensionFunction { |
| 48 protected: | 49 protected: |
| 49 ~SessionsGetDevicesFunction() override {} | 50 ~SessionsGetDevicesFunction() override {} |
| 50 bool RunSync() override; | 51 bool RunSync() override; |
| 51 DECLARE_EXTENSION_FUNCTION("sessions.getDevices", SESSIONS_GETDEVICES) | 52 DECLARE_EXTENSION_FUNCTION("sessions.getDevices", SESSIONS_GETDEVICES) |
| 52 | 53 |
| 53 private: | 54 private: |
| 54 scoped_ptr<api::tabs::Tab> CreateTabModel(const std::string& session_tag, | 55 scoped_ptr<api::tabs::Tab> CreateTabModel(const std::string& session_tag, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 74 private: | 75 private: |
| 75 void SetInvalidIdError(const std::string& invalid_id); | 76 void SetInvalidIdError(const std::string& invalid_id); |
| 76 void SetResultRestoredTab(content::WebContents* contents); | 77 void SetResultRestoredTab(content::WebContents* contents); |
| 77 bool SetResultRestoredWindow(int window_id); | 78 bool SetResultRestoredWindow(int window_id); |
| 78 bool RestoreMostRecentlyClosed(Browser* browser); | 79 bool RestoreMostRecentlyClosed(Browser* browser); |
| 79 bool RestoreLocalSession(const SessionId& session_id, Browser* browser); | 80 bool RestoreLocalSession(const SessionId& session_id, Browser* browser); |
| 80 bool RestoreForeignSession(const SessionId& session_id, | 81 bool RestoreForeignSession(const SessionId& session_id, |
| 81 Browser* browser); | 82 Browser* browser); |
| 82 }; | 83 }; |
| 83 | 84 |
| 84 class SessionsEventRouter : public TabRestoreServiceObserver { | 85 class SessionsEventRouter : public sessions::TabRestoreServiceObserver { |
| 85 public: | 86 public: |
| 86 explicit SessionsEventRouter(Profile* profile); | 87 explicit SessionsEventRouter(Profile* profile); |
| 87 ~SessionsEventRouter() override; | 88 ~SessionsEventRouter() override; |
| 88 | 89 |
| 89 // Observer callback for TabRestoreServiceObserver. Sends data on | 90 // Observer callback for TabRestoreServiceObserver. Sends data on |
| 90 // recently closed tabs to the javascript side of this page to | 91 // recently closed tabs to the javascript side of this page to |
| 91 // display to the user. | 92 // display to the user. |
| 92 void TabRestoreServiceChanged(TabRestoreService* service) override; | 93 void TabRestoreServiceChanged(sessions::TabRestoreService* service) override; |
| 93 | 94 |
| 94 // Observer callback to notice when our associated TabRestoreService | 95 // Observer callback to notice when our associated TabRestoreService |
| 95 // is destroyed. | 96 // is destroyed. |
| 96 void TabRestoreServiceDestroyed(TabRestoreService* service) override; | 97 void TabRestoreServiceDestroyed( |
| 98 sessions::TabRestoreService* service) override; |
| 97 | 99 |
| 98 private: | 100 private: |
| 99 Profile* profile_; | 101 Profile* profile_; |
| 100 | 102 |
| 101 // TabRestoreService that we are observing. | 103 // TabRestoreService that we are observing. |
| 102 TabRestoreService* tab_restore_service_; | 104 sessions::TabRestoreService* tab_restore_service_; |
| 103 | 105 |
| 104 DISALLOW_COPY_AND_ASSIGN(SessionsEventRouter); | 106 DISALLOW_COPY_AND_ASSIGN(SessionsEventRouter); |
| 105 }; | 107 }; |
| 106 | 108 |
| 107 class SessionsAPI : public BrowserContextKeyedAPI, | 109 class SessionsAPI : public BrowserContextKeyedAPI, |
| 108 public extensions::EventRouter::Observer { | 110 public extensions::EventRouter::Observer { |
| 109 public: | 111 public: |
| 110 explicit SessionsAPI(content::BrowserContext* context); | 112 explicit SessionsAPI(content::BrowserContext* context); |
| 111 ~SessionsAPI() override; | 113 ~SessionsAPI() override; |
| 112 | 114 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 132 | 134 |
| 133 // Created lazily upon OnListenerAdded. | 135 // Created lazily upon OnListenerAdded. |
| 134 scoped_ptr<SessionsEventRouter> sessions_event_router_; | 136 scoped_ptr<SessionsEventRouter> sessions_event_router_; |
| 135 | 137 |
| 136 DISALLOW_COPY_AND_ASSIGN(SessionsAPI); | 138 DISALLOW_COPY_AND_ASSIGN(SessionsAPI); |
| 137 }; | 139 }; |
| 138 | 140 |
| 139 } // namespace extensions | 141 } // namespace extensions |
| 140 | 142 |
| 141 #endif // CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSIONS_API_H__ | 143 #endif // CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSIONS_API_H__ |
| OLD | NEW |