| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 void WebIntentPickerModel::AddSuggestedExtensions( | 102 void WebIntentPickerModel::AddSuggestedExtensions( |
| 103 const std::vector<SuggestedExtension>& suggestions) { | 103 const std::vector<SuggestedExtension>& suggestions) { |
| 104 suggested_extensions_.insert(suggested_extensions_.end(), | 104 suggested_extensions_.insert(suggested_extensions_.end(), |
| 105 suggestions.begin(), | 105 suggestions.begin(), |
| 106 suggestions.end()); | 106 suggestions.end()); |
| 107 if (observer_) | 107 if (observer_) |
| 108 observer_->OnModelChanged(this); | 108 observer_->OnModelChanged(this); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void WebIntentPickerModel::RemoveSuggestedExtension(const std::string& id) { |
| 112 std::vector<SuggestedExtension>::iterator it; |
| 113 for (it = suggested_extensions_.begin(); |
| 114 it < suggested_extensions_.end(); |
| 115 ++it) { |
| 116 SuggestedExtension extension = *it; |
| 117 if (extension.id == id) { |
| 118 suggested_extensions_.erase(it); |
| 119 break; |
| 120 } |
| 121 } |
| 122 } |
| 123 |
| 111 const WebIntentPickerModel::SuggestedExtension& | 124 const WebIntentPickerModel::SuggestedExtension& |
| 112 WebIntentPickerModel::GetSuggestedExtensionAt(size_t index) const { | 125 WebIntentPickerModel::GetSuggestedExtensionAt(size_t index) const { |
| 113 DCHECK_LT(index, suggested_extensions_.size()); | 126 DCHECK_LT(index, suggested_extensions_.size()); |
| 114 return suggested_extensions_[index]; | 127 return suggested_extensions_[index]; |
| 115 } | 128 } |
| 116 | 129 |
| 117 const WebIntentPickerModel::SuggestedExtension* | 130 const WebIntentPickerModel::SuggestedExtension* |
| 118 WebIntentPickerModel::GetSuggestedExtensionWithId( | 131 WebIntentPickerModel::GetSuggestedExtensionWithId( |
| 119 const std::string& id) const { | 132 const std::string& id) const { |
| 120 for (size_t i = 0; i < suggested_extensions_.size(); ++i) { | 133 for (size_t i = 0; i < suggested_extensions_.size(); ++i) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 double average_rating) | 272 double average_rating) |
| 260 : title(title), | 273 : title(title), |
| 261 id(id), | 274 id(id), |
| 262 average_rating(average_rating), | 275 average_rating(average_rating), |
| 263 icon(ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 276 icon(ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
| 264 IDR_DEFAULT_FAVICON)) { | 277 IDR_DEFAULT_FAVICON)) { |
| 265 } | 278 } |
| 266 | 279 |
| 267 WebIntentPickerModel::SuggestedExtension::~SuggestedExtension() { | 280 WebIntentPickerModel::SuggestedExtension::~SuggestedExtension() { |
| 268 } | 281 } |
| OLD | NEW |