OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_APPS_DRIVE_DRIVE_APP_PROVIDER_H_ | |
6 #define CHROME_BROWSER_APPS_DRIVE_DRIVE_APP_PROVIDER_H_ | |
7 | |
8 #include <set> | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "base/macros.h" | |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/memory/scoped_vector.h" | |
15 #include "base/memory/weak_ptr.h" | |
16 #include "chrome/browser/drive/drive_app_registry_observer.h" | |
17 #include "chrome/browser/extensions/install_observer.h" | |
18 | |
19 namespace app_list { | |
20 class AppListModel; | |
21 } | |
22 | |
23 namespace drive { | |
24 struct DriveAppInfo; | |
25 } | |
26 | |
27 class BrowserContextKeyedServiceFactory; | |
28 class ExtensionService; | |
29 class Profile; | |
30 | |
31 namespace extensions { | |
32 | |
33 class DriveAppConverter; | |
34 class DriveAppMapping; | |
35 class DriveServiceBridge; | |
36 | |
37 // DriveAppProvider is the integration point for Drive apps. It ensures each | |
38 // Drive app has a corresponding Chrome app in the extension system. If there | |
39 // is no matching Chrome app, a local URL app would be created. The class | |
40 // processes app changes from both DriveAppRegistry and extension system to | |
41 // keep the two in sync. | |
42 class DriveAppProvider : public drive::DriveAppRegistryObserver, | |
43 public InstallObserver { | |
44 public: | |
45 DriveAppProvider(Profile* profile, app_list::AppListModel* model); | |
46 virtual ~DriveAppProvider(); | |
47 | |
48 // Appends PKS factories this class depends on. | |
49 static void AppendDependsOnFactories( | |
50 std::set<BrowserContextKeyedServiceFactory*>* factories); | |
51 | |
52 void SetDriveServiceBridgeForTest(scoped_ptr<DriveServiceBridge> test_bridge); | |
53 | |
54 private: | |
55 friend class DriveAppProviderTest; | |
56 | |
57 typedef std::set<std::string> IdSet; | |
58 typedef std::vector<drive::DriveAppInfo> DriveAppInfos; | |
59 | |
60 // Migrate launcher model data of |old_chrome_app_id| to |new_chrome_app_id|. | |
benwells
2014/06/05 01:24:39
Can you explain under which circumstances this can
xiyuan
2014/06/05 17:48:32
Updated the comment to explain when this is called
| |
61 void MigrateModelSettings(const std::string& drive_app_id, | |
62 const std::string& old_chrome_app_id, | |
63 const std::string& new_chrome_app_id); | |
64 | |
65 // Updates drive app id to chrome app mapping with the preference | |
66 // to keep chrome app over URL app and new app over existing app. | |
benwells
2014/06/05 01:24:39
I don't understand this comment, specifically the
xiyuan
2014/06/05 17:48:32
Update the comments to be more specific.
| |
67 void UpdateMappingAndExtensionSystem(const std::string& drive_app_id, | |
68 const Extension* new_app); | |
69 | |
70 // Deferred processing of relevant extension installed message. | |
71 void ProcessDeferredOnExtensionInstalled(const std::string drive_app_id, | |
72 const std::string chrome_app_id); | |
73 | |
74 void SchedulePendingConverters(); | |
75 void OnLocalAppConverted(const DriveAppConverter* converter, bool success); | |
76 | |
77 bool IsDriveAppUpToDate(const drive::DriveAppInfo& drive_app) const; | |
78 | |
79 void AddOrUpdateDriveApp(const drive::DriveAppInfo& drive_app); | |
80 void RemoveDriveApp(const std::string& drive_app_id); | |
81 | |
82 // drive::DriveAppRegistryObserver overrides: | |
83 virtual void OnDriveAppRegistryUpdated() OVERRIDE; | |
84 | |
85 // InstallObserver overrides: | |
86 virtual void OnExtensionInstalled(const Extension* extension) OVERRIDE; | |
87 virtual void OnExtensionUninstalled(const Extension* extension) OVERRIDE; | |
88 | |
89 Profile* profile_; | |
90 app_list::AppListModel* model_; // Not owned. Must out live this class. | |
91 | |
92 scoped_ptr<DriveServiceBridge> service_bridge_; | |
93 scoped_ptr<DriveAppMapping> mapping_; | |
94 DriveAppInfos drive_apps_; | |
95 | |
96 // Tracks the pending web app convertions. | |
97 ScopedVector<DriveAppConverter> pending_converters_; | |
98 | |
99 base::WeakPtrFactory<DriveAppProvider> weak_ptr_factory_; | |
100 | |
101 DISALLOW_COPY_AND_ASSIGN(DriveAppProvider); | |
102 }; | |
103 | |
104 } // namespace extensions | |
105 | |
106 #endif // CHROME_BROWSER_APPS_DRIVE_DRIVE_APP_PROVIDER_H_ | |
OLD | NEW |