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

Side by Side Diff: chrome/browser/ui/app_list/drive/drive_app_provider.h

Issue 308003005: app_list: Drive app integration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: format Created 6 years, 6 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 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_UI_APP_LIST_DRIVE_DRIVE_APP_PROVIDER_H_
6 #define CHROME_BROWSER_UI_APP_LIST_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 DriveAppConverter;
29 class DriveAppMapping;
30 class DriveServiceBridge;
31 class ExtensionService;
32 class Profile;
33
34 // DriveAppProvider is the integration point for Drive apps in launcher.
35 // It ensures each Drive app has a corresponding Chrome app in the extension
36 // system. If there is no matching Chrome app, a local URL app would be created.
37 // The class processes app changes from both DriveAppRegistry and extension
38 // system to keep the two in sync.
39 class DriveAppProvider : public drive::DriveAppRegistryObserver,
40 public extensions::InstallObserver {
41 public:
42 DriveAppProvider(Profile* profile, app_list::AppListModel* model);
43 virtual ~DriveAppProvider();
44
45 // Appends PKS factories this class depends on.
46 static void AppendDependsOnFactories(
47 std::set<BrowserContextKeyedServiceFactory*>* factories);
48
49 void SetDriveServiceBridgeForTest(scoped_ptr<DriveServiceBridge> test_bridge);
50
51 private:
52 friend class DriveAppProviderTest;
53
54 typedef std::set<std::string> IdSet;
55 typedef std::vector<drive::DriveAppInfo> DriveAppInfos;
56
57 // Migrate launcher model data of |old_chrome_app_id| to |new_chrome_app_id|.
58 void MigrateModelSettings(const std::string& drive_app_id,
59 const std::string& old_chrome_app_id,
60 const std::string& new_chrome_app_id);
61
62 // Updates drive app id to chrome app mapping with the preference
63 // to keep chrome app over URL app and new app over existing app.
64 void UpdateMappingAndExtensionSystem(const std::string& drive_app_id,
65 const extensions::Extension* new_app);
66
67 // Deferred processing of relevant extension installed message.
68 void ProcessDeferredOnExtensionInstalled(const std::string drive_app_id,
69 const std::string chrome_app_id);
70
71 void SchedulePendingConverters();
72 void OnLocalAppConverted(const DriveAppConverter* converter, bool success);
73
74 bool IsDriveAppUpToDate(const drive::DriveAppInfo& drive_app) const;
75
76 void AddOrUpdateDriveApp(const drive::DriveAppInfo& drive_app);
77 void RemoveDriveApp(const std::string& drive_app_id);
78
79 // drive::DriveAppRegistryObserver overrides:
80 virtual void OnDriveAppRegistryUpdated() OVERRIDE;
81
82 // extensions::InstallObserver overrides:
83 virtual void OnExtensionInstalled(
84 const extensions::Extension* extension) OVERRIDE;
85 virtual void OnExtensionUninstalled(
86 const extensions::Extension* extension) OVERRIDE;
87
88 Profile* profile_;
89 app_list::AppListModel* model_; // Not owned. Must out live this class.
90
91 scoped_ptr<DriveServiceBridge> service_bridge_;
92 scoped_ptr<DriveAppMapping> mapping_;
93 DriveAppInfos drive_apps_;
94
95 // Tracks the pending web app convertions.
96 ScopedVector<DriveAppConverter> pending_converters_;
97
98 base::WeakPtrFactory<DriveAppProvider> weak_ptr_factory_;
99
100 DISALLOW_COPY_AND_ASSIGN(DriveAppProvider);
101 };
102
103 #endif // CHROME_BROWSER_UI_APP_LIST_DRIVE_DRIVE_APP_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698