Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / app_list / app_list_item.cc
blobd0daa271c7a708dc758e9bf837f8ff34e1054dc6
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
3 // found in the LICENSE file.
5 #include "ui/app_list/app_list_item.h"
7 #include "base/logging.h"
8 #include "ui/app_list/app_list_item_observer.h"
10 namespace app_list {
12 AppListItem::AppListItem(const std::string& id)
13 : id_(id),
14 highlighted_(false),
15 is_installing_(false),
16 percent_downloaded_(-1) {
19 AppListItem::~AppListItem() {
20 FOR_EACH_OBSERVER(AppListItemObserver, observers_, ItemBeingDestroyed());
23 void AppListItem::SetIcon(const gfx::ImageSkia& icon) {
24 icon_ = icon;
25 FOR_EACH_OBSERVER(AppListItemObserver, observers_, ItemIconChanged());
28 void AppListItem::SetIsInstalling(bool is_installing) {
29 if (is_installing_ == is_installing)
30 return;
32 is_installing_ = is_installing;
33 FOR_EACH_OBSERVER(AppListItemObserver,
34 observers_,
35 ItemIsInstallingChanged());
38 void AppListItem::SetPercentDownloaded(int percent_downloaded) {
39 if (percent_downloaded_ == percent_downloaded)
40 return;
42 percent_downloaded_ = percent_downloaded;
43 FOR_EACH_OBSERVER(AppListItemObserver,
44 observers_,
45 ItemPercentDownloadedChanged());
48 void AppListItem::AddObserver(AppListItemObserver* observer) {
49 observers_.AddObserver(observer);
52 void AppListItem::RemoveObserver(AppListItemObserver* observer) {
53 observers_.RemoveObserver(observer);
56 void AppListItem::Activate(int event_flags) {
59 const char* AppListItem::GetItemType() const {
60 static const char* app_type = "";
61 return app_type;
64 ui::MenuModel* AppListItem::GetContextMenuModel() {
65 return NULL;
68 AppListItem* AppListItem::FindChildItem(const std::string& id) {
69 return NULL;
72 size_t AppListItem::ChildItemCount() const {
73 return 0;
76 void AppListItem::OnExtensionPreferenceChanged() {}
78 bool AppListItem::CompareForTest(const AppListItem* other) const {
79 return id_ == other->id_ &&
80 folder_id_ == other->folder_id_ &&
81 name_ == other->name_ &&
82 short_name_ == other->short_name_ &&
83 GetItemType() == other->GetItemType() &&
84 position_.Equals(other->position_);
87 std::string AppListItem::ToDebugString() const {
88 return id_.substr(0, 8) + " '" + name_ + "'"
89 + " [" + position_.ToDebugString() + "]";
92 // Protected methods
94 void AppListItem::SetName(const std::string& name) {
95 if (name_ == name && (short_name_.empty() || short_name_ == name))
96 return;
97 name_ = name;
98 short_name_.clear();
99 FOR_EACH_OBSERVER(AppListItemObserver, observers_, ItemNameChanged());
102 void AppListItem::SetNameAndShortName(const std::string& name,
103 const std::string& short_name) {
104 if (name_ == name && short_name_ == short_name)
105 return;
106 name_ = name;
107 short_name_ = short_name;
108 FOR_EACH_OBSERVER(AppListItemObserver, observers_, ItemNameChanged());
111 } // namespace app_list