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

Side by Side Diff: chrome/browser/drive/drive_app_registry.cc

Issue 140783006: drive: Support authorizing third-party Drive apps for opening files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | « chrome/browser/drive/drive_api_service.cc ('k') | google_apis/drive/drive_api_requests.h » ('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 2014 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/drive/drive_app_registry.h" 5 #include "chrome/browser/drive/drive_app_registry.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "chrome/browser/drive/drive_service_interface.h" 13 #include "chrome/browser/drive/drive_service_interface.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "google_apis/drive/drive_api_parser.h" 15 #include "google_apis/drive/drive_api_parser.h"
16 #include "google_apis/google_api_keys.h"
16 17
17 using content::BrowserThread; 18 using content::BrowserThread;
18 19
19 namespace { 20 namespace {
20 21
21 // Add {selector -> app_id} mapping to |map|. 22 // Add {selector -> app_id} mapping to |map|.
22 void AddAppSelectorList(const ScopedVector<std::string>& selectors, 23 void AddAppSelectorList(const ScopedVector<std::string>& selectors,
23 const std::string& app_id, 24 const std::string& app_id,
24 std::multimap<std::string, std::string>* map) { 25 std::multimap<std::string, std::string>* map) {
25 for (size_t i = 0; i < selectors.size(); ++i) 26 for (size_t i = 0; i < selectors.size(); ++i)
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 if (error == google_apis::HTTP_NO_CONTENT) { 199 if (error == google_apis::HTTP_NO_CONTENT) {
199 all_apps_.erase(app_id); 200 all_apps_.erase(app_id);
200 RemoveAppFromSelector(app_id, &mimetype_map_); 201 RemoveAppFromSelector(app_id, &mimetype_map_);
201 RemoveAppFromSelector(app_id, &extension_map_); 202 RemoveAppFromSelector(app_id, &extension_map_);
202 } 203 }
203 callback.Run(error); 204 callback.Run(error);
204 } 205 }
205 206
206 // static 207 // static
207 bool DriveAppRegistry::IsAppUninstallSupported() { 208 bool DriveAppRegistry::IsAppUninstallSupported() {
208 #ifdef USE_OFFICIAL_GOOGLE_API_KEYS 209 return google_apis::IsGoogleChromeAPIKeyUsed();
209 return true;
210 #else
211 return false;
212 #endif
213 } 210 }
214 211
215 namespace util { 212 namespace util {
216 213
217 GURL FindPreferredIcon(const google_apis::InstalledApp::IconList& icons, 214 GURL FindPreferredIcon(const google_apis::InstalledApp::IconList& icons,
218 int preferred_size) { 215 int preferred_size) {
219 if (icons.empty()) 216 if (icons.empty())
220 return GURL(); 217 return GURL();
221 218
222 google_apis::InstalledApp::IconList sorted_icons = icons; 219 google_apis::InstalledApp::IconList sorted_icons = icons;
223 std::sort(sorted_icons.rbegin(), sorted_icons.rend()); 220 std::sort(sorted_icons.rbegin(), sorted_icons.rend());
224 221
225 // Go forward while the size is larger or equal to preferred_size. 222 // Go forward while the size is larger or equal to preferred_size.
226 size_t i = 1; 223 size_t i = 1;
227 while (i < sorted_icons.size() && sorted_icons[i].first >= preferred_size) 224 while (i < sorted_icons.size() && sorted_icons[i].first >= preferred_size)
228 ++i; 225 ++i;
229 return sorted_icons[i - 1].second; 226 return sorted_icons[i - 1].second;
230 } 227 }
231 228
232 } // namespace util 229 } // namespace util
233 } // namespace drive 230 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/drive/drive_api_service.cc ('k') | google_apis/drive/drive_api_requests.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698