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

Side by Side Diff: chrome/browser/chromeos/drive/drive_webapps_registry.h

Issue 11106007: drive: Rename 'gdata' namespace to 'drive' in chrome/browser/chromeos/drive (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_WEBAPPS_REGISTRY_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_WEBAPPS_REGISTRY_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_WEBAPPS_REGISTRY_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_WEBAPPS_REGISTRY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 13 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
14 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 15
16 class FilePath; 16 class FilePath;
17 17
18 namespace gdata { 18 namespace gdata {
19 class AppList;
20 }
19 21
20 class AppList; 22 namespace drive {
21 23
22 // Data structure that defines WebApp 24 // Data structure that defines WebApp
23 struct DriveWebAppInfo { 25 struct DriveWebAppInfo {
24 DriveWebAppInfo(const std::string& app_id, 26 DriveWebAppInfo(const std::string& app_id,
25 const InstalledApp::IconList& app_icons, 27 const gdata::InstalledApp::IconList& app_icons,
26 const InstalledApp::IconList& document_icons, 28 const gdata::InstalledApp::IconList& document_icons,
27 const std::string& web_store_id, 29 const std::string& web_store_id,
28 const string16& app_name, 30 const string16& app_name,
29 const string16& object_type, 31 const string16& object_type,
30 bool is_primary_selector); 32 bool is_primary_selector);
31 ~DriveWebAppInfo(); 33 ~DriveWebAppInfo();
32 34
33 // Drive app id 35 // Drive app id
34 std::string app_id; 36 std::string app_id;
35 // Drive application icon URLs for this app, paired with their size (length of 37 // Drive application icon URLs for this app, paired with their size (length of
36 // a side in pixels). 38 // a side in pixels).
37 InstalledApp::IconList app_icons; 39 gdata::InstalledApp::IconList app_icons;
38 // Drive document icon URLs for this app, paired with their size (length of 40 // Drive document icon URLs for this app, paired with their size (length of
39 // a side in pixels). 41 // a side in pixels).
40 InstalledApp::IconList document_icons; 42 gdata::InstalledApp::IconList document_icons;
41 // Web store id/extension id; 43 // Web store id/extension id;
42 std::string web_store_id; 44 std::string web_store_id;
43 // WebApp name. 45 // WebApp name.
44 string16 app_name; 46 string16 app_name;
45 // Object (file) type description handled by this app. 47 // Object (file) type description handled by this app.
46 string16 object_type; 48 string16 object_type;
47 // Is app the primary selector for file (default open action). 49 // Is app the primary selector for file (default open action).
48 bool is_primary_selector; 50 bool is_primary_selector;
49 }; 51 };
50 52
51 // DriveWebAppsRegistry abstraction layer. 53 // DriveWebAppsRegistry abstraction layer.
52 // The interface is defined to make DriveWebAppsRegistry mockable. 54 // The interface is defined to make DriveWebAppsRegistry mockable.
53 class DriveWebAppsRegistryInterface { 55 class DriveWebAppsRegistryInterface {
54 public: 56 public:
55 virtual ~DriveWebAppsRegistryInterface() {} 57 virtual ~DriveWebAppsRegistryInterface() {}
56 58
57 // Gets the list of web |apps| matching |file| and its |mime_type|. 59 // Gets the list of web |apps| matching |file| and its |mime_type|.
58 virtual void GetWebAppsForFile(const FilePath& file, 60 virtual void GetWebAppsForFile(const FilePath& file,
59 const std::string& mime_type, 61 const std::string& mime_type,
60 ScopedVector<DriveWebAppInfo>* apps) = 0; 62 ScopedVector<DriveWebAppInfo>* apps) = 0;
61 63
62 // Returns a set of filename extensions registered for the given 64 // Returns a set of filename extensions registered for the given
63 // |web_store_id|. 65 // |web_store_id|.
64 virtual std::set<std::string> GetExtensionsForWebStoreApp( 66 virtual std::set<std::string> GetExtensionsForWebStoreApp(
65 const std::string& web_store_id) = 0; 67 const std::string& web_store_id) = 0;
66 68
67 // Updates the list of drive-enabled WebApps with freshly fetched account 69 // Updates the list of drive-enabled WebApps with freshly fetched account
68 // metadata feed. 70 // metadata feed.
69 virtual void UpdateFromFeed(const AccountMetadataFeed& metadata) = 0; 71 virtual void UpdateFromFeed(const gdata::AccountMetadataFeed& metadata) = 0;
70 72
71 // Updates the list of drive-enabled WebApps with freshly fetched account 73 // Updates the list of drive-enabled WebApps with freshly fetched account
72 // metadata feed. 74 // metadata feed.
73 virtual void UpdateFromApplicationList(const AppList& applist) = 0; 75 virtual void UpdateFromApplicationList(const gdata::AppList& applist) = 0;
74 }; 76 };
75 77
76 // The production implementation of DriveWebAppsRegistryInterface. 78 // The production implementation of DriveWebAppsRegistryInterface.
77 // Keeps the track of installed drive web application and provider. 79 // Keeps the track of installed drive web application and provider.
78 class DriveWebAppsRegistry : public DriveWebAppsRegistryInterface { 80 class DriveWebAppsRegistry : public DriveWebAppsRegistryInterface {
79 public: 81 public:
80 DriveWebAppsRegistry(); 82 DriveWebAppsRegistry();
81 virtual ~DriveWebAppsRegistry(); 83 virtual ~DriveWebAppsRegistry();
82 84
83 // DriveWebAppsRegistry overrides. 85 // DriveWebAppsRegistry overrides.
84 virtual void GetWebAppsForFile(const FilePath& file, 86 virtual void GetWebAppsForFile(const FilePath& file,
85 const std::string& mime_type, 87 const std::string& mime_type,
86 ScopedVector<DriveWebAppInfo>* apps) OVERRIDE; 88 ScopedVector<DriveWebAppInfo>* apps) OVERRIDE;
87 virtual std::set<std::string> GetExtensionsForWebStoreApp( 89 virtual std::set<std::string> GetExtensionsForWebStoreApp(
88 const std::string& web_store_id) OVERRIDE; 90 const std::string& web_store_id) OVERRIDE;
89 virtual void UpdateFromFeed(const AccountMetadataFeed& metadata) OVERRIDE; 91 virtual void UpdateFromFeed(
90 virtual void UpdateFromApplicationList(const AppList& applist) OVERRIDE; 92 const gdata::AccountMetadataFeed& metadata) OVERRIDE;
93 virtual void UpdateFromApplicationList(
94 const gdata::AppList& applist) OVERRIDE;
91 95
92 private: 96 private:
93 // Defines WebApp application details that are associated with a given 97 // Defines WebApp application details that are associated with a given
94 // file extension or content mimetype. 98 // file extension or content mimetype.
95 struct WebAppFileSelector { 99 struct WebAppFileSelector {
96 WebAppFileSelector(const GURL& product_link, 100 WebAppFileSelector(const GURL& product_link,
97 const InstalledApp::IconList& app_icons, 101 const gdata::InstalledApp::IconList& app_icons,
98 const InstalledApp::IconList& document_icons, 102 const gdata::InstalledApp::IconList& document_icons,
99 const string16& object_type, 103 const string16& object_type,
100 const std::string& app_id, 104 const std::string& app_id,
101 bool is_primary_selector); 105 bool is_primary_selector);
102 ~WebAppFileSelector(); 106 ~WebAppFileSelector();
103 // WebApp product link. 107 // WebApp product link.
104 GURL product_link; 108 GURL product_link;
105 // Drive application icon URLs for this app, paired with their size (length 109 // Drive application icon URLs for this app, paired with their size (length
106 // of a side in pixels). 110 // of a side in pixels).
107 InstalledApp::IconList app_icons; 111 gdata::InstalledApp::IconList app_icons;
108 // Drive document icon URLs for this app, paired with their size (length of 112 // Drive document icon URLs for this app, paired with their size (length of
109 // a side in pixels). 113 // a side in pixels).
110 InstalledApp::IconList document_icons; 114 gdata::InstalledApp::IconList document_icons;
111 // Object (file) type description. 115 // Object (file) type description.
112 string16 object_type; 116 string16 object_type;
113 // Drive app id 117 // Drive app id
114 std::string app_id; 118 std::string app_id;
115 // True if the selector is the default one. The default selector should 119 // True if the selector is the default one. The default selector should
116 // trigger on file double-click events. Non-default selectors only show up 120 // trigger on file double-click events. Non-default selectors only show up
117 // in "Open with..." pop-up menu. 121 // in "Open with..." pop-up menu.
118 bool is_primary_selector; 122 bool is_primary_selector;
119 }; 123 };
120 124
121 // Defines mapping between file content type selectors (extensions, MIME 125 // Defines mapping between file content type selectors (extensions, MIME
122 // types) and corresponding WebApp. 126 // types) and corresponding WebApp.
123 typedef std::multimap<std::string, WebAppFileSelector*> WebAppFileSelectorMap; 127 typedef std::multimap<std::string, WebAppFileSelector*> WebAppFileSelectorMap;
124 128
125 // Helper map used for deduplication of selector matching results. 129 // Helper map used for deduplication of selector matching results.
126 typedef std::map<const WebAppFileSelector*, 130 typedef std::map<const WebAppFileSelector*,
127 DriveWebAppInfo*> SelectorWebAppList; 131 DriveWebAppInfo*> SelectorWebAppList;
128 132
129 // Helper function for loading web application file |selectors| into 133 // Helper function for loading web application file |selectors| into
130 // corresponding |map|. 134 // corresponding |map|.
131 static void AddAppSelectorList(const GURL& product_link, 135 static void AddAppSelectorList(
132 const InstalledApp::IconList& app_icons, 136 const GURL& product_link,
133 const InstalledApp::IconList& document_icons, 137 const gdata::InstalledApp::IconList& app_icons,
134 const string16& object_type, 138 const gdata::InstalledApp::IconList& document_icons,
135 const std::string& app_id, 139 const string16& object_type,
136 bool is_primary_selector, 140 const std::string& app_id,
137 const ScopedVector<std::string>& selectors, 141 bool is_primary_selector,
138 WebAppFileSelectorMap* map); 142 const ScopedVector<std::string>& selectors,
143 WebAppFileSelectorMap* map);
139 144
140 // Finds matching |apps| from |map| based on provided file |selector|. 145 // Finds matching |apps| from |map| based on provided file |selector|.
141 void FindWebAppsForSelector(const std::string& selector, 146 void FindWebAppsForSelector(const std::string& selector,
142 const WebAppFileSelectorMap& map, 147 const WebAppFileSelectorMap& map,
143 SelectorWebAppList* apps); 148 SelectorWebAppList* apps);
144 149
145 // Map of web store product URL to application name. 150 // Map of web store product URL to application name.
146 std::map<GURL, string16> url_to_name_map_; 151 std::map<GURL, string16> url_to_name_map_;
147 152
148 // Map of filename extension to application info. 153 // Map of filename extension to application info.
149 WebAppFileSelectorMap webapp_extension_map_; 154 WebAppFileSelectorMap webapp_extension_map_;
150 155
151 // Map of MIME type to application info. 156 // Map of MIME type to application info.
152 WebAppFileSelectorMap webapp_mimetypes_map_; 157 WebAppFileSelectorMap webapp_mimetypes_map_;
153 158
154 DISALLOW_COPY_AND_ASSIGN(DriveWebAppsRegistry); 159 DISALLOW_COPY_AND_ASSIGN(DriveWebAppsRegistry);
155 }; 160 };
156 161
157 } // namespace gdata 162 } // namespace drive
158 163
159 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_WEBAPPS_REGISTRY_H_ 164 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_WEBAPPS_REGISTRY_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_uploader.cc ('k') | chrome/browser/chromeos/drive/drive_webapps_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698