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

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

Issue 23608007: Remove drive::DriveAppRegistry::DriveAppFileSelector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_app_registry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_APP_REGISTRY_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_APP_REGISTRY_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_APP_REGISTRY_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_APP_REGISTRY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set>
10 #include <string> 9 #include <string>
10 #include <vector>
11 11
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "chrome/browser/google_apis/gdata_errorcode.h" 16 #include "chrome/browser/google_apis/gdata_errorcode.h"
17 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 17 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 namespace google_apis { 20 namespace google_apis {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 const std::string& mime_type, 69 const std::string& mime_type,
70 ScopedVector<DriveAppInfo>* apps) const; 70 ScopedVector<DriveAppInfo>* apps) const;
71 71
72 // Updates this registry by fetching the data from the server. 72 // Updates this registry by fetching the data from the server.
73 void Update(); 73 void Update();
74 74
75 // Updates this registry from the |app_list|. 75 // Updates this registry from the |app_list|.
76 void UpdateFromAppList(const google_apis::AppList& app_list); 76 void UpdateFromAppList(const google_apis::AppList& app_list);
77 77
78 private: 78 private:
79 // Defines application details that are associated with a given
80 // file extension or content mimetype.
81 struct DriveAppFileSelector {
82 DriveAppFileSelector(
83 const GURL& product_link,
84 const google_apis::InstalledApp::IconList& app_icons,
85 const google_apis::InstalledApp::IconList& document_icons,
86 const std::string& object_type,
87 const std::string& app_id,
88 bool is_primary_selector);
89 ~DriveAppFileSelector();
90 // Product link to the webstore.
91 GURL product_link;
92 // Drive application icon URLs for this app, paired with their size (length
93 // of a side in pixels).
94 google_apis::InstalledApp::IconList app_icons;
95 // Drive document icon URLs for this app, paired with their size (length of
96 // a side in pixels).
97 google_apis::InstalledApp::IconList document_icons;
98 // Object (file) type description.
99 std::string object_type;
100 // Drive app id
101 std::string app_id;
102 // True if the selector is the default one. The default selector should
103 // trigger on file double-click events. Non-default selectors only show up
104 // in "Open with..." pop-up menu.
105 bool is_primary_selector;
106 };
107 79
108 // Defines mapping between file content type selectors (extensions, MIME 80 // Defines mapping between file content type selectors (extensions, MIME
109 // types) and corresponding app. 81 // types) and corresponding app.
110 typedef std::multimap<std::string, 82 typedef std::multimap<std::string, DriveAppInfo*> DriveAppFileSelectorMap;
111 DriveAppFileSelector*> DriveAppFileSelectorMap;
112
113 // Helper map used for deduplication of selector matching results.
114 typedef std::map<const DriveAppFileSelector*,
115 DriveAppInfo*> SelectorAppList;
116 83
117 // Part of Update(). Runs upon the completion of fetching the Drive apps 84 // Part of Update(). Runs upon the completion of fetching the Drive apps
118 // data from the server. 85 // data from the server.
119 void UpdateAfterGetAppList(google_apis::GDataErrorCode gdata_error, 86 void UpdateAfterGetAppList(google_apis::GDataErrorCode gdata_error,
120 scoped_ptr<google_apis::AppList> app_list); 87 scoped_ptr<google_apis::AppList> app_list);
121 88
122 // Helper function for loading Drive application file |selectors| into 89 // Helper function for loading Drive application file |selectors| into
123 // corresponding |map|. 90 // corresponding |map|.
124 static void AddAppSelectorList( 91 static void AddAppSelectorList(
125 const GURL& product_link, 92 const std::string& web_store_id,
93 const std::string& app_name,
126 const google_apis::InstalledApp::IconList& app_icons, 94 const google_apis::InstalledApp::IconList& app_icons,
127 const google_apis::InstalledApp::IconList& document_icons, 95 const google_apis::InstalledApp::IconList& document_icons,
128 const std::string& object_type, 96 const std::string& object_type,
129 const std::string& app_id, 97 const std::string& app_id,
130 bool is_primary_selector, 98 bool is_primary_selector,
131 const ScopedVector<std::string>& selectors, 99 const ScopedVector<std::string>& selectors,
132 DriveAppFileSelectorMap* map); 100 DriveAppFileSelectorMap* map);
133 101
134 // Finds matching |apps| from |map| based on provided file |selector|. 102 // Finds matching |apps| from |map| based on provided file |selector|.
135 void FindAppsForSelector(const std::string& selector, 103 void FindAppsForSelector(const std::string& selector,
136 const DriveAppFileSelectorMap& map, 104 const DriveAppFileSelectorMap& map,
137 SelectorAppList* apps) const; 105 std::vector<DriveAppInfo*>* matched_apps) const;
138 106
139 JobScheduler* scheduler_; 107 JobScheduler* scheduler_;
140 108
141 // Map of web store product URL to application name.
142 std::map<GURL, std::string> url_to_name_map_;
143
144 // Map of filename extension to application info. 109 // Map of filename extension to application info.
145 DriveAppFileSelectorMap app_extension_map_; 110 DriveAppFileSelectorMap app_extension_map_;
146 111
147 // Map of MIME type to application info. 112 // Map of MIME type to application info.
148 DriveAppFileSelectorMap app_mimetypes_map_; 113 DriveAppFileSelectorMap app_mimetypes_map_;
149 114
150 bool is_updating_; 115 bool is_updating_;
151 116
152 // Note: This should remain the last member so it'll be destroyed and 117 // Note: This should remain the last member so it'll be destroyed and
153 // invalidate the weak pointers before any other members are destroyed. 118 // invalidate the weak pointers before any other members are destroyed.
(...skipping 12 matching lines...) Expand all
166 // Icons do not have to be sorted by the icon size. If there are no icons in 131 // Icons do not have to be sorted by the icon size. If there are no icons in
167 // the list, returns an empty URL. 132 // the list, returns an empty URL.
168 GURL FindPreferredIcon(const google_apis::InstalledApp::IconList& icons, 133 GURL FindPreferredIcon(const google_apis::InstalledApp::IconList& icons,
169 int preferred_size); 134 int preferred_size);
170 135
171 } // namespace util 136 } // namespace util
172 137
173 } // namespace drive 138 } // namespace drive
174 139
175 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_APP_REGISTRY_H_ 140 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_APP_REGISTRY_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_app_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698