| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/app_list/app_list_item.h" | 5 #include "ui/app_list/app_list_item.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/app_list/app_list_item_observer.h" | 8 #include "ui/app_list/app_list_item_observer.h" |
| 9 | 9 |
| 10 namespace app_list { | 10 namespace app_list { |
| 11 | 11 |
| 12 AppListItem::AppListItem(const std::string& id) | 12 AppListItem::AppListItem(const std::string& id) |
| 13 : id_(id), | 13 : id_(id), |
| 14 highlighted_(false), | 14 highlighted_(false), |
| 15 is_installing_(false), | 15 is_installing_(false), |
| 16 percent_downloaded_(-1) { | 16 percent_downloaded_(-1) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 AppListItem::~AppListItem() { | 19 AppListItem::~AppListItem() { |
| 20 FOR_EACH_OBSERVER(AppListItemObserver, observers_, ItemBeingDestroyed()); | 20 for (auto& observer : observers_) |
| 21 observer.ItemBeingDestroyed(); |
| 21 } | 22 } |
| 22 | 23 |
| 23 void AppListItem::SetIcon(const gfx::ImageSkia& icon) { | 24 void AppListItem::SetIcon(const gfx::ImageSkia& icon) { |
| 24 icon_ = icon; | 25 icon_ = icon; |
| 25 FOR_EACH_OBSERVER(AppListItemObserver, observers_, ItemIconChanged()); | 26 for (auto& observer : observers_) |
| 27 observer.ItemIconChanged(); |
| 26 } | 28 } |
| 27 | 29 |
| 28 void AppListItem::SetIsInstalling(bool is_installing) { | 30 void AppListItem::SetIsInstalling(bool is_installing) { |
| 29 if (is_installing_ == is_installing) | 31 if (is_installing_ == is_installing) |
| 30 return; | 32 return; |
| 31 | 33 |
| 32 is_installing_ = is_installing; | 34 is_installing_ = is_installing; |
| 33 FOR_EACH_OBSERVER(AppListItemObserver, | 35 for (auto& observer : observers_) |
| 34 observers_, | 36 observer.ItemIsInstallingChanged(); |
| 35 ItemIsInstallingChanged()); | |
| 36 } | 37 } |
| 37 | 38 |
| 38 void AppListItem::SetPercentDownloaded(int percent_downloaded) { | 39 void AppListItem::SetPercentDownloaded(int percent_downloaded) { |
| 39 if (percent_downloaded_ == percent_downloaded) | 40 if (percent_downloaded_ == percent_downloaded) |
| 40 return; | 41 return; |
| 41 | 42 |
| 42 percent_downloaded_ = percent_downloaded; | 43 percent_downloaded_ = percent_downloaded; |
| 43 FOR_EACH_OBSERVER(AppListItemObserver, | 44 for (auto& observer : observers_) |
| 44 observers_, | 45 observer.ItemPercentDownloadedChanged(); |
| 45 ItemPercentDownloadedChanged()); | |
| 46 } | 46 } |
| 47 | 47 |
| 48 void AppListItem::AddObserver(AppListItemObserver* observer) { | 48 void AppListItem::AddObserver(AppListItemObserver* observer) { |
| 49 observers_.AddObserver(observer); | 49 observers_.AddObserver(observer); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void AppListItem::RemoveObserver(AppListItemObserver* observer) { | 52 void AppListItem::RemoveObserver(AppListItemObserver* observer) { |
| 53 observers_.RemoveObserver(observer); | 53 observers_.RemoveObserver(observer); |
| 54 } | 54 } |
| 55 | 55 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 + " [" + position_.ToDebugString() + "]"; | 89 + " [" + position_.ToDebugString() + "]"; |
| 90 } | 90 } |
| 91 | 91 |
| 92 // Protected methods | 92 // Protected methods |
| 93 | 93 |
| 94 void AppListItem::SetName(const std::string& name) { | 94 void AppListItem::SetName(const std::string& name) { |
| 95 if (name_ == name && (short_name_.empty() || short_name_ == name)) | 95 if (name_ == name && (short_name_.empty() || short_name_ == name)) |
| 96 return; | 96 return; |
| 97 name_ = name; | 97 name_ = name; |
| 98 short_name_.clear(); | 98 short_name_.clear(); |
| 99 FOR_EACH_OBSERVER(AppListItemObserver, observers_, ItemNameChanged()); | 99 for (auto& observer : observers_) |
| 100 observer.ItemNameChanged(); |
| 100 } | 101 } |
| 101 | 102 |
| 102 void AppListItem::SetNameAndShortName(const std::string& name, | 103 void AppListItem::SetNameAndShortName(const std::string& name, |
| 103 const std::string& short_name) { | 104 const std::string& short_name) { |
| 104 if (name_ == name && short_name_ == short_name) | 105 if (name_ == name && short_name_ == short_name) |
| 105 return; | 106 return; |
| 106 name_ = name; | 107 name_ = name; |
| 107 short_name_ = short_name; | 108 short_name_ = short_name; |
| 108 FOR_EACH_OBSERVER(AppListItemObserver, observers_, ItemNameChanged()); | 109 for (auto& observer : observers_) |
| 110 observer.ItemNameChanged(); |
| 109 } | 111 } |
| 110 | 112 |
| 111 } // namespace app_list | 113 } // namespace app_list |
| OLD | NEW |