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 "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 void SetResultRestoredTab(content::WebContents* contents); | 78 void SetResultRestoredTab(content::WebContents* contents); |
79 bool SetResultRestoredWindow(int window_id); | 79 bool SetResultRestoredWindow(int window_id); |
80 bool RestoreMostRecentlyClosed(Browser* browser); | 80 bool RestoreMostRecentlyClosed(Browser* browser); |
81 bool RestoreLocalSession(const SessionId& session_id, Browser* browser); | 81 bool RestoreLocalSession(const SessionId& session_id, Browser* browser); |
82 bool RestoreForeignSession(const SessionId& session_id, | 82 bool RestoreForeignSession(const SessionId& session_id, |
83 Browser* browser); | 83 Browser* browser); |
84 }; | 84 }; |
85 | 85 |
86 class SessionsEventRouter : public sessions::TabRestoreServiceObserver { | 86 class SessionsEventRouter : public sessions::TabRestoreServiceObserver { |
87 public: | 87 public: |
88 explicit SessionsEventRouter(Profile* profile); | 88 explicit SessionsEventRouter(Profile* profile, |
| 89 EventRouter::Observer* observer); |
89 ~SessionsEventRouter() override; | 90 ~SessionsEventRouter() override; |
90 | 91 |
91 // Observer callback for TabRestoreServiceObserver. Sends data on | 92 // Observer callback for TabRestoreServiceObserver. Sends data on |
92 // recently closed tabs to the javascript side of this page to | 93 // recently closed tabs to the javascript side of this page to |
93 // display to the user. | 94 // display to the user. |
94 void TabRestoreServiceChanged(sessions::TabRestoreService* service) override; | 95 void TabRestoreServiceChanged(sessions::TabRestoreService* service) override; |
95 | 96 |
96 // Observer callback to notice when our associated TabRestoreService | 97 // Observer callback to notice when our associated TabRestoreService |
97 // is destroyed. | 98 // is destroyed. |
98 void TabRestoreServiceDestroyed( | 99 void TabRestoreServiceDestroyed( |
99 sessions::TabRestoreService* service) override; | 100 sessions::TabRestoreService* service) override; |
100 | 101 |
101 private: | 102 private: |
102 Profile* profile_; | 103 Profile* profile_; |
| 104 EventRouter::Observer* observer_; |
103 | 105 |
104 // TabRestoreService that we are observing. | 106 // TabRestoreService that we are observing. |
105 sessions::TabRestoreService* tab_restore_service_; | 107 sessions::TabRestoreService* tab_restore_service_; |
106 | 108 |
107 DISALLOW_COPY_AND_ASSIGN(SessionsEventRouter); | 109 DISALLOW_COPY_AND_ASSIGN(SessionsEventRouter); |
108 }; | 110 }; |
109 | 111 |
110 class SessionsAPI : public BrowserContextKeyedAPI, | 112 class SessionsAPI : public BrowserContextKeyedAPI, |
111 public extensions::EventRouter::Observer { | 113 public extensions::EventRouter::Observer { |
112 public: | 114 public: |
(...skipping 22 matching lines...) Expand all Loading... |
135 | 137 |
136 // Created lazily upon OnListenerAdded. | 138 // Created lazily upon OnListenerAdded. |
137 scoped_ptr<SessionsEventRouter> sessions_event_router_; | 139 scoped_ptr<SessionsEventRouter> sessions_event_router_; |
138 | 140 |
139 DISALLOW_COPY_AND_ASSIGN(SessionsAPI); | 141 DISALLOW_COPY_AND_ASSIGN(SessionsAPI); |
140 }; | 142 }; |
141 | 143 |
142 } // namespace extensions | 144 } // namespace extensions |
143 | 145 |
144 #endif // CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSIONS_API_H__ | 146 #endif // CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSIONS_API_H__ |
OLD | NEW |