/chromium-webcl/src/chrome/browser/extensions/api/session_restore/session_restore_api.h

https://bitbucket.org/peixuan/chromium_r197479_base · C Header · 61 lines · 44 code · 12 blank · 5 comment · 0 complexity · 42b707500403397f5d4933ccc5829bd1 MD5 · raw file

  1. // Copyright (c) 2012 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.
  4. #ifndef CHROME_BROWSER_EXTENSIONS_API_SESSION_RESTORE_SESSION_RESTORE_API_H__
  5. #define CHROME_BROWSER_EXTENSIONS_API_SESSION_RESTORE_SESSION_RESTORE_API_H__
  6. #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
  7. #include "chrome/browser/extensions/extension_function.h"
  8. #include "chrome/browser/sessions/tab_restore_service.h"
  9. #include "chrome/common/extensions/api/session_restore.h"
  10. #include "chrome/common/extensions/api/tabs.h"
  11. #include "chrome/common/extensions/api/windows.h"
  12. class Profile;
  13. namespace extensions {
  14. class SessionRestoreGetRecentlyClosedFunction : public SyncExtensionFunction {
  15. protected:
  16. virtual ~SessionRestoreGetRecentlyClosedFunction() {}
  17. virtual bool RunImpl() OVERRIDE;
  18. DECLARE_EXTENSION_FUNCTION("sessionRestore.getRecentlyClosed",
  19. SESSIONRESTORE_GETRECENTLYCLOSED)
  20. private:
  21. scoped_ptr<api::tabs::Tab> CreateTabModel(
  22. const TabRestoreService::Tab& tab, int selected_index);
  23. scoped_ptr<api::windows::Window> CreateWindowModel(
  24. const TabRestoreService::Window& window);
  25. scoped_ptr<api::session_restore::ClosedEntry> CreateEntryModel(
  26. const TabRestoreService::Entry* entry);
  27. };
  28. class SessionRestoreRestoreFunction : public SyncExtensionFunction {
  29. protected:
  30. virtual ~SessionRestoreRestoreFunction() {}
  31. virtual bool RunImpl() OVERRIDE;
  32. DECLARE_EXTENSION_FUNCTION("sessionRestore.restore", SESSIONRESTORE_RESTORE)
  33. };
  34. class SessionRestoreAPI : public ProfileKeyedAPI {
  35. public:
  36. explicit SessionRestoreAPI(Profile* profile);
  37. virtual ~SessionRestoreAPI();
  38. // ProfileKeyedAPI implementation.
  39. static ProfileKeyedAPIFactory<SessionRestoreAPI>* GetFactoryInstance();
  40. private:
  41. friend class ProfileKeyedAPIFactory<SessionRestoreAPI>;
  42. // ProfileKeyedAPI implementation.
  43. static const char* service_name() {
  44. return "SessionRestoreAPI";
  45. }
  46. static const bool kServiceIsNULLWhileTesting = true;
  47. };
  48. } // namespace extensions
  49. #endif // CHROME_BROWSER_EXTENSIONS_API_SESSION_RESTORE_SESSION_RESTORE_API_H__