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

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

Issue 133123004: Implement DriveAppRegistry::UninstallApp() and GetAppList(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix after revert 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 | « no previous file | chrome/browser/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 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 #ifndef CHROME_BROWSER_DRIVE_DRIVE_APP_REGISTRY_H_ 5 #ifndef CHROME_BROWSER_DRIVE_DRIVE_APP_REGISTRY_H_
6 #define CHROME_BROWSER_DRIVE_DRIVE_APP_REGISTRY_H_ 6 #define CHROME_BROWSER_DRIVE_DRIVE_APP_REGISTRY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback_forward.h"
12 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "google_apis/drive/gdata_errorcode.h" 16 #include "google_apis/drive/gdata_errorcode.h"
16 #include "google_apis/drive/gdata_wapi_parser.h" 17 #include "google_apis/drive/gdata_wapi_parser.h"
17 #include "url/gurl.h" 18 #include "url/gurl.h"
18 19
19 namespace google_apis { 20 namespace google_apis {
20 class AppList; 21 class AppList;
21 } // namespace google_apis 22 } // namespace google_apis
(...skipping 22 matching lines...) Expand all
44 // Drive document icon URLs for this app, paired with their size (length of 45 // Drive document icon URLs for this app, paired with their size (length of
45 // a side in pixels). 46 // a side in pixels).
46 google_apis::InstalledApp::IconList document_icons; 47 google_apis::InstalledApp::IconList document_icons;
47 // App name. 48 // App name.
48 std::string app_name; 49 std::string app_name;
49 // URL for opening a new file in the app. Empty if the app does not support 50 // URL for opening a new file in the app. Empty if the app does not support
50 // new file creation. 51 // new file creation.
51 GURL create_url; 52 GURL create_url;
52 }; 53 };
53 54
55 // Callback type for UninstallApp().
56 typedef base::Callback<void(google_apis::GDataErrorCode)> UninstallCallback;
57
54 // Keeps the track of installed drive applications in-memory. 58 // Keeps the track of installed drive applications in-memory.
55 class DriveAppRegistry { 59 class DriveAppRegistry {
56 public: 60 public:
57 explicit DriveAppRegistry(DriveServiceInterface* scheduler); 61 explicit DriveAppRegistry(DriveServiceInterface* scheduler);
58 ~DriveAppRegistry(); 62 ~DriveAppRegistry();
59 63
60 // Returns a list of Drive app information for the |file_extension| with 64 // Returns a list of Drive app information for the |file_extension| with
61 // |mime_type|. 65 // |mime_type|.
62 void GetAppsForFile(const base::FilePath::StringType& file_extension, 66 void GetAppsForFile(const base::FilePath::StringType& file_extension,
63 const std::string& mime_type, 67 const std::string& mime_type,
64 std::vector<DriveAppInfo>* apps) const; 68 std::vector<DriveAppInfo>* apps) const;
65 69
70 // Returns the list of all Drive apps installed.
71 void GetAppList(std::vector<DriveAppInfo>* apps) const;
72
73 // Uninstalls the app specified by |app_id|. This method sends requests to the
74 // remote server, and returns the result to |callback| asynchronously.
75 // |callback| must not be null.
76 void UninstallApp(const std::string& app_id,
77 const UninstallCallback& callback);
78
79 // Checks whether UinstallApp is supported. The feature is available only for
80 // clients with whitelisted API keys (like Official Google Chrome build).
81 static bool IsAppUninstallSupported();
82
66 // Updates this registry by fetching the data from the server. 83 // Updates this registry by fetching the data from the server.
67 void Update(); 84 void Update();
68 85
69 // Updates this registry from the |app_list|. 86 // Updates this registry from the |app_list|.
70 void UpdateFromAppList(const google_apis::AppList& app_list); 87 void UpdateFromAppList(const google_apis::AppList& app_list);
71 88
72 private: 89 private:
73 // Part of Update(). Runs upon the completion of fetching the Drive apps 90 // Part of Update(). Runs upon the completion of fetching the Drive apps
74 // data from the server. 91 // data from the server.
75 void UpdateAfterGetAppList(google_apis::GDataErrorCode gdata_error, 92 void UpdateAfterGetAppList(google_apis::GDataErrorCode gdata_error,
76 scoped_ptr<google_apis::AppList> app_list); 93 scoped_ptr<google_apis::AppList> app_list);
77 94
95 // Part of UninstallApp(). Receives the response from the server.
96 void OnAppUninstalled(const std::string& app_id,
97 const UninstallCallback& callback,
98 google_apis::GDataErrorCode error);
99
78 // Map of application id to each app's info. 100 // Map of application id to each app's info.
79 std::map<std::string, DriveAppInfo> all_apps_; 101 std::map<std::string, DriveAppInfo> all_apps_;
80 102
81 // Defines mapping between file content type selectors (extensions, MIME 103 // Defines mapping between file content type selectors (extensions, MIME
82 // types) and corresponding app. 104 // types) and corresponding app.
83 typedef std::multimap<std::string, std::string> DriveAppFileSelectorMap; 105 typedef std::multimap<std::string, std::string> DriveAppFileSelectorMap;
84 DriveAppFileSelectorMap extension_map_; 106 DriveAppFileSelectorMap extension_map_;
85 DriveAppFileSelectorMap mimetype_map_; 107 DriveAppFileSelectorMap mimetype_map_;
86 108
87 DriveServiceInterface* drive_service_; 109 DriveServiceInterface* drive_service_;
(...skipping 17 matching lines...) Expand all
105 // Icons do not have to be sorted by the icon size. If there are no icons in 127 // Icons do not have to be sorted by the icon size. If there are no icons in
106 // the list, returns an empty URL. 128 // the list, returns an empty URL.
107 GURL FindPreferredIcon(const google_apis::InstalledApp::IconList& icons, 129 GURL FindPreferredIcon(const google_apis::InstalledApp::IconList& icons,
108 int preferred_size); 130 int preferred_size);
109 131
110 } // namespace util 132 } // namespace util
111 133
112 } // namespace drive 134 } // namespace drive
113 135
114 #endif // CHROME_BROWSER_DRIVE_DRIVE_APP_REGISTRY_H_ 136 #endif // CHROME_BROWSER_DRIVE_DRIVE_APP_REGISTRY_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/drive/drive_app_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698