Add Flex to views::BoxLayout.
[chromium-blink-merge.git] / ui / app_list / app_list_item.cc
blobcbb6f864e013c6a022fd0c02163eb18b3f8fe0bb
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 has_shadow_(false),
15 highlighted_(false),
16 is_installing_(false),
17 percent_downloaded_(-1) {
20 AppListItem::~AppListItem() {
23 void AppListItem::SetIcon(const gfx::ImageSkia& icon, bool has_shadow) {
24 icon_ = icon;
25 has_shadow_ = has_shadow;
26 FOR_EACH_OBSERVER(AppListItemObserver, observers_, ItemIconChanged());
29 void AppListItem::SetHighlighted(bool highlighted) {
30 if (highlighted_ == highlighted)
31 return;
33 highlighted_ = highlighted;
34 FOR_EACH_OBSERVER(AppListItemObserver,
35 observers_,
36 ItemHighlightedChanged());
39 void AppListItem::SetIsInstalling(bool is_installing) {
40 if (is_installing_ == is_installing)
41 return;
43 is_installing_ = is_installing;
44 FOR_EACH_OBSERVER(AppListItemObserver,
45 observers_,
46 ItemIsInstallingChanged());
49 void AppListItem::SetPercentDownloaded(int percent_downloaded) {
50 if (percent_downloaded_ == percent_downloaded)
51 return;
53 percent_downloaded_ = percent_downloaded;
54 FOR_EACH_OBSERVER(AppListItemObserver,
55 observers_,
56 ItemPercentDownloadedChanged());
59 void AppListItem::AddObserver(AppListItemObserver* observer) {
60 observers_.AddObserver(observer);
63 void AppListItem::RemoveObserver(AppListItemObserver* observer) {
64 observers_.RemoveObserver(observer);
67 void AppListItem::Activate(int event_flags) {
70 const char* AppListItem::GetItemType() const {
71 static const char* app_type = "";
72 return app_type;
75 ui::MenuModel* AppListItem::GetContextMenuModel() {
76 return NULL;
79 AppListItem* AppListItem::FindChildItem(const std::string& id) {
80 return NULL;
83 size_t AppListItem::ChildItemCount() const {
84 return 0;
87 void AppListItem::OnExtensionPreferenceChanged() {}
89 bool AppListItem::CompareForTest(const AppListItem* other) const {
90 return id_ == other->id_ &&
91 folder_id_ == other->folder_id_ &&
92 name_ == other->name_ &&
93 short_name_ == other->short_name_ &&
94 GetItemType() == other->GetItemType() &&
95 position_.Equals(other->position_);
98 std::string AppListItem::ToDebugString() const {
99 return id_.substr(0, 8) + " '" + name_ + "'"
100 + " [" + position_.ToDebugString() + "]";
103 // Protected methods
105 void AppListItem::SetName(const std::string& name) {
106 if (name_ == name && (short_name_.empty() || short_name_ == name))
107 return;
108 name_ = name;
109 short_name_.clear();
110 FOR_EACH_OBSERVER(AppListItemObserver, observers_, ItemNameChanged());
113 void AppListItem::SetNameAndShortName(const std::string& name,
114 const std::string& short_name) {
115 if (name_ == name && short_name_ == short_name)
116 return;
117 name_ = name;
118 short_name_ = short_name;
119 FOR_EACH_OBSERVER(AppListItemObserver, observers_, ItemNameChanged());
122 } // namespace app_list