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

Side by Side Diff: chrome/browser/apps/drive/drive_app_provider.h

Issue 308003005: app_list: Drive app integration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: crx_installer changes 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_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;
benwells 2014/06/06 00:31:04 This dependency is not good. My questions about Mi
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. It ensures each
35 // Drive app has a corresponding Chrome app in the extension system. If there
36 // is no matching Chrome app, a local URL app would be created. The class
37 // processes app changes from both DriveAppRegistry and extension system to
38 // 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 // when a Drive app is mapped to a different app ID. This happens when
59 // the matching Chrome app is installed by user. The placeholder URL app will
60 // be auto uninstalled and this function is called to migrate its model data
61 // (folder/position info) to the Chrome app. Another possible edge case is
62 // the Drive app changes its create_url and a new placeholder URL app will be
63 // used.
64 void MigrateModelSettings(const std::string& drive_app_id,
benwells 2014/06/06 00:31:04 Has this behavior come from the UX team? I couldn'
xiyuan 2014/06/06 01:32:01 The behavior is not defined by UX. I guess I put i
65 const std::string& old_chrome_app_id,
66 const std::string& new_chrome_app_id);
67
68 // Updates drive app id to chrome app id mapping. If the drive app has
benwells 2014/06/06 00:31:04 Nit: has -> was.
69 // not mapped, add a mapping to |new_app|'s id. Do nothing if it is mapped to
70 // |new_app|'s id already. Things become complicated when there is an existing
71 // mapping. If the existing one is an URL app, update the mapping to |new_app|
72 // and call MigrateModelSettings to migrate model data. If the existing one
73 // is an Chrome app and |new_app| is an URL app, the existing mapping is
74 // preferred and |new_app| will auto uninstalled. Otherwise, if |new_app| is
benwells 2014/06/06 00:31:04 Again I'm not sure of this behaviour. I think the
xiyuan 2014/06/06 01:32:01 Agree. The CL does too much. I will change it to k
75 // a Chrome app, the mapping is updated to use |new_app| but existing Chrome
76 // app is kept.
77 void UpdateMappingAndExtensionSystem(const std::string& drive_app_id,
78 const extensions::Extension* new_app);
79
80 // Deferred processing of relevant extension installed message.
81 void ProcessDeferredOnExtensionInstalled(const std::string drive_app_id,
82 const std::string chrome_app_id);
83
84 void SchedulePendingConverters();
85 void OnLocalAppConverted(const DriveAppConverter* converter, bool success);
86
87 bool IsDriveAppUpToDate(const drive::DriveAppInfo& drive_app) const;
88
89 void AddOrUpdateDriveApp(const drive::DriveAppInfo& drive_app);
90 void RemoveDriveApp(const std::string& drive_app_id);
91
92 // drive::DriveAppRegistryObserver overrides:
93 virtual void OnDriveAppRegistryUpdated() OVERRIDE;
94
95 // extensions::InstallObserver overrides:
96 virtual void OnExtensionInstalled(
97 const extensions::Extension* extension) OVERRIDE;
98 virtual void OnExtensionUninstalled(
99 const extensions::Extension* extension) OVERRIDE;
100
101 Profile* profile_;
102 app_list::AppListModel* model_; // Not owned. Must out live this class.
103
104 scoped_ptr<DriveServiceBridge> service_bridge_;
105 scoped_ptr<DriveAppMapping> mapping_;
106 DriveAppInfos drive_apps_;
107
108 // Tracks the pending web app convertions.
109 ScopedVector<DriveAppConverter> pending_converters_;
110
111 base::WeakPtrFactory<DriveAppProvider> weak_ptr_factory_;
112
113 DISALLOW_COPY_AND_ASSIGN(DriveAppProvider);
114 };
115
116 #endif // CHROME_BROWSER_APPS_DRIVE_DRIVE_APP_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698