Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / apps / drive / drive_app_mapping.h
blob3ac44c09fbb46ff0f659b119cb9f4c682095e5f7
1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_APPS_DRIVE_DRIVE_APP_MAPPING_H_
6 #define CHROME_BROWSER_APPS_DRIVE_DRIVE_APP_MAPPING_H_
8 #include <set>
9 #include <string>
11 #include "base/macros.h"
13 namespace user_prefs {
14 class PrefRegistrySyncable;
17 class PrefService;
19 // DriveAppMapping tracks the mapping between Drive apps and corresponding
20 // Chrome apps. The data is backed by kAppLauncherDriveAppMapping pref.
21 class DriveAppMapping {
22 public:
23 explicit DriveAppMapping(PrefService* prefs);
24 ~DriveAppMapping();
26 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
28 // Adds a mapping from |drive_app_id| to |chrome_app_id|. |generated|
29 // represents whether the corresponding Chrome app is generated.
30 void Add(const std::string& drive_app_id,
31 const std::string& chrome_app_id,
32 bool generated);
33 void Remove(const std::string& drive_app_id);
35 std::string GetChromeApp(const std::string& drive_app_id) const;
36 std::string GetDriveApp(const std::string& chrome_app_id) const;
37 bool IsChromeAppGenerated(const std::string& chrome_app_id) const;
39 std::set<std::string> GetDriveAppIds() const;
41 void AddUninstalledDriveApp(const std::string& drive_app_id);
42 void RemoveUninstalledDriveApp(const std::string& drive_app_id);
43 bool IsUninstalledDriveApp(const std::string& drive_app_id) const;
45 private:
46 void GetUninstalledIdsFromPref();
47 void UpdateUninstalledList();
49 PrefService* prefs_;
50 std::set<std::string> uninstalled_app_ids_;
52 DISALLOW_COPY_AND_ASSIGN(DriveAppMapping);
55 #endif // CHROME_BROWSER_APPS_DRIVE_DRIVE_APP_MAPPING_H_