blob: 0217f6010abd03396aa5301489e379dd03b44687 [file] [log] [blame]
[email protected]28c3eeb2012-10-15 05:47:531// 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
5#ifndef CHROME_BROWSER_EXTENSIONS_APP_RESTORE_SERVICE_H_
6#define CHROME_BROWSER_EXTENSIONS_APP_RESTORE_SERVICE_H_
7
[email protected]c2e2b6d2013-01-22 02:23:298#include <string>
9
[email protected]28c3eeb2012-10-15 05:47:5310#include "chrome/browser/profiles/profile_keyed_service.h"
11#include "content/public/browser/notification_observer.h"
12#include "content/public/browser/notification_registrar.h"
13
[email protected]b8816a42013-02-27 07:59:0014namespace extensions {
15class Extension;
[email protected]b897ff872013-02-27 19:50:1316
17namespace app_file_handler_util {
18struct SavedFileEntry;
[email protected]b8816a42013-02-27 07:59:0019}
[email protected]4fe61bc2013-02-27 05:17:0820
[email protected]b897ff872013-02-27 19:50:1321}
22
23class Profile;
24
25using extensions::app_file_handler_util::SavedFileEntry;
26
[email protected]c2e2b6d2013-01-22 02:23:2927namespace apps {
[email protected]28c3eeb2012-10-15 05:47:5328
29// Tracks what apps need to be restarted when the browser restarts.
30class AppRestoreService : public ProfileKeyedService,
31 public content::NotificationObserver {
32 public:
33 explicit AppRestoreService(Profile* profile);
34
[email protected]119454622012-10-18 09:48:3235 // Restart apps that need to be restarted and clear the "running" preference
36 // from apps to prevent them being restarted in subsequent restarts.
[email protected]300ba0c42012-12-06 06:57:1737 void HandleStartup(bool should_restore_apps);
[email protected]28c3eeb2012-10-15 05:47:5338
39 private:
40 // content::NotificationObserver.
41 virtual void Observe(int type,
42 const content::NotificationSource& source,
43 const content::NotificationDetails& details) OVERRIDE;
44
45 void RecordAppStart(const std::string& extension_id);
46 void RecordAppStop(const std::string& extension_id);
[email protected]b897ff872013-02-27 19:50:1347 void RestoreApp(
48 const extensions::Extension* extension,
49 const std::vector<SavedFileEntry>& file_entries);
[email protected]28c3eeb2012-10-15 05:47:5350
51 content::NotificationRegistrar registrar_;
52 Profile* profile_;
53};
54
[email protected]c2e2b6d2013-01-22 02:23:2955} // namespace apps
[email protected]28c3eeb2012-10-15 05:47:5356
57#endif // CHROME_BROWSER_EXTENSIONS_APP_RESTORE_SERVICE_H_