OLD | NEW |
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_UI_INTENTS_WEB_INTENT_PICKER_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_MODEL_H_ |
6 #define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_MODEL_H_ | 6 #define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_MODEL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
13 #include "ui/gfx/image/image.h" | 13 #include "ui/gfx/image/image.h" |
14 #include "webkit/glue/web_intent_service_data.h" | 14 #include "webkit/glue/web_intent_service_data.h" |
15 | 15 |
| 16 namespace content { |
| 17 class DownloadItem; |
| 18 } |
| 19 |
16 class WebIntentPickerModelObserver; | 20 class WebIntentPickerModelObserver; |
17 | 21 |
18 // Model for the WebIntentPicker. | 22 // Model for the WebIntentPicker. |
19 class WebIntentPickerModel { | 23 class WebIntentPickerModel { |
20 public: | 24 public: |
21 // An intent service to display in the picker. | 25 // An intent service to display in the picker. |
22 struct InstalledService { | 26 struct InstalledService { |
23 InstalledService( | 27 InstalledService( |
24 const string16& title, | 28 const string16& title, |
25 const GURL& url, | 29 const GURL& url, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // Returns true if there is still a pending request for suggestions from CWS. | 140 // Returns true if there is still a pending request for suggestions from CWS. |
137 bool IsWaitingForSuggestions() const; | 141 bool IsWaitingForSuggestions() const; |
138 | 142 |
139 // Set the "waiting for suggestions" status to |waiting| | 143 // Set the "waiting for suggestions" status to |waiting| |
140 void SetWaitingForSuggestions(bool waiting); | 144 void SetWaitingForSuggestions(bool waiting); |
141 | 145 |
142 // Returns the url of the intent service that is being displayed inline, or | 146 // Returns the url of the intent service that is being displayed inline, or |
143 // GURL::EmptyGURL() if none. | 147 // GURL::EmptyGURL() if none. |
144 const GURL& inline_disposition_url() const { return inline_disposition_url_; } | 148 const GURL& inline_disposition_url() const { return inline_disposition_url_; } |
145 | 149 |
| 150 // Sets the ID of the extension currently being installed. |
| 151 void SetPendingExtensionInstallId(const std::string& id); |
| 152 |
| 153 // Gets the ID of the extension currently being installed. |
| 154 const std::string& pending_extension_install_id() const { |
| 155 return pending_extension_install_id_; |
| 156 } |
| 157 |
| 158 // Updates the pending install download state. |
| 159 void UpdateExtensionDownloadState(content::DownloadItem* item); |
| 160 |
| 161 // Sets the download progress of the extension currently being downloaded. |
| 162 void SetPendingExtensionInstallDownloadProgress(int progress); |
| 163 |
| 164 // Gets the download progress of the extension currently being downloaded. |
| 165 // Returns -1 if progress is indeterminate, otherwise a value from 0 to 100. |
| 166 int pending_extension_install_download_progress() const { |
| 167 return pending_extension_install_download_progress_; |
| 168 } |
| 169 |
| 170 // Sets the status of extension install process. |
| 171 void SetPendingExtensionInstallStatusString(const string16& status); |
| 172 |
| 173 // Gets the status of extension install process. |
| 174 const string16& pending_extension_install_status_string() const { |
| 175 return pending_extension_install_status_string_; |
| 176 } |
| 177 |
| 178 // Removes any pending extension install state. |
| 179 void ClearPendingExtensionInstall(); |
| 180 |
146 private: | 181 private: |
147 // Delete all elements in |installed_services_| and |suggested_extensions_|. | 182 // Delete all elements in |installed_services_| and |suggested_extensions_|. |
148 // Note that this method does not reset the observer. | 183 // Note that this method does not reset the observer. |
149 void DestroyAll(); | 184 void DestroyAll(); |
150 | 185 |
151 // A vector of all installed services in the picker. Each installed service | 186 // A vector of all installed services in the picker. Each installed service |
152 // is owned by this model. | 187 // is owned by this model. |
153 std::vector<InstalledService*> installed_services_; | 188 std::vector<InstalledService*> installed_services_; |
154 | 189 |
155 // A vector of all suggested extensions in the picker. | 190 // A vector of all suggested extensions in the picker. |
(...skipping 15 matching lines...) Expand all Loading... |
171 // The non-empty url of the default service if the WebIntentsRegistry | 206 // The non-empty url of the default service if the WebIntentsRegistry |
172 // finds a default service matching the intent being dispatched. | 207 // finds a default service matching the intent being dispatched. |
173 GURL default_service_url_; | 208 GURL default_service_url_; |
174 | 209 |
175 // Indicates that there are still open requests to CWS. | 210 // Indicates that there are still open requests to CWS. |
176 bool waiting_for_suggestions_; | 211 bool waiting_for_suggestions_; |
177 | 212 |
178 // The hash context for the default service, if there is one. | 213 // The hash context for the default service, if there is one. |
179 int64 default_service_hash_; | 214 int64 default_service_hash_; |
180 | 215 |
| 216 // Information about the pending extension install. |
| 217 std::string pending_extension_install_id_; |
| 218 int pending_extension_install_download_progress_; |
| 219 string16 pending_extension_install_status_string_; |
| 220 |
181 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerModel); | 221 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerModel); |
182 }; | 222 }; |
183 | 223 |
184 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_MODEL_H_ | 224 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_MODEL_H_ |
OLD | NEW |