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

Side by Side Diff: chrome/browser/ui/intents/web_intent_picker_model.cc

Issue 11035017: Mac Web Intents Part 15: Inline extension install prompt (model) (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 #include "chrome/browser/ui/intents/web_intent_picker_model.h" 5 #include "chrome/browser/ui/intents/web_intent_picker_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "chrome/browser/download/download_item_model.h" 11 #include "chrome/browser/download/download_item_model.h"
12 #include "chrome/browser/ui/intents/web_intent_picker_model_observer.h" 12 #include "chrome/browser/ui/intents/web_intent_picker_model_observer.h"
13 #include "content/public/browser/download_item.h" 13 #include "content/public/browser/download_item.h"
14 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
15 #include "grit/ui_resources.h" 15 #include "grit/ui_resources.h"
16 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/gfx/image/image.h" 18 #include "ui/gfx/image/image.h"
19 19
20 namespace { 20 namespace {
21 21
22 const size_t kMaxSuggestionCount = 5; // Maximum number of visible suggestions. 22 const size_t kMaxSuggestionCount = 5; // Maximum number of visible suggestions.
23 23
24 } // namespace 24 } // namespace
25 25
26 WebIntentPickerModel::WebIntentPickerModel() 26 WebIntentPickerModel::WebIntentPickerModel()
27 : observer_(NULL), 27 : observer_(NULL),
28 waiting_for_suggestions_(true), 28 waiting_for_suggestions_(true),
29 default_service_hash_(0), 29 default_service_hash_(0),
30 pending_extension_install_download_progress_(0) { 30 pending_extension_install_download_progress_(0),
31 pending_extension_install_prompt_(NULL) {
31 } 32 }
32 33
33 WebIntentPickerModel::~WebIntentPickerModel() { 34 WebIntentPickerModel::~WebIntentPickerModel() {
34 DestroyAll(); 35 DestroyAll();
35 } 36 }
36 37
37 void WebIntentPickerModel::AddInstalledService( 38 void WebIntentPickerModel::AddInstalledService(
38 const string16& title, 39 const string16& title,
39 const GURL& url, 40 const GURL& url,
40 webkit_glue::WebIntentServiceData::Disposition disposition) { 41 webkit_glue::WebIntentServiceData::Disposition disposition) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 observer_->OnModelChanged(this); 203 observer_->OnModelChanged(this);
203 } 204 }
204 205
205 void WebIntentPickerModel::SetPendingExtensionInstallStatusString( 206 void WebIntentPickerModel::SetPendingExtensionInstallStatusString(
206 const string16& status) { 207 const string16& status) {
207 pending_extension_install_status_string_ = status; 208 pending_extension_install_status_string_ = status;
208 if (observer_) 209 if (observer_)
209 observer_->OnModelChanged(this); 210 observer_->OnModelChanged(this);
210 } 211 }
211 212
213 void WebIntentPickerModel::SetPendingExtensionInstallDelegate(
214 ExtensionInstallPrompt::Delegate* delegate) {
215 pending_extension_install_delegate_ = delegate;
216 if (observer_)
217 observer_->OnModelChanged(this);
218 }
219
220 void WebIntentPickerModel::SetPendingExtensionInstallPrompt(
221 const ExtensionInstallPrompt::Prompt& prompt) {
222 pending_extension_install_prompt_.reset(
223 new ExtensionInstallPrompt::Prompt(prompt));
224 if (observer_)
225 observer_->OnModelChanged(this);
226 }
227
212 void WebIntentPickerModel::ClearPendingExtensionInstall() { 228 void WebIntentPickerModel::ClearPendingExtensionInstall() {
213 pending_extension_install_id_.clear(); 229 pending_extension_install_id_.clear();
214 pending_extension_install_download_progress_ = 0; 230 pending_extension_install_download_progress_ = 0;
215 pending_extension_install_status_string_.clear(); 231 pending_extension_install_status_string_.clear();
232 pending_extension_install_delegate_ = NULL;
233 pending_extension_install_prompt_.reset();
216 if (observer_) 234 if (observer_)
217 observer_->OnModelChanged(this); 235 observer_->OnModelChanged(this);
218 } 236 }
219 237
220 void WebIntentPickerModel::DestroyAll() { 238 void WebIntentPickerModel::DestroyAll() {
221 STLDeleteElements(&installed_services_); 239 STLDeleteElements(&installed_services_);
222 } 240 }
223 241
224 WebIntentPickerModel::InstalledService::InstalledService( 242 WebIntentPickerModel::InstalledService::InstalledService(
225 const string16& title, 243 const string16& title,
(...skipping 15 matching lines...) Expand all
241 double average_rating) 259 double average_rating)
242 : title(title), 260 : title(title),
243 id(id), 261 id(id),
244 average_rating(average_rating), 262 average_rating(average_rating),
245 icon(ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( 263 icon(ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
246 IDR_DEFAULT_FAVICON)) { 264 IDR_DEFAULT_FAVICON)) {
247 } 265 }
248 266
249 WebIntentPickerModel::SuggestedExtension::~SuggestedExtension() { 267 WebIntentPickerModel::SuggestedExtension::~SuggestedExtension() {
250 } 268 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698