Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/browser/extensions/api/sessions/sessions_api.h

Issue 21022018: Sessions API - previously Session Restore API. Supports restoring currently open foreign windows an… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added assert true to test Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
not at google - send to devlin 2013/07/31 22:54:22 could you make git detect this and the next 2 file
Kristen Dwan 2013/08/02 20:54:19 Done.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSIONS_API_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSIONS_API_H__
7
8 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
9 #include "chrome/browser/extensions/extension_function.h"
10 #include "chrome/browser/sessions/tab_restore_service.h"
11 #include "chrome/browser/sessions/tab_restore_service_observer.h"
12 #include "chrome/common/extensions/api/sessions.h"
13 #include "chrome/common/extensions/api/tabs.h"
14 #include "chrome/common/extensions/api/windows.h"
15
16 class Profile;
17
18 namespace browser_sync {
19 struct SyncedSession;
20 }
21
22 namespace extensions {
23
24 class SessionsGetRecentlyClosedFunction : public SyncExtensionFunction {
25 protected:
26 virtual ~SessionsGetRecentlyClosedFunction() {}
27 virtual bool RunImpl() OVERRIDE;
28 DECLARE_EXTENSION_FUNCTION("sessions.getRecentlyClosed",
29 SESSIONS_GETRECENTLYCLOSED)
30
31 private:
32 scoped_ptr<api::tabs::Tab> CreateTabModel(
33 const TabRestoreService::Tab& tab, const int* const session_id,
34 int selected_index);
35 scoped_ptr<api::windows::Window> CreateWindowModel(
36 const TabRestoreService::Window& window, int session_id);
37 scoped_ptr<api::sessions::Session> CreateSessionModel(
38 const TabRestoreService::Entry* entry);
39 };
40
41 class SessionsGetDevicesFunction : public SyncExtensionFunction {
42 protected:
43 virtual ~SessionsGetDevicesFunction() {}
44 virtual bool RunImpl() OVERRIDE;
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);
57 };
58
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 {
73 public:
74 explicit SessionsAPI(Profile* profile);
75 virtual ~SessionsAPI();
76
77 // ProfileKeyedAPI implementation.
78 static ProfileKeyedAPIFactory<SessionsAPI>* GetFactoryInstance();
79 private:
80 friend class ProfileKeyedAPIFactory<SessionsAPI>;
81
82 // ProfileKeyedAPI implementation.
83 static const char* service_name() {
84 return "SessionsAPI";
85 }
86 static const bool kServiceIsNULLWhileTesting = true;
87 };
88
89 } // namespace extensions
90
91 #endif // CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSIONS_API_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698