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

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: fix merge 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
« no previous file with comments | « chrome/browser/ui/intents/web_intent_picker_model.h ('k') | no next file » | 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 #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 pending_extension_install_download_progress_(0) { 29 pending_extension_install_download_progress_(0),
30 pending_extension_install_delegate_(NULL) {
30 } 31 }
31 32
32 WebIntentPickerModel::~WebIntentPickerModel() { 33 WebIntentPickerModel::~WebIntentPickerModel() {
33 DestroyAll(); 34 DestroyAll();
34 } 35 }
35 36
36 void WebIntentPickerModel::AddInstalledService( 37 void WebIntentPickerModel::AddInstalledService(
37 const string16& title, 38 const string16& title,
38 const GURL& url, 39 const GURL& url,
39 webkit_glue::WebIntentServiceData::Disposition disposition) { 40 webkit_glue::WebIntentServiceData::Disposition disposition) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 observer_->OnModelChanged(this); 202 observer_->OnModelChanged(this);
202 } 203 }
203 204
204 void WebIntentPickerModel::SetPendingExtensionInstallStatusString( 205 void WebIntentPickerModel::SetPendingExtensionInstallStatusString(
205 const string16& status) { 206 const string16& status) {
206 pending_extension_install_status_string_ = status; 207 pending_extension_install_status_string_ = status;
207 if (observer_) 208 if (observer_)
208 observer_->OnModelChanged(this); 209 observer_->OnModelChanged(this);
209 } 210 }
210 211
212 void WebIntentPickerModel::SetPendingExtensionInstallDelegate(
213 ExtensionInstallPrompt::Delegate* delegate) {
214 pending_extension_install_delegate_ = delegate;
215 if (observer_)
216 observer_->OnModelChanged(this);
217 }
218
219 void WebIntentPickerModel::SetPendingExtensionInstallPrompt(
220 const ExtensionInstallPrompt::Prompt& prompt) {
221 pending_extension_install_prompt_.reset(
222 new ExtensionInstallPrompt::Prompt(prompt));
223 if (observer_)
224 observer_->OnModelChanged(this);
225 }
226
211 void WebIntentPickerModel::ClearPendingExtensionInstall() { 227 void WebIntentPickerModel::ClearPendingExtensionInstall() {
212 pending_extension_install_id_.clear(); 228 pending_extension_install_id_.clear();
213 pending_extension_install_download_progress_ = 0; 229 pending_extension_install_download_progress_ = 0;
214 pending_extension_install_status_string_.clear(); 230 pending_extension_install_status_string_.clear();
231 pending_extension_install_delegate_ = NULL;
232 pending_extension_install_prompt_.reset();
215 if (observer_) 233 if (observer_)
216 observer_->OnModelChanged(this); 234 observer_->OnModelChanged(this);
217 } 235 }
218 236
219 void WebIntentPickerModel::DestroyAll() { 237 void WebIntentPickerModel::DestroyAll() {
220 STLDeleteElements(&installed_services_); 238 STLDeleteElements(&installed_services_);
221 } 239 }
222 240
223 WebIntentPickerModel::InstalledService::InstalledService( 241 WebIntentPickerModel::InstalledService::InstalledService(
224 const string16& title, 242 const string16& title,
(...skipping 15 matching lines...) Expand all
240 double average_rating) 258 double average_rating)
241 : title(title), 259 : title(title),
242 id(id), 260 id(id),
243 average_rating(average_rating), 261 average_rating(average_rating),
244 icon(ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( 262 icon(ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
245 IDR_DEFAULT_FAVICON)) { 263 IDR_DEFAULT_FAVICON)) {
246 } 264 }
247 265
248 WebIntentPickerModel::SuggestedExtension::~SuggestedExtension() { 266 WebIntentPickerModel::SuggestedExtension::~SuggestedExtension() {
249 } 267 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/intents/web_intent_picker_model.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698