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 #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" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 void WebIntentPickerModel::AddSuggestedExtensions( | 108 void WebIntentPickerModel::AddSuggestedExtensions( |
109 const std::vector<SuggestedExtension>& suggestions) { | 109 const std::vector<SuggestedExtension>& suggestions) { |
110 suggested_extensions_.insert(suggested_extensions_.end(), | 110 suggested_extensions_.insert(suggested_extensions_.end(), |
111 suggestions.begin(), | 111 suggestions.begin(), |
112 suggestions.end()); | 112 suggestions.end()); |
113 if (observer_) | 113 if (observer_) |
114 observer_->OnModelChanged(this); | 114 observer_->OnModelChanged(this); |
115 } | 115 } |
116 | 116 |
117 void WebIntentPickerModel::RemoveSuggestedExtension(const std::string& id) { | |
118 std::vector<SuggestedExtension>::iterator it; | |
119 for (it = suggested_extensions_.begin(); | |
120 it < suggested_extensions_.end(); | |
121 ++it) { | |
122 SuggestedExtension extension = *it; | |
123 if (extension.id == id) { | |
124 suggested_extensions_.erase(it); | |
125 break; | |
126 } | |
127 } | |
128 } | |
129 | |
130 const WebIntentPickerModel::SuggestedExtension& | 117 const WebIntentPickerModel::SuggestedExtension& |
131 WebIntentPickerModel::GetSuggestedExtensionAt(size_t index) const { | 118 WebIntentPickerModel::GetSuggestedExtensionAt(size_t index) const { |
132 DCHECK_LT(index, suggested_extensions_.size()); | 119 DCHECK_LT(index, suggested_extensions_.size()); |
133 return suggested_extensions_[index]; | 120 return suggested_extensions_[index]; |
134 } | 121 } |
135 | 122 |
136 const WebIntentPickerModel::SuggestedExtension* | 123 const WebIntentPickerModel::SuggestedExtension* |
137 WebIntentPickerModel::GetSuggestedExtensionWithId( | 124 WebIntentPickerModel::GetSuggestedExtensionWithId( |
138 const std::string& id) const { | 125 const std::string& id) const { |
139 for (size_t i = 0; i < suggested_extensions_.size(); ++i) { | 126 for (size_t i = 0; i < suggested_extensions_.size(); ++i) { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 double average_rating) | 265 double average_rating) |
279 : title(title), | 266 : title(title), |
280 id(id), | 267 id(id), |
281 average_rating(average_rating), | 268 average_rating(average_rating), |
282 icon(ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 269 icon(ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
283 IDR_DEFAULT_FAVICON)) { | 270 IDR_DEFAULT_FAVICON)) { |
284 } | 271 } |
285 | 272 |
286 WebIntentPickerModel::SuggestedExtension::~SuggestedExtension() { | 273 WebIntentPickerModel::SuggestedExtension::~SuggestedExtension() { |
287 } | 274 } |
OLD | NEW |