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

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

Issue 10980002: Mac Web Intents Part 1: Show extension download progress (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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/ui/intents/web_intent_picker_model_observer.h" 11 #include "chrome/browser/ui/intents/web_intent_picker_model_observer.h"
12 #include "grit/generated_resources.h" 12 #include "grit/generated_resources.h"
13 #include "grit/ui_resources.h" 13 #include "grit/ui_resources.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/image/image.h" 16 #include "ui/gfx/image/image.h"
17 17
18 namespace { 18 namespace {
19 19
20 const size_t kMaxSuggestionCount = 5; // Maximum number of visible suggestions. 20 const size_t kMaxSuggestionCount = 5; // Maximum number of visible suggestions.
21 21
22 } // namespace 22 } // namespace
23 23
24 WebIntentPickerModel::WebIntentPickerModel() 24 WebIntentPickerModel::WebIntentPickerModel()
25 : observer_(NULL), 25 : observer_(NULL),
26 waiting_for_suggestions_(true), 26 waiting_for_suggestions_(true),
27 default_service_hash_(0) { 27 default_service_hash_(0),
28 pending_install_download_percent_(0) {
Steve McKay 2012/09/25 18:56:04 pending_install_download_percent_ > pending_instal
sail 2012/10/02 18:57:01 Done.
28 } 29 }
29 30
30 WebIntentPickerModel::~WebIntentPickerModel() { 31 WebIntentPickerModel::~WebIntentPickerModel() {
31 DestroyAll(); 32 DestroyAll();
32 } 33 }
33 34
34 void WebIntentPickerModel::AddInstalledService( 35 void WebIntentPickerModel::AddInstalledService(
35 const string16& title, 36 const string16& title,
36 const GURL& url, 37 const GURL& url,
37 webkit_glue::WebIntentServiceData::Disposition disposition) { 38 webkit_glue::WebIntentServiceData::Disposition disposition) {
(...skipping 17 matching lines...) Expand all
55 if (observer_) 56 if (observer_)
56 observer_->OnModelChanged(this); 57 observer_->OnModelChanged(this);
57 } 58 }
58 59
59 void WebIntentPickerModel::Clear() { 60 void WebIntentPickerModel::Clear() {
60 DestroyAll(); 61 DestroyAll();
61 action_.clear(); 62 action_.clear();
62 type_.clear(); 63 type_.clear();
63 inline_disposition_url_ = GURL::EmptyGURL(); 64 inline_disposition_url_ = GURL::EmptyGURL();
64 waiting_for_suggestions_ = true; 65 waiting_for_suggestions_ = true;
66 ClearPendingInstall();
Steve McKay 2012/09/25 18:56:04 There are a lot of things at play in the picker. I
sail 2012/10/02 18:57:01 Done. Updated all the other fields as well.
65 if (observer_) 67 if (observer_)
66 observer_->OnModelChanged(this); 68 observer_->OnModelChanged(this);
67 } 69 }
68 70
69 const WebIntentPickerModel::InstalledService& 71 const WebIntentPickerModel::InstalledService&
70 WebIntentPickerModel::GetInstalledServiceAt(size_t index) const { 72 WebIntentPickerModel::GetInstalledServiceAt(size_t index) const {
71 DCHECK_LT(index, installed_services_.size()); 73 DCHECK_LT(index, installed_services_.size());
72 return *installed_services_[index]; 74 return *installed_services_[index];
73 } 75 }
74 76
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 bool WebIntentPickerModel::IsWaitingForSuggestions() const { 155 bool WebIntentPickerModel::IsWaitingForSuggestions() const {
154 return waiting_for_suggestions_; 156 return waiting_for_suggestions_;
155 } 157 }
156 158
157 void WebIntentPickerModel::SetWaitingForSuggestions(bool waiting) { 159 void WebIntentPickerModel::SetWaitingForSuggestions(bool waiting) {
158 waiting_for_suggestions_ = waiting; 160 waiting_for_suggestions_ = waiting;
159 if (observer_) 161 if (observer_)
160 observer_->OnModelChanged(this); 162 observer_->OnModelChanged(this);
161 } 163 }
162 164
165 void WebIntentPickerModel::SetPendingInstallExtensionId(const std::string& id) {
166 pending_install_extension_id_ = id;
167 if (observer_)
168 observer_->OnModelChanged(this);
169 }
170
171 void WebIntentPickerModel::SetPendingInstallDownloadPercent(int percent) {
172 pending_install_download_percent_ = percent;
173 if (observer_)
174 observer_->OnModelChanged(this);
groby-ooo-7-16 2012/09/25 22:20:56 Pre your refactor, OnModelChanged used to trigger
sail 2012/10/02 18:57:01 Yea, it's really cheap now and I don't see any vis
175 }
176
177 void WebIntentPickerModel::SetPendingInstallStatusString(
178 const string16& status) {
179 pending_install_status_string_ = status;
180 if (observer_)
181 observer_->OnModelChanged(this);
182 }
183
184 void WebIntentPickerModel::ClearPendingInstall() {
185 pending_install_extension_id_.clear();
186 pending_install_download_percent_ = 0;
187 pending_install_status_string_.clear();
188 if (observer_)
189 observer_->OnModelChanged(this);
190 }
191
163 void WebIntentPickerModel::DestroyAll() { 192 void WebIntentPickerModel::DestroyAll() {
164 STLDeleteElements(&installed_services_); 193 STLDeleteElements(&installed_services_);
165 } 194 }
166 195
167 WebIntentPickerModel::InstalledService::InstalledService( 196 WebIntentPickerModel::InstalledService::InstalledService(
168 const string16& title, 197 const string16& title,
169 const GURL& url, 198 const GURL& url,
170 webkit_glue::WebIntentServiceData::Disposition disposition) 199 webkit_glue::WebIntentServiceData::Disposition disposition)
171 : title(title), 200 : title(title),
172 url(url), 201 url(url),
(...skipping 11 matching lines...) Expand all
184 double average_rating) 213 double average_rating)
185 : title(title), 214 : title(title),
186 id(id), 215 id(id),
187 average_rating(average_rating), 216 average_rating(average_rating),
188 icon(ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( 217 icon(ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
189 IDR_DEFAULT_FAVICON)) { 218 IDR_DEFAULT_FAVICON)) {
190 } 219 }
191 220
192 WebIntentPickerModel::SuggestedExtension::~SuggestedExtension() { 221 WebIntentPickerModel::SuggestedExtension::~SuggestedExtension() {
193 } 222 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698