diff options
author | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-27 21:54:40 +0000 |
---|---|---|
committer | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-27 21:54:40 +0000 |
commit | 6d74e6f100fb8d87b245654ded0843a78f429818 (patch) | |
tree | d0f72f79ad3db7098262dcfec1c11988e1c34e90 /ui/app_list | |
parent | 2c333618f92d0bd27cbcab73e3a81c8203d79898 (diff) | |
download | chromium_src-6d74e6f100fb8d87b245654ded0843a78f429818.zip chromium_src-6d74e6f100fb8d87b245654ded0843a78f429818.tar.gz chromium_src-6d74e6f100fb8d87b245654ded0843a78f429818.tar.bz2 |
AppListItemModel -> AppListItem
As previously discussed, reenaming class to reduce confusion with
AppListModel.
BUG=none
For ash/shell and c/b/sync:
TBR=sky@chromium.org,zea@chromium.org
Review URL: https://codereview.chromium.org/112593005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242638 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/app_list')
31 files changed, 330 insertions, 335 deletions
diff --git a/ui/app_list/app_list.gyp b/ui/app_list/app_list.gyp index 2df15a8..cea4074 100644 --- a/ui/app_list/app_list.gyp +++ b/ui/app_list/app_list.gyp @@ -31,12 +31,12 @@ 'app_list_export.h', 'app_list_folder_item.cc', 'app_list_folder_item.h', + 'app_list_item.cc', + 'app_list_item.h', + 'app_list_item_observer.h', 'app_list_item_list.cc', 'app_list_item_list.h', 'app_list_item_list_observer.h', - 'app_list_item_model.cc', - 'app_list_item_model.h', - 'app_list_item_model_observer.h', 'app_list_menu.cc', 'app_list_menu.h', 'app_list_model.cc', diff --git a/ui/app_list/app_list_folder_item.cc b/ui/app_list/app_list_folder_item.cc index b256f99..38bce30 100644 --- a/ui/app_list/app_list_folder_item.cc +++ b/ui/app_list/app_list_folder_item.cc @@ -92,7 +92,7 @@ class FolderImageSource : public gfx::CanvasImageSource { } // namespace AppListFolderItem::AppListFolderItem(const std::string& id) - : AppListItemModel(id), + : AppListItem(id), item_list_(new AppListItemList) { item_list_->AddObserver(this); } @@ -148,20 +148,20 @@ void AppListFolderItem::ItemPercentDownloadedChanged() { } void AppListFolderItem::OnListItemAdded(size_t index, - AppListItemModel* item) { + AppListItem* item) { if (index <= kNumTopApps) UpdateTopItems(); } void AppListFolderItem::OnListItemRemoved(size_t index, - AppListItemModel* item) { + AppListItem* item) { if (index <= kNumTopApps) UpdateTopItems(); } void AppListFolderItem::OnListItemMoved(size_t from_index, size_t to_index, - AppListItemModel* item) { + AppListItem* item) { if (from_index <= kNumTopApps || to_index <= kNumTopApps) UpdateTopItems(); } @@ -173,7 +173,7 @@ void AppListFolderItem::UpdateTopItems() { for (size_t i = 0; i < kNumTopApps && i < item_list_->item_count(); ++i) { - AppListItemModel* item = item_list_->item_at(i); + AppListItem* item = item_list_->item_at(i); item->AddObserver(this); top_items_.push_back(item); } diff --git a/ui/app_list/app_list_folder_item.h b/ui/app_list/app_list_folder_item.h index 696c9d1..b04b777 100644 --- a/ui/app_list/app_list_folder_item.h +++ b/ui/app_list/app_list_folder_item.h @@ -9,18 +9,18 @@ #include <vector> #include "ui/app_list/app_list_export.h" +#include "ui/app_list/app_list_item.h" #include "ui/app_list/app_list_item_list_observer.h" -#include "ui/app_list/app_list_item_model.h" -#include "ui/app_list/app_list_item_model_observer.h" +#include "ui/app_list/app_list_item_observer.h" namespace app_list { class AppListItemList; // AppListFolderItem implements the model/controller for folders. -class APP_LIST_EXPORT AppListFolderItem : public AppListItemModel, +class APP_LIST_EXPORT AppListFolderItem : public AppListItem, public AppListItemListObserver, - public AppListItemModelObserver { + public AppListItemObserver { public: explicit AppListFolderItem(const std::string& id); virtual ~AppListFolderItem(); @@ -33,12 +33,12 @@ class APP_LIST_EXPORT AppListFolderItem : public AppListItemModel, static const char kAppType[]; private: - // AppListItemModel + // AppListItem virtual void Activate(int event_flags) OVERRIDE; virtual const char* GetAppType() const OVERRIDE; virtual ui::MenuModel* GetContextMenuModel() OVERRIDE; - // AppListItemModelObserver + // AppListItemObserver virtual void ItemIconChanged() OVERRIDE; virtual void ItemTitleChanged() OVERRIDE; virtual void ItemHighlightedChanged() OVERRIDE; @@ -46,18 +46,18 @@ class APP_LIST_EXPORT AppListFolderItem : public AppListItemModel, virtual void ItemPercentDownloadedChanged() OVERRIDE; // AppListItemListObserver - virtual void OnListItemAdded(size_t index, AppListItemModel* item) OVERRIDE; + virtual void OnListItemAdded(size_t index, AppListItem* item) OVERRIDE; virtual void OnListItemRemoved(size_t index, - AppListItemModel* item) OVERRIDE;; + AppListItem* item) OVERRIDE;; virtual void OnListItemMoved(size_t from_index, size_t to_index, - AppListItemModel* item) OVERRIDE; + AppListItem* item) OVERRIDE; void UpdateTopItems(); scoped_ptr<AppListItemList> item_list_; // Top items for generating folder icon. - std::vector<AppListItemModel*> top_items_; + std::vector<AppListItem*> top_items_; DISALLOW_COPY_AND_ASSIGN(AppListFolderItem); }; diff --git a/ui/app_list/app_list_item.cc b/ui/app_list/app_list_item.cc new file mode 100644 index 0000000..8440f52 --- /dev/null +++ b/ui/app_list/app_list_item.cc @@ -0,0 +1,99 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/app_list/app_list_item.h" + +#include "base/logging.h" +#include "ui/app_list/app_list_item_observer.h" + +namespace app_list { + +AppListItem::AppListItem(const std::string& id) + : id_(id), + highlighted_(false), + is_installing_(false), + percent_downloaded_(-1) { +} + +AppListItem::~AppListItem() { +} + +void AppListItem::SetIcon(const gfx::ImageSkia& icon, bool has_shadow) { + icon_ = icon; + has_shadow_ = has_shadow; + FOR_EACH_OBSERVER(AppListItemObserver, observers_, ItemIconChanged()); +} + +void AppListItem::SetTitleAndFullName(const std::string& title, + const std::string& full_name) { + if (title_ == title && full_name_ == full_name) + return; + + title_ = title; + full_name_ = full_name; + FOR_EACH_OBSERVER(AppListItemObserver, observers_, ItemTitleChanged()); +} + +void AppListItem::SetHighlighted(bool highlighted) { + if (highlighted_ == highlighted) + return; + + highlighted_ = highlighted; + FOR_EACH_OBSERVER(AppListItemObserver, + observers_, + ItemHighlightedChanged()); +} + +void AppListItem::SetIsInstalling(bool is_installing) { + if (is_installing_ == is_installing) + return; + + is_installing_ = is_installing; + FOR_EACH_OBSERVER(AppListItemObserver, + observers_, + ItemIsInstallingChanged()); +} + +void AppListItem::SetPercentDownloaded(int percent_downloaded) { + if (percent_downloaded_ == percent_downloaded) + return; + + percent_downloaded_ = percent_downloaded; + FOR_EACH_OBSERVER(AppListItemObserver, + observers_, + ItemPercentDownloadedChanged()); +} + +void AppListItem::AddObserver(AppListItemObserver* observer) { + observers_.AddObserver(observer); +} + +void AppListItem::RemoveObserver(AppListItemObserver* observer) { + observers_.RemoveObserver(observer); +} + +void AppListItem::Activate(int event_flags) { +} + +const char* AppListItem::GetAppType() const { + static const char* app_type = ""; + return app_type; +} + +ui::MenuModel* AppListItem::GetContextMenuModel() { + return NULL; +} + +bool AppListItem::CompareForTest(const AppListItem* other) const { + return id_ == other->id_ && + title_ == other->title_ && + position_.Equals(other->position_); +} + +std::string AppListItem::ToDebugString() const { + return id_.substr(0, 8) + " '" + title_ + "'" + + " [" + position_.ToDebugString() + "]"; +} + +} // namespace app_list diff --git a/ui/app_list/app_list_item_model.h b/ui/app_list/app_list_item.h index 1ffc6c0..6123caf 100644 --- a/ui/app_list/app_list_item_model.h +++ b/ui/app_list/app_list_item.h @@ -1,9 +1,9 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef UI_APP_LIST_APP_LIST_ITEM_MODEL_H_ -#define UI_APP_LIST_APP_LIST_ITEM_MODEL_H_ +#ifndef UI_APP_LIST_APP_LIST_ITEM_H_ +#define UI_APP_LIST_APP_LIST_ITEM_H_ #include <string> @@ -21,14 +21,14 @@ namespace app_list { class AppListItemList; class AppListItemListTest; -class AppListItemModelObserver; +class AppListItemObserver; -// AppListItemModel provides icon and title to be shown in a AppListItemView +// AppListItem provides icon and title to be shown in a AppListItemView // and action to be executed when the AppListItemView is activated. -class APP_LIST_EXPORT AppListItemModel { +class APP_LIST_EXPORT AppListItem { public: - explicit AppListItemModel(const std::string& id); - virtual ~AppListItemModel(); + explicit AppListItem(const std::string& id); + virtual ~AppListItem(); void SetIcon(const gfx::ImageSkia& icon, bool has_shadow); const gfx::ImageSkia& icon() const { return icon_; } @@ -51,8 +51,8 @@ class APP_LIST_EXPORT AppListItemModel { const std::string& id() const { return id_; } const syncer::StringOrdinal& position() const { return position_; } - void AddObserver(AppListItemModelObserver* observer); - void RemoveObserver(AppListItemModelObserver* observer); + void AddObserver(AppListItemObserver* observer); + void RemoveObserver(AppListItemObserver* observer); // Activates (opens) the item. Does nothing by default. virtual void Activate(int event_flags); @@ -67,7 +67,7 @@ class APP_LIST_EXPORT AppListItemModel { virtual ui::MenuModel* GetContextMenuModel(); // Utility functions for sync integration tests. - virtual bool CompareForTest(const AppListItemModel* other) const; + virtual bool CompareForTest(const AppListItem* other) const; virtual std::string ToDebugString() const; protected: @@ -92,11 +92,11 @@ class APP_LIST_EXPORT AppListItemModel { bool is_installing_; int percent_downloaded_; - ObserverList<AppListItemModelObserver> observers_; + ObserverList<AppListItemObserver> observers_; - DISALLOW_COPY_AND_ASSIGN(AppListItemModel); + DISALLOW_COPY_AND_ASSIGN(AppListItem); }; } // namespace app_list -#endif // UI_APP_LIST_APP_LIST_ITEM_MODEL_H_ +#endif // UI_APP_LIST_APP_LIST_ITEM_H_ diff --git a/ui/app_list/app_list_item_list.cc b/ui/app_list/app_list_item_list.cc index 5f88b2d..ea76c48 100644 --- a/ui/app_list/app_list_item_list.cc +++ b/ui/app_list/app_list_item_list.cc @@ -4,7 +4,7 @@ #include "ui/app_list/app_list_item_list.h" -#include "ui/app_list/app_list_item_model.h" +#include "ui/app_list/app_list_item.h" namespace app_list { @@ -22,9 +22,9 @@ void AppListItemList::RemoveObserver(AppListItemListObserver* observer) { observers_.RemoveObserver(observer); } -AppListItemModel* AppListItemList::FindItem(const std::string& id) { +AppListItem* AppListItemList::FindItem(const std::string& id) { for (size_t i = 0; i < app_list_items_.size(); ++i) { - AppListItemModel* item = app_list_items_[i]; + AppListItem* item = app_list_items_[i]; if (item->id() == id) return item; } @@ -33,7 +33,7 @@ AppListItemModel* AppListItemList::FindItem(const std::string& id) { bool AppListItemList::FindItemIndex(const std::string& id, size_t* index) { for (size_t i = 0; i < app_list_items_.size(); ++i) { - AppListItemModel* item = app_list_items_[i]; + AppListItem* item = app_list_items_[i]; if (item->id() == id) { *index = i; return true; @@ -42,7 +42,7 @@ bool AppListItemList::FindItemIndex(const std::string& id, size_t* index) { return false; } -size_t AppListItemList::AddItem(AppListItemModel* item) { +size_t AppListItemList::AddItem(AppListItem* item) { CHECK(std::find(app_list_items_.begin(), app_list_items_.end(), item) == app_list_items_.end()); EnsureValidItemPosition(item); @@ -54,16 +54,15 @@ size_t AppListItemList::AddItem(AppListItemModel* item) { return index; } -void AppListItemList::InsertItemAt(AppListItemModel* item, size_t index) { +void AppListItemList::InsertItemAt(AppListItem* item, size_t index) { DCHECK_LE(index, item_count()); if (item_count() == 0) { AddItem(item); return; } - AppListItemModel* prev = - index > 0 ? app_list_items_[index - 1] : NULL; - AppListItemModel* next = index <= app_list_items_.size() - 1 ? + AppListItem* prev = index > 0 ? app_list_items_[index - 1] : NULL; + AppListItem* next = index <= app_list_items_.size() - 1 ? app_list_items_[index] : NULL; CHECK_NE(prev, next); @@ -85,36 +84,36 @@ void AppListItemList::InsertItemAt(AppListItemModel* item, size_t index) { } void AppListItemList::DeleteItem(const std::string& id) { - scoped_ptr<AppListItemModel> item = RemoveItem(id); + scoped_ptr<AppListItem> item = RemoveItem(id); // |item| will be deleted on destruction. } void AppListItemList::DeleteItemsByType(const char* type) { for (int i = static_cast<int>(app_list_items_.size()) - 1; i >= 0; --i) { - AppListItemModel* item = app_list_items_[i]; + AppListItem* item = app_list_items_[i]; if (!type || item->GetAppType() == type) DeleteItemAt(i); } } -scoped_ptr<AppListItemModel> AppListItemList::RemoveItem( +scoped_ptr<AppListItem> AppListItemList::RemoveItem( const std::string& id) { size_t index; if (FindItemIndex(id, &index)) return RemoveItemAt(index); - return scoped_ptr<AppListItemModel>(); + return scoped_ptr<AppListItem>(); } -scoped_ptr<AppListItemModel> AppListItemList::RemoveItemAt(size_t index) { +scoped_ptr<AppListItem> AppListItemList::RemoveItemAt(size_t index) { DCHECK_LT(index, item_count()); - AppListItemModel* item = app_list_items_[index]; + AppListItem* item = app_list_items_[index]; app_list_items_.weak_erase(app_list_items_.begin() + index); FOR_EACH_OBSERVER(AppListItemListObserver, observers_, OnListItemRemoved(index, item)); - return make_scoped_ptr<AppListItemModel>(item); + return make_scoped_ptr<AppListItem>(item); } void AppListItemList::MoveItem(size_t from_index, size_t to_index) { @@ -123,13 +122,13 @@ void AppListItemList::MoveItem(size_t from_index, size_t to_index) { if (from_index == to_index) return; - AppListItemModel* target_item = app_list_items_[from_index]; + AppListItem* target_item = app_list_items_[from_index]; app_list_items_.weak_erase(app_list_items_.begin() + from_index); app_list_items_.insert(app_list_items_.begin() + to_index, target_item); // Update position - AppListItemModel* prev = to_index > 0 ? app_list_items_[to_index - 1] : NULL; - AppListItemModel* next = to_index < app_list_items_.size() - 1 ? + AppListItem* prev = to_index > 0 ? app_list_items_[to_index - 1] : NULL; + AppListItem* next = to_index < app_list_items_.size() - 1 ? app_list_items_[to_index + 1] : NULL; CHECK_NE(prev, next); @@ -157,7 +156,7 @@ void AppListItemList::MoveItem(size_t from_index, size_t to_index) { } void AppListItemList::SetItemPosition( - AppListItemModel* item, + AppListItem* item, const syncer::StringOrdinal& new_position) { DCHECK(item); size_t from_index; @@ -190,11 +189,11 @@ void AppListItemList::SetItemPosition( // AppListItemList private void AppListItemList::DeleteItemAt(size_t index) { - scoped_ptr<AppListItemModel> item = RemoveItemAt(index); + scoped_ptr<AppListItem> item = RemoveItemAt(index); // |item| will be deleted on destruction. } -void AppListItemList::EnsureValidItemPosition(AppListItemModel* item) { +void AppListItemList::EnsureValidItemPosition(AppListItem* item) { syncer::StringOrdinal position = item->position(); if (position.IsValid()) return; diff --git a/ui/app_list/app_list_item_list.h b/ui/app_list/app_list_item_list.h index 9e74074..916de70 100644 --- a/ui/app_list/app_list_item_list.h +++ b/ui/app_list/app_list_item_list.h @@ -16,7 +16,7 @@ namespace app_list { -class AppListItemModel; +class AppListItem; // Class to manage items in the app list. Used both by AppListModel and // AppListFolderItem. Manages the position ordinal of items in the list, and @@ -30,7 +30,7 @@ class APP_LIST_EXPORT AppListItemList { void RemoveObserver(AppListItemListObserver* observer); // Finds item matching |id|. NOTE: Requires a linear search. - AppListItemModel* FindItem(const std::string& id); + AppListItem* FindItem(const std::string& id); // Finds the |index| of the the item matching |id| in |app_list_items_|. // Returns true if the matching item is found. @@ -39,11 +39,11 @@ class APP_LIST_EXPORT AppListItemList { // Adds |item| to the end of |app_list_items_|. Takes ownership of |item|. // Triggers observers_.OnListItemAdded(). Returns the index of the added item. - size_t AddItem(AppListItemModel* item); + size_t AddItem(AppListItem* item); // Inserts |item| at the |index| into |app_list_items_|. Takes ownership of // |item|. Triggers observers_.OnListItemAdded(). - void InsertItemAt(AppListItemModel* item, size_t index); + void InsertItemAt(AppListItem* item, size_t index); // Finds item matching |id| in |app_list_items_| (linear search) and deletes // it. Triggers observers_.OnListItemRemoved() after removing the item from @@ -58,11 +58,11 @@ class APP_LIST_EXPORT AppListItemList { // Removes the item with matching |id| in |app_list_items_| without deleting // it. Returns a scoped pointer containing the removed item. - scoped_ptr<AppListItemModel> RemoveItem(const std::string& id); + scoped_ptr<AppListItem> RemoveItem(const std::string& id); // Removes the item at |index| from |app_list_items_| without deleting it. // Returns a scoped pointer containing the removed item. - scoped_ptr<AppListItemModel> RemoveItemAt(size_t index); + scoped_ptr<AppListItem> RemoveItemAt(size_t index); // Moves item at |from_index| to |to_index|. // Triggers observers_.OnListItemMoved(). @@ -70,10 +70,10 @@ class APP_LIST_EXPORT AppListItemList { // Sets the position of |item| which is expected to be a member of // |app_list_items_| and sorts the list accordingly. - void SetItemPosition(AppListItemModel* item, + void SetItemPosition(AppListItem* item, const syncer::StringOrdinal& new_position); - AppListItemModel* item_at(size_t index) { + AppListItem* item_at(size_t index) { DCHECK_LT(index, app_list_items_.size()); return app_list_items_[index]; } @@ -85,14 +85,14 @@ class APP_LIST_EXPORT AppListItemList { // If |item|->position() is not a valid ordinal, sets |item|->position() // to a valid ordinal after the last item in the list. - void EnsureValidItemPosition(AppListItemModel* item); + void EnsureValidItemPosition(AppListItem* item); // Returns the index at which to insert an item in |app_list_items_| based on // |position| (which must be valid) and |id| (if the positions are equal). size_t GetItemSortOrderIndex(const syncer::StringOrdinal& position, const std::string& id); - ScopedVector<AppListItemModel> app_list_items_; + ScopedVector<AppListItem> app_list_items_; ObserverList<AppListItemListObserver> observers_; DISALLOW_COPY_AND_ASSIGN(AppListItemList); diff --git a/ui/app_list/app_list_item_list_observer.h b/ui/app_list/app_list_item_list_observer.h index bca7e90..a6debcb 100644 --- a/ui/app_list/app_list_item_list_observer.h +++ b/ui/app_list/app_list_item_list_observer.h @@ -9,21 +9,21 @@ namespace app_list { -class AppListItemModel; +class AppListItem; class APP_LIST_EXPORT AppListItemListObserver { public: // Triggered after |item| has been added to the list at |index|. - virtual void OnListItemAdded(size_t index, AppListItemModel* item) {} + virtual void OnListItemAdded(size_t index, AppListItem* item) {} // Triggered after an item has been removed from the list at |index|, just // before the item is deleted. - virtual void OnListItemRemoved(size_t index, AppListItemModel* item) {} + virtual void OnListItemRemoved(size_t index, AppListItem* item) {} // Triggered after |item| has been moved from |from_index| to |to_index|. virtual void OnListItemMoved(size_t from_index, size_t to_index, - AppListItemModel* item) {} + AppListItem* item) {} protected: virtual ~AppListItemListObserver() {} diff --git a/ui/app_list/app_list_item_list_unittest.cc b/ui/app_list/app_list_item_list_unittest.cc index 2dbc628..b21edba 100644 --- a/ui/app_list/app_list_item_list_unittest.cc +++ b/ui/app_list/app_list_item_list_unittest.cc @@ -8,8 +8,8 @@ #include "base/strings/stringprintf.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/app_list/app_list_folder_item.h" +#include "ui/app_list/app_list_item.h" #include "ui/app_list/app_list_item_list_observer.h" -#include "ui/app_list/app_list_item_model.h" namespace app_list { @@ -26,12 +26,11 @@ class TestObserver : public AppListItemListObserver { } // AppListItemListObserver overriden: - virtual void OnListItemAdded(size_t index, AppListItemModel* item) OVERRIDE { + virtual void OnListItemAdded(size_t index, AppListItem* item) OVERRIDE { ++items_added_; } - virtual void OnListItemRemoved(size_t index, - AppListItemModel* item) OVERRIDE { + virtual void OnListItemRemoved(size_t index, AppListItem* item) OVERRIDE { ++items_removed_; } @@ -66,9 +65,9 @@ class AppListItemListTest : public testing::Test { } protected: - AppListItemModel* CreateItem(const std::string& title, + AppListItem* CreateItem(const std::string& title, const std::string& full_name) { - AppListItemModel* item = new AppListItemModel(title); + AppListItem* item = new AppListItem(title); size_t nitems = item_list_.item_count(); syncer::StringOrdinal position; if (nitems == 0) @@ -80,9 +79,9 @@ class AppListItemListTest : public testing::Test { return item; } - AppListItemModel* CreateAndAddItem(const std::string& title, - const std::string& full_name) { - AppListItemModel* item = CreateItem(title, full_name); + AppListItem* CreateAndAddItem(const std::string& title, + const std::string& full_name) { + AppListItem* item = CreateItem(title, full_name); item_list_.AddItem(item); return item; } @@ -122,9 +121,9 @@ class AppListItemListTest : public testing::Test { }; TEST_F(AppListItemListTest, FindItemIndex) { - AppListItemModel* item_0 = CreateAndAddItem(GetItemName(0), GetItemName(0)); - AppListItemModel* item_1 = CreateAndAddItem(GetItemName(1), GetItemName(1)); - AppListItemModel* item_2 = CreateAndAddItem(GetItemName(2), GetItemName(2)); + AppListItem* item_0 = CreateAndAddItem(GetItemName(0), GetItemName(0)); + AppListItem* item_1 = CreateAndAddItem(GetItemName(1), GetItemName(1)); + AppListItem* item_2 = CreateAndAddItem(GetItemName(2), GetItemName(2)); EXPECT_EQ(observer_.items_added(), 3u); EXPECT_EQ(item_list_.item_count(), 3u); EXPECT_EQ(item_0, item_list_.item_at(0)); @@ -140,15 +139,15 @@ TEST_F(AppListItemListTest, FindItemIndex) { EXPECT_TRUE(item_list_.FindItemIndex(item_2->id(), &index)); EXPECT_EQ(index, 2u); - scoped_ptr<AppListItemModel> item_3( + scoped_ptr<AppListItem> item_3( CreateItem(GetItemName(3), GetItemName(3))); EXPECT_FALSE(item_list_.FindItemIndex(item_3->id(), &index)); } TEST_F(AppListItemListTest, RemoveItemAt) { - AppListItemModel* item_0 = CreateAndAddItem(GetItemName(0), GetItemName(0)); - AppListItemModel* item_1 = CreateAndAddItem(GetItemName(1), GetItemName(1)); - AppListItemModel* item_2 = CreateAndAddItem(GetItemName(2), GetItemName(2)); + AppListItem* item_0 = CreateAndAddItem(GetItemName(0), GetItemName(0)); + AppListItem* item_1 = CreateAndAddItem(GetItemName(1), GetItemName(1)); + AppListItem* item_2 = CreateAndAddItem(GetItemName(2), GetItemName(2)); EXPECT_EQ(item_list_.item_count(), 3u); EXPECT_EQ(observer_.items_added(), 3u); size_t index; @@ -156,7 +155,7 @@ TEST_F(AppListItemListTest, RemoveItemAt) { EXPECT_EQ(index, 1u); EXPECT_TRUE(VerifyItemListOrdinals()); - scoped_ptr<AppListItemModel> item_removed = item_list_.RemoveItemAt(1); + scoped_ptr<AppListItem> item_removed = item_list_.RemoveItemAt(1); EXPECT_EQ(item_removed, item_1); EXPECT_FALSE(item_list_.FindItem(item_1->id())); EXPECT_EQ(item_list_.item_count(), 2u); @@ -167,9 +166,9 @@ TEST_F(AppListItemListTest, RemoveItemAt) { } TEST_F(AppListItemListTest, RemoveItem) { - AppListItemModel* item_0 = CreateAndAddItem(GetItemName(0), GetItemName(0)); - AppListItemModel* item_1 = CreateAndAddItem(GetItemName(1), GetItemName(1)); - AppListItemModel* item_2 = CreateAndAddItem(GetItemName(2), GetItemName(2)); + AppListItem* item_0 = CreateAndAddItem(GetItemName(0), GetItemName(0)); + AppListItem* item_1 = CreateAndAddItem(GetItemName(1), GetItemName(1)); + AppListItem* item_2 = CreateAndAddItem(GetItemName(2), GetItemName(2)); EXPECT_EQ(item_list_.item_count(), 3u); EXPECT_EQ(observer_.items_added(), 3u); EXPECT_EQ(item_0, item_list_.item_at(0)); @@ -181,7 +180,7 @@ TEST_F(AppListItemListTest, RemoveItem) { EXPECT_TRUE(item_list_.FindItemIndex(item_1->id(), &index)); EXPECT_EQ(index, 1u); - scoped_ptr<AppListItemModel> item_removed = + scoped_ptr<AppListItem> item_removed = item_list_.RemoveItem(item_1->id()); EXPECT_EQ(item_removed, item_1); EXPECT_FALSE(item_list_.FindItem(item_1->id())); @@ -189,13 +188,13 @@ TEST_F(AppListItemListTest, RemoveItem) { EXPECT_EQ(observer_.items_removed(), 1u); EXPECT_TRUE(VerifyItemListOrdinals()); - scoped_ptr<AppListItemModel> not_found_item = item_list_.RemoveItem("Bogus"); + scoped_ptr<AppListItem> not_found_item = item_list_.RemoveItem("Bogus"); EXPECT_FALSE(not_found_item.get()); } TEST_F(AppListItemListTest, InsertItemAt) { - AppListItemModel* item_0 = CreateAndAddItem(GetItemName(0), GetItemName(0)); - AppListItemModel* item_1 = CreateAndAddItem(GetItemName(1), GetItemName(1)); + AppListItem* item_0 = CreateAndAddItem(GetItemName(0), GetItemName(0)); + AppListItem* item_1 = CreateAndAddItem(GetItemName(1), GetItemName(1)); EXPECT_EQ(item_list_.item_count(), 2u); EXPECT_EQ(observer_.items_added(), 2u); EXPECT_EQ(item_list_.item_at(0), item_0); @@ -203,7 +202,7 @@ TEST_F(AppListItemListTest, InsertItemAt) { EXPECT_TRUE(VerifyItemListOrdinals()); // Insert an item at the beginning of the item_list_. - AppListItemModel* item_2 = CreateItem(GetItemName(2), GetItemName(2)); + AppListItem* item_2 = CreateItem(GetItemName(2), GetItemName(2)); item_list_.InsertItemAt(item_2, 0); EXPECT_EQ(item_list_.item_count(), 3u); EXPECT_EQ(observer_.items_added(), 3u); @@ -213,7 +212,7 @@ TEST_F(AppListItemListTest, InsertItemAt) { EXPECT_TRUE(VerifyItemListOrdinals()); // Insert an item at the end of the item_list_. - AppListItemModel* item_3 = CreateItem(GetItemName(3), GetItemName(3)); + AppListItem* item_3 = CreateItem(GetItemName(3), GetItemName(3)); item_list_.InsertItemAt(item_3, item_list_.item_count()); EXPECT_EQ(item_list_.item_count(), 4u); EXPECT_EQ(observer_.items_added(), 4u); @@ -224,7 +223,7 @@ TEST_F(AppListItemListTest, InsertItemAt) { EXPECT_TRUE(VerifyItemListOrdinals()); // Insert an item at the 2nd item of the item_list_. - AppListItemModel* item_4 = CreateItem(GetItemName(4), GetItemName(4)); + AppListItem* item_4 = CreateItem(GetItemName(4), GetItemName(4)); item_list_.InsertItemAt(item_4, 1); EXPECT_EQ(item_list_.item_count(), 5u); EXPECT_EQ(observer_.items_added(), 5u); @@ -237,7 +236,7 @@ TEST_F(AppListItemListTest, InsertItemAt) { } TEST_F(AppListItemListTest, InsertItemAtEmptyList) { - AppListItemModel* item_0 = CreateItem(GetItemName(0), GetItemName(0)); + AppListItem* item_0 = CreateItem(GetItemName(0), GetItemName(0)); EXPECT_EQ(item_list_.item_count(), 0u); item_list_.InsertItemAt(item_0, 0); EXPECT_EQ(item_list_.item_count(), 1u); diff --git a/ui/app_list/app_list_item_model.cc b/ui/app_list/app_list_item_model.cc deleted file mode 100644 index 8a71a0c..0000000 --- a/ui/app_list/app_list_item_model.cc +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/app_list/app_list_item_model.h" - -#include "base/logging.h" -#include "ui/app_list/app_list_item_model_observer.h" - -namespace app_list { - -AppListItemModel::AppListItemModel(const std::string& id) - : id_(id), - highlighted_(false), - is_installing_(false), - percent_downloaded_(-1) { -} - -AppListItemModel::~AppListItemModel() { -} - -void AppListItemModel::SetIcon(const gfx::ImageSkia& icon, bool has_shadow) { - icon_ = icon; - has_shadow_ = has_shadow; - FOR_EACH_OBSERVER(AppListItemModelObserver, observers_, ItemIconChanged()); -} - -void AppListItemModel::SetTitleAndFullName(const std::string& title, - const std::string& full_name) { - if (title_ == title && full_name_ == full_name) - return; - - title_ = title; - full_name_ = full_name; - FOR_EACH_OBSERVER(AppListItemModelObserver, observers_, ItemTitleChanged()); -} - -void AppListItemModel::SetHighlighted(bool highlighted) { - if (highlighted_ == highlighted) - return; - - highlighted_ = highlighted; - FOR_EACH_OBSERVER(AppListItemModelObserver, - observers_, - ItemHighlightedChanged()); -} - -void AppListItemModel::SetIsInstalling(bool is_installing) { - if (is_installing_ == is_installing) - return; - - is_installing_ = is_installing; - FOR_EACH_OBSERVER(AppListItemModelObserver, - observers_, - ItemIsInstallingChanged()); -} - -void AppListItemModel::SetPercentDownloaded(int percent_downloaded) { - if (percent_downloaded_ == percent_downloaded) - return; - - percent_downloaded_ = percent_downloaded; - FOR_EACH_OBSERVER(AppListItemModelObserver, - observers_, - ItemPercentDownloadedChanged()); -} - -void AppListItemModel::AddObserver(AppListItemModelObserver* observer) { - observers_.AddObserver(observer); -} - -void AppListItemModel::RemoveObserver(AppListItemModelObserver* observer) { - observers_.RemoveObserver(observer); -} - -void AppListItemModel::Activate(int event_flags) { -} - -const char* AppListItemModel::GetAppType() const { - static const char* app_type = ""; - return app_type; -} - -ui::MenuModel* AppListItemModel::GetContextMenuModel() { - return NULL; -} - -bool AppListItemModel::CompareForTest(const AppListItemModel* other) const { - return id_ == other->id_ && - title_ == other->title_ && - position_.Equals(other->position_); -} - -std::string AppListItemModel::ToDebugString() const { - return id_.substr(0, 8) + " '" + title_ + "'" - + " [" + position_.ToDebugString() + "]"; -} - -} // namespace app_list diff --git a/ui/app_list/app_list_item_model_observer.h b/ui/app_list/app_list_item_observer.h index 80abb39..cc8a70a 100644 --- a/ui/app_list/app_list_item_model_observer.h +++ b/ui/app_list/app_list_item_observer.h @@ -1,15 +1,15 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef UI_APP_LIST_APP_LIST_ITEM_MODEL_OBSERVER_H_ -#define UI_APP_LIST_APP_LIST_ITEM_MODEL_OBSERVER_H_ +#ifndef UI_APP_LIST_APP_LIST_ITEM_OBSERVER_H_ +#define UI_APP_LIST_APP_LIST_ITEM_OBSERVER_H_ #include "ui/app_list/app_list_export.h" namespace app_list { -class APP_LIST_EXPORT AppListItemModelObserver { +class APP_LIST_EXPORT AppListItemObserver { public: // Invoked after item's icon is changed. virtual void ItemIconChanged() = 0; @@ -27,9 +27,9 @@ class APP_LIST_EXPORT AppListItemModelObserver { virtual void ItemPercentDownloadedChanged() = 0; protected: - virtual ~AppListItemModelObserver() {} + virtual ~AppListItemObserver() {} }; } // namespace app_list -#endif // UI_APP_LIST_APP_LIST_ITEM_MODEL_OBSERVER_H_ +#endif // UI_APP_LIST_APP_LIST_ITEM_OBSERVER_H_ diff --git a/ui/app_list/app_list_model.cc b/ui/app_list/app_list_model.cc index b37ec61..c5515033 100644 --- a/ui/app_list/app_list_model.cc +++ b/ui/app_list/app_list_model.cc @@ -4,7 +4,7 @@ #include "ui/app_list/app_list_model.h" -#include "ui/app_list/app_list_item_model.h" +#include "ui/app_list/app_list_item.h" #include "ui/app_list/app_list_model_observer.h" #include "ui/app_list/search_box_model.h" #include "ui/app_list/search_result.h" diff --git a/ui/app_list/app_list_model.h b/ui/app_list/app_list_model.h index a0d2a39..76619ec 100644 --- a/ui/app_list/app_list_model.h +++ b/ui/app_list/app_list_model.h @@ -14,15 +14,15 @@ namespace app_list { +class AppListItem; class AppListItemList; -class AppListItemModel; class AppListModelObserver; class SearchBoxModel; class SearchResult; // Master model of app list that consists of three sub models: AppListItemList, // SearchBoxModel and SearchResults. The AppListItemList sub model owns a list -// of AppListItemModel and is displayed in the grid view. SearchBoxModel is +// of AppListItems and is displayed in the grid view. SearchBoxModel is // the model for SearchBoxView. SearchResults owns a list of SearchResult. class APP_LIST_EXPORT AppListModel { public: diff --git a/ui/app_list/app_list_model_unittest.cc b/ui/app_list/app_list_model_unittest.cc index 9ddbecf..2edc2c6 100644 --- a/ui/app_list/app_list_model_unittest.cc +++ b/ui/app_list/app_list_model_unittest.cc @@ -10,7 +10,7 @@ #include "base/strings/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/app_list/app_list_folder_item.h" -#include "ui/app_list/app_list_item_model.h" +#include "ui/app_list/app_list_item.h" #include "ui/app_list/app_list_model_observer.h" #include "ui/app_list/test/app_list_test_model.h" #include "ui/base/models/list_model_observer.h" @@ -37,18 +37,17 @@ class TestObserver : public AppListModelObserver, } // AppListItemListObserver - virtual void OnListItemAdded(size_t index, AppListItemModel* item) OVERRIDE { + virtual void OnListItemAdded(size_t index, AppListItem* item) OVERRIDE { items_added_++; } - virtual void OnListItemRemoved(size_t index, - AppListItemModel* item) OVERRIDE { + virtual void OnListItemRemoved(size_t index, AppListItem* item) OVERRIDE { items_removed_++; } virtual void OnListItemMoved(size_t from_index, size_t to_index, - AppListItemModel* item) OVERRIDE { + AppListItem* item) OVERRIDE { items_moved_++; } @@ -95,7 +94,7 @@ class AppListModelTest : public testing::Test { protected: bool ItemObservedByFolder(AppListFolderItem* folder, - AppListItemModel* item) { + AppListItem* item) { return item->observers_.HasObserver(folder); } @@ -127,10 +126,10 @@ TEST_F(AppListModelTest, AppsObserver) { TEST_F(AppListModelTest, ModelGetItem) { const size_t num_apps = 2; model_.PopulateApps(num_apps); - AppListItemModel* item0 = model_.item_list()->item_at(0); + AppListItem* item0 = model_.item_list()->item_at(0); ASSERT_TRUE(item0); EXPECT_EQ(model_.GetItemName(0), item0->id()); - AppListItemModel* item1 = model_.item_list()->item_at(1); + AppListItem* item1 = model_.item_list()->item_at(1); ASSERT_TRUE(item1); EXPECT_EQ(model_.GetItemName(1), item1->id()); } @@ -139,11 +138,11 @@ TEST_F(AppListModelTest, ModelFindItem) { const size_t num_apps = 2; model_.PopulateApps(num_apps); std::string item_name0 = model_.GetItemName(0); - AppListItemModel* item0 = model_.item_list()->FindItem(item_name0); + AppListItem* item0 = model_.item_list()->FindItem(item_name0); ASSERT_TRUE(item0); EXPECT_EQ(item_name0, item0->id()); std::string item_name1 = model_.GetItemName(1); - AppListItemModel* item1 = model_.item_list()->FindItem(item_name1); + AppListItem* item1 = model_.item_list()->FindItem(item_name1); ASSERT_TRUE(item1); EXPECT_EQ(item_name1, item1->id()); } @@ -156,11 +155,11 @@ TEST_F(AppListModelTest, ModelAddItem) { ASSERT_EQ(num_apps + 1, model_.item_list()->item_count()); EXPECT_EQ("Added Item 1", model_.item_list()->item_at(num_apps)->id()); // Add an item between items 0 and 1. - AppListItemModel* item0 = model_.item_list()->item_at(0); + AppListItem* item0 = model_.item_list()->item_at(0); ASSERT_TRUE(item0); - AppListItemModel* item1 = model_.item_list()->item_at(1); + AppListItem* item1 = model_.item_list()->item_at(1); ASSERT_TRUE(item1); - AppListItemModel* item2 = model_.CreateItem("Added Item 2", "Added Item 2"); + AppListItem* item2 = model_.CreateItem("Added Item 2", "Added Item 2"); model_.item_list()->AddItem(item2); model_.item_list()->SetItemPosition( item2, item0->position().CreateBetween(item1->position())); @@ -176,7 +175,7 @@ TEST_F(AppListModelTest, ModelMoveItem) { ASSERT_EQ(num_apps + 1, model_.item_list()->item_count()); // Move it to the position 1. model_.item_list()->MoveItem(num_apps, 1); - AppListItemModel* item = model_.item_list()->item_at(1); + AppListItem* item = model_.item_list()->item_at(1); ASSERT_TRUE(item); EXPECT_EQ("Inserted Item", item->id()); } @@ -197,7 +196,7 @@ TEST_F(AppListModelTest, ModelRemoveItem) { EXPECT_EQ(num_apps - 3, model_.item_list()->item_count()); EXPECT_EQ(3u, observer_.items_removed()); // Ensure that the first item is the expected one - AppListItemModel* item0 = model_.item_list()->item_at(0); + AppListItem* item0 = model_.item_list()->item_at(0); ASSERT_TRUE(item0); EXPECT_EQ(model_.GetItemName(2), item0->id()); } diff --git a/ui/app_list/app_list_view_delegate.h b/ui/app_list/app_list_view_delegate.h index 235e126..011bfb3 100644 --- a/ui/app_list/app_list_view_delegate.h +++ b/ui/app_list/app_list_view_delegate.h @@ -27,7 +27,6 @@ class ImageSkia; namespace app_list { -class AppListItemModel; class AppListModel; class AppListViewDelegateObserver; class SearchResult; diff --git a/ui/app_list/cocoa/apps_grid_controller.mm b/ui/app_list/cocoa/apps_grid_controller.mm index dc5145c..93b1540 100644 --- a/ui/app_list/cocoa/apps_grid_controller.mm +++ b/ui/app_list/cocoa/apps_grid_controller.mm @@ -5,7 +5,7 @@ #import "ui/app_list/cocoa/apps_grid_controller.h" #include "base/mac/foundation_util.h" -#include "ui/app_list/app_list_item_model.h" +#include "ui/app_list/app_list_item.h" #include "ui/app_list/app_list_model.h" #include "ui/app_list/app_list_model_observer.h" #include "ui/app_list/app_list_view_delegate.h" @@ -78,7 +78,7 @@ NSTimeInterval g_scroll_duration = 0.18; // Bridged methods for AppListItemListObserver. - (void)listItemAdded:(size_t)index - item:(app_list::AppListItemModel*)item; + item:(app_list::AppListItem*)item; - (void)listItemRemoved:(size_t)index; @@ -98,17 +98,16 @@ class AppsGridDelegateBridge : public AppListItemListObserver { private: // Overridden from AppListItemListObserver: - virtual void OnListItemAdded(size_t index, AppListItemModel* item) OVERRIDE { + virtual void OnListItemAdded(size_t index, AppListItem* item) OVERRIDE { [parent_ listItemAdded:index item:item]; } - virtual void OnListItemRemoved(size_t index, - AppListItemModel* item) OVERRIDE { + virtual void OnListItemRemoved(size_t index, AppListItem* item) OVERRIDE { [parent_ listItemRemoved:index]; } virtual void OnListItemMoved(size_t from_index, size_t to_index, - AppListItemModel* item) OVERRIDE { + AppListItem* item) OVERRIDE { [parent_ listItemMovedFromIndex:from_index toModelIndex:to_index]; } @@ -210,7 +209,7 @@ class AppsGridDelegateBridge : public AppListItemListObserver { newModel->item_list()->AddObserver(bridge_.get()); for (size_t i = 0; i < newModel->item_list()->item_count(); ++i) { - app_list::AppListItemModel* itemModel = newModel->item_list()->item_at(i); + app_list::AppListItem* itemModel = newModel->item_list()->item_at(i); [items_ insertObject:[NSValue valueWithPointer:itemModel] atIndex:i]; } @@ -380,9 +379,9 @@ class AppsGridDelegateBridge : public AppListItemListObserver { - (void)onItemClicked:(id)sender { for (size_t i = 0; i < [items_ count]; ++i) { - AppsGridViewItem* item = [self itemAtIndex:i]; - if ([[item button] isEqual:sender]) - [item model]->Activate(0); + AppsGridViewItem* gridItem = [self itemAtIndex:i]; + if ([[gridItem button] isEqual:sender]) + [gridItem model]->Activate(0); } } @@ -467,9 +466,9 @@ class AppsGridDelegateBridge : public AppListItemListObserver { // Clear the models first, otherwise removed items could be autoreleased at // an unknown point in the future, when the model owner may have gone away. for (size_t i = 0; i < [[pageView content] count]; ++i) { - AppsGridViewItem* item = base::mac::ObjCCastStrict<AppsGridViewItem>( + AppsGridViewItem* gridItem = base::mac::ObjCCastStrict<AppsGridViewItem>( [pageView itemAtIndex:i]); - [item setModel:NULL]; + [gridItem setModel:NULL]; } } @@ -482,9 +481,9 @@ class AppsGridDelegateBridge : public AppListItemListObserver { return; for (size_t i = 0; i < [pageContent count]; ++i) { - AppsGridViewItem* item = base::mac::ObjCCastStrict<AppsGridViewItem>( + AppsGridViewItem* gridItem = base::mac::ObjCCastStrict<AppsGridViewItem>( [pageView itemAtIndex:i]); - [item setModel:static_cast<app_list::AppListItemModel*>( + [gridItem setModel:static_cast<app_list::AppListItem*>( [[pageContent objectAtIndex:i] pointerValue])]; } } @@ -536,7 +535,7 @@ class AppsGridDelegateBridge : public AppListItemListObserver { } - (void)listItemAdded:(size_t)index - item:(app_list::AppListItemModel*)itemModel { + item:(app_list::AppListItem*)itemModel { // Cancel any drag, to ensure the model stays consistent. [dragManager_ cancelDrag]; diff --git a/ui/app_list/cocoa/apps_grid_controller_unittest.mm b/ui/app_list/cocoa/apps_grid_controller_unittest.mm index da0b37d..2815882 100644 --- a/ui/app_list/cocoa/apps_grid_controller_unittest.mm +++ b/ui/app_list/cocoa/apps_grid_controller_unittest.mm @@ -8,7 +8,7 @@ #include "skia/ext/skia_utils_mac.h" #import "testing/gtest_mac.h" #include "ui/app_list/app_list_constants.h" -#include "ui/app_list/app_list_item_model.h" +#include "ui/app_list/app_list_item.h" #import "ui/app_list/cocoa/apps_collection_view_drag_manager.h" #import "ui/app_list/cocoa/apps_grid_controller.h" #import "ui/app_list/cocoa/apps_grid_view_item.h" @@ -131,10 +131,10 @@ class AppsGridControllerTest : public AppsGridControllerTestHelper { DISALLOW_COPY_AND_ASSIGN(AppsGridControllerTest); }; -class AppListItemWithMenu : public AppListItemModel { +class AppListItemWithMenu : public AppListItem { public: explicit AppListItemWithMenu(const std::string& title) - : AppListItemModel(title), + : AppListItem(title), menu_model_(NULL), menu_ready_(true) { SetTitleAndFullName(title, title); @@ -448,7 +448,7 @@ TEST_F(AppsGridControllerTest, ModelUpdate) { EXPECT_EQ(std::string("|Item 0,Item 1,Item 2|"), GetViewContent()); // Update the title via the ItemModelObserver. - app_list::AppListItemModel* item_model = model()->item_list()->item_at(2); + app_list::AppListItem* item_model = model()->item_list()->item_at(2); item_model->SetTitleAndFullName("UpdatedItem", "UpdatedItem"); EXPECT_NSEQ(@"UpdatedItem", [button title]); EXPECT_EQ(std::string("|Item 0,Item 1,UpdatedItem|"), GetViewContent()); @@ -482,9 +482,9 @@ TEST_F(AppsGridControllerTest, ModelAdd) { EXPECT_EQ(std::string("|Item 0,Item 1,Item 2|"), GetViewContent()); // Test adding an item whose position is in the middle. - app_list::AppListItemModel* item0 = item_list->item_at(0); - app_list::AppListItemModel* item1 = item_list->item_at(1); - app_list::AppListItemModel* item3 = + app_list::AppListItem* item0 = item_list->item_at(0); + app_list::AppListItem* item1 = item_list->item_at(1); + app_list::AppListItem* item3 = model()->CreateItem("Item Three", "Item Three"); item_list->AddItem(item3); item_list->SetItemPosition( @@ -542,7 +542,7 @@ TEST_F(AppsGridControllerTest, ModelRemovePage) { EXPECT_EQ(2u, [apps_grid_controller_ pageCount]); // Test removing the last item when there is one item on the second page. - app_list::AppListItemModel* last_item = item_list->item_at(kItemsPerPage); + app_list::AppListItem* last_item = item_list->item_at(kItemsPerPage); item_list->DeleteItem(last_item->id()); EXPECT_EQ(kItemsPerPage, item_list->item_count()); EXPECT_EQ(kItemsPerPage, [apps_grid_controller_ itemCount]); @@ -554,7 +554,7 @@ TEST_F(AppsGridControllerTest, ItemInstallProgress) { ReplaceTestModel(kItemsPerPage + 1); EXPECT_EQ(2u, [apps_grid_controller_ pageCount]); EXPECT_EQ(0u, [apps_grid_controller_ visiblePage]); - app_list::AppListItemModel* item_model = + app_list::AppListItem* item_model = model()->item_list()->item_at(kItemsPerPage); // Highlighting an item should activate the page it is on. @@ -590,7 +590,7 @@ TEST_F(AppsGridControllerTest, ItemInstallProgress) { // Two things can be installing simultaneously. When one starts or completes // the model builder will ask for the item to be highlighted. - app_list::AppListItemModel* alternate_item_model = + app_list::AppListItem* alternate_item_model = model()->item_list()->item_at(0); item_model->SetHighlighted(false); alternate_item_model->SetHighlighted(true); diff --git a/ui/app_list/cocoa/apps_grid_view_item.h b/ui/app_list/cocoa/apps_grid_view_item.h index b42eec1..6106050 100644 --- a/ui/app_list/cocoa/apps_grid_view_item.h +++ b/ui/app_list/cocoa/apps_grid_view_item.h @@ -12,7 +12,7 @@ #import "ui/base/cocoa/tracking_area.h" namespace app_list { -class AppListItemModel; +class AppListItem; class ItemModelObserverBridge; } @@ -34,10 +34,10 @@ APP_LIST_EXPORT - (id)initWithSize:(NSSize)tileSize; // Set the represented model, updating views. Clears if |itemModel| is NULL. -- (void)setModel:(app_list::AppListItemModel*)itemModel; +- (void)setModel:(app_list::AppListItem*)itemModel; // Model accessor, via the |observerBridge_|. -- (app_list::AppListItemModel*)model; +- (app_list::AppListItem*)model; // Return the button portion of the item, showing the icon and title. - (NSButton*)button; diff --git a/ui/app_list/cocoa/apps_grid_view_item.mm b/ui/app_list/cocoa/apps_grid_view_item.mm index 08304da..e3101ef 100644 --- a/ui/app_list/cocoa/apps_grid_view_item.mm +++ b/ui/app_list/cocoa/apps_grid_view_item.mm @@ -10,8 +10,8 @@ #include "base/strings/sys_string_conversions.h" #include "skia/ext/skia_utils_mac.h" #include "ui/app_list/app_list_constants.h" -#include "ui/app_list/app_list_item_model.h" -#include "ui/app_list/app_list_item_model_observer.h" +#include "ui/app_list/app_list_item.h" +#include "ui/app_list/app_list_item_observer.h" #import "ui/app_list/cocoa/apps_grid_controller.h" #import "ui/base/cocoa/menu_controller.h" #include "ui/base/resource/resource_bundle.h" @@ -43,7 +43,7 @@ const int kMacFontSizeDelta = -1; // Typed accessor for the root view. - (AppsGridItemBackgroundView*)itemBackgroundView; -// Bridged methods from app_list::AppListItemModelObserver: +// Bridged methods from app_list::AppListItemObserver: // Update the title, correctly setting the color if the button is highlighted. - (void)updateButtonTitle; @@ -64,12 +64,12 @@ const int kMacFontSizeDelta = -1; namespace app_list { -class ItemModelObserverBridge : public app_list::AppListItemModelObserver { +class ItemModelObserverBridge : public app_list::AppListItemObserver { public: - ItemModelObserverBridge(AppsGridViewItem* parent, AppListItemModel* model); + ItemModelObserverBridge(AppsGridViewItem* parent, AppListItem* model); virtual ~ItemModelObserverBridge(); - AppListItemModel* model() { return model_; } + AppListItem* model() { return model_; } NSMenu* GetContextMenu(); virtual void ItemIconChanged() OVERRIDE; @@ -80,14 +80,14 @@ class ItemModelObserverBridge : public app_list::AppListItemModelObserver { private: AppsGridViewItem* parent_; // Weak. Owns us. - AppListItemModel* model_; // Weak. Owned by AppListModel. + AppListItem* model_; // Weak. Owned by AppListModel. base::scoped_nsobject<MenuController> context_menu_controller_; DISALLOW_COPY_AND_ASSIGN(ItemModelObserverBridge); }; ItemModelObserverBridge::ItemModelObserverBridge(AppsGridViewItem* parent, - AppListItemModel* model) + AppListItem* model) : parent_(parent), model_(model) { model_->AddObserver(this); @@ -286,7 +286,7 @@ void ItemModelObserverBridge::ItemPercentDownloadedChanged() { [[[self button] cell] setHasShadow:[self model]->has_shadow()]; } -- (void)setModel:(app_list::AppListItemModel*)itemModel { +- (void)setModel:(app_list::AppListItem*)itemModel { [trackingArea_.get() clearOwner]; if (!itemModel) { observerBridge_.reset(); @@ -310,7 +310,7 @@ void ItemModelObserverBridge::ItemPercentDownloadedChanged() { [[self view] addTrackingArea:trackingArea_.get()]; } -- (app_list::AppListItemModel*)model { +- (app_list::AppListItem*)model { return observerBridge_->model(); } diff --git a/ui/app_list/cocoa/test/apps_grid_controller_test_helper.mm b/ui/app_list/cocoa/test/apps_grid_controller_test_helper.mm index f24b7d4..eb710e7 100644 --- a/ui/app_list/cocoa/test/apps_grid_controller_test_helper.mm +++ b/ui/app_list/cocoa/test/apps_grid_controller_test_helper.mm @@ -6,7 +6,7 @@ #include "base/mac/foundation_util.h" #include "base/strings/stringprintf.h" -#include "ui/app_list/app_list_item_model.h" +#include "ui/app_list/app_list_item.h" #import "ui/app_list/cocoa/apps_grid_controller.h" #import "ui/app_list/cocoa/apps_grid_view_item.h" #import "ui/base/test/cocoa_test_event_utils.h" diff --git a/ui/app_list/test/app_list_test_model.cc b/ui/app_list/test/app_list_test_model.cc index 64e03b9..fd733d3 100644 --- a/ui/app_list/test/app_list_test_model.cc +++ b/ui/app_list/test/app_list_test_model.cc @@ -17,7 +17,7 @@ const char AppListTestModel::kAppType[] = "TestItem"; AppListTestModel::AppListTestItemModel::AppListTestItemModel( const std::string& id, AppListTestModel* model) - : AppListItemModel(id), + : AppListItem(id), model_(model) { } AppListTestModel::AppListTestItemModel::~AppListTestItemModel() { @@ -92,7 +92,7 @@ void AppListTestModel::CreateAndAddItem(const std::string& title) { } void AppListTestModel::HighlightItemAt(int index) { - AppListItemModel* item = item_list()->item_at(index); + AppListItem* item = item_list()->item_at(index); item->SetHighlighted(true); } diff --git a/ui/app_list/test/app_list_test_model.h b/ui/app_list/test/app_list_test_model.h index 2536b09..c9593ef 100644 --- a/ui/app_list/test/app_list_test_model.h +++ b/ui/app_list/test/app_list_test_model.h @@ -7,7 +7,7 @@ #include <string> -#include "ui/app_list/app_list_item_model.h" +#include "ui/app_list/app_list_item.h" #include "ui/app_list/app_list_model.h" namespace app_list { @@ -17,7 +17,7 @@ namespace test { // Extends AppListModel with helper functions for use in tests. class AppListTestModel : public AppListModel { public: - class AppListTestItemModel : public AppListItemModel { + class AppListTestItemModel : public AppListItem { public: AppListTestItemModel(const std::string& id, AppListTestModel* model); virtual ~AppListTestItemModel(); @@ -60,7 +60,7 @@ class AppListTestModel : public AppListModel { void HighlightItemAt(int index); int activate_count() { return activate_count_; } - AppListItemModel* last_activated() { return last_activated_; } + AppListItem* last_activated() { return last_activated_; } static const char kAppType[]; @@ -68,7 +68,7 @@ class AppListTestModel : public AppListModel { void ItemActivated(AppListTestItemModel* item); int activate_count_; - AppListItemModel* last_activated_; + AppListItem* last_activated_; DISALLOW_COPY_AND_ASSIGN(AppListTestModel); }; diff --git a/ui/app_list/views/app_list_item_view.cc b/ui/app_list/views/app_list_item_view.cc index 525b729..ff756cc 100644 --- a/ui/app_list/views/app_list_item_view.cc +++ b/ui/app_list/views/app_list_item_view.cc @@ -8,7 +8,7 @@ #include "base/strings/utf_string_conversions.h" #include "ui/app_list/app_list_constants.h" -#include "ui/app_list/app_list_item_model.h" +#include "ui/app_list/app_list_item.h" #include "ui/app_list/app_list_switches.h" #include "ui/app_list/views/apps_grid_view.h" #include "ui/app_list/views/cached_label.h" @@ -55,9 +55,9 @@ const int kMouseDragUIDelayInMs = 100; const char AppListItemView::kViewClassName[] = "ui/app_list/AppListItemView"; AppListItemView::AppListItemView(AppsGridView* apps_grid_view, - AppListItemModel* model) + AppListItem* item) : CustomButton(apps_grid_view), - model_(model), + item_(item), apps_grid_view_(apps_grid_view), icon_(new views::ImageView), title_(new CachedLabel), @@ -72,7 +72,7 @@ AppListItemView::AppListItemView(AppsGridView* apps_grid_view, title_->SetEnabledColor(kGridTitleColor); title_->SetFontList(rb.GetFontList(kItemTextFontStyle)); title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); - title_->SetVisible(!model_->is_installing()); + title_->SetVisible(!item_->is_installing()); title_->Invalidate(); const gfx::ShadowValue kIconShadows[] = { @@ -87,7 +87,7 @@ AppListItemView::AppListItemView(AppsGridView* apps_grid_view, ItemIconChanged(); ItemTitleChanged(); ItemIsInstallingChanged(); - model_->AddObserver(this); + item_->AddObserver(this); set_context_menu_controller(this); set_request_focus_on_press(false); @@ -96,7 +96,7 @@ AppListItemView::AppListItemView(AppsGridView* apps_grid_view, } AppListItemView::~AppListItemView() { - model_->RemoveObserver(this); + item_->RemoveObserver(this); } void AppListItemView::SetIconSize(const gfx::Size& size) { @@ -112,8 +112,8 @@ void AppListItemView::UpdateIcon() { if (icon_size_.IsEmpty()) return; - gfx::ImageSkia icon = model_->icon(); - // Clear icon and bail out if model icon is empty. + gfx::ImageSkia icon = item_->icon(); + // Clear icon and bail out if item icon is empty. if (icon.isNull()) { icon_->SetImage(NULL); return; @@ -121,7 +121,7 @@ void AppListItemView::UpdateIcon() { gfx::ImageSkia resized(gfx::ImageSkiaOperations::CreateResizedImage(icon, skia::ImageOperations::RESIZE_BEST, icon_size_)); - if (model_->has_shadow()) { + if (item_->has_shadow()) { gfx::ImageSkia shadow( gfx::ImageSkiaOperations::CreateImageWithDropShadow(resized, icon_shadows_)); @@ -133,8 +133,8 @@ void AppListItemView::UpdateIcon() { } void AppListItemView::UpdateTooltip() { - title_->SetTooltipText(model_->title() == model_->full_name() ? - base::string16() : base::UTF8ToUTF16(model_->full_name())); + title_->SetTooltipText(item_->title() == item_->full_name() ? base::string16() + : base::UTF8ToUTF16(item_->full_name())); } void AppListItemView::SetUIState(UIState state) { @@ -146,8 +146,8 @@ void AppListItemView::SetUIState(UIState state) { #if defined(USE_AURA) switch (ui_state_) { case UI_STATE_NORMAL: - title_->SetVisible(!model_->is_installing()); - progress_bar_->SetVisible(model_->is_installing()); + title_->SetVisible(!item_->is_installing()); + progress_bar_->SetVisible(item_->is_installing()); break; case UI_STATE_DRAGGING: title_->SetVisible(false); @@ -226,7 +226,7 @@ void AppListItemView::ItemIconChanged() { } void AppListItemView::ItemTitleChanged() { - title_->SetText(base::UTF8ToUTF16(model_->title())); + title_->SetText(base::UTF8ToUTF16(item_->title())); title_->Invalidate(); UpdateTooltip(); Layout(); @@ -238,10 +238,10 @@ void AppListItemView::ItemHighlightedChanged() { } void AppListItemView::ItemIsInstallingChanged() { - if (model_->is_installing()) + if (item_->is_installing()) apps_grid_view_->EnsureViewVisible(this); - title_->SetVisible(!model_->is_installing()); - progress_bar_->SetVisible(model_->is_installing()); + title_->SetVisible(!item_->is_installing()); + progress_bar_->SetVisible(item_->is_installing()); SchedulePaint(); } @@ -249,9 +249,9 @@ void AppListItemView::ItemPercentDownloadedChanged() { // A percent_downloaded() of -1 can mean it's not known how much percent is // completed, or the download hasn't been marked complete, as is the case // while an extension is being installed after being downloaded. - if (model_->percent_downloaded() == -1) + if (item_->percent_downloaded() == -1) return; - progress_bar_->SetValue(model_->percent_downloaded() / 100.0); + progress_bar_->SetValue(item_->percent_downloaded() / 100.0); } const char* AppListItemView::GetClassName() const { @@ -290,7 +290,7 @@ void AppListItemView::OnPaint(gfx::Canvas* canvas) { return; gfx::Rect rect(GetContentsBounds()); - if (model_->highlighted() && !model_->is_installing()) { + if (item_->highlighted() && !item_->is_installing()) { canvas->FillRect(rect, kHighlightedColor); return; } else if (apps_grid_view_->IsSelectedView(this)) { @@ -317,13 +317,13 @@ void AppListItemView::OnPaint(gfx::Canvas* canvas) { void AppListItemView::GetAccessibleState(ui::AccessibleViewState* state) { state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; - state->name = base::UTF8ToUTF16(model_->title()); + state->name = base::UTF8ToUTF16(item_->title()); } void AppListItemView::ShowContextMenuForView(views::View* source, const gfx::Point& point, ui::MenuSourceType source_type) { - ui::MenuModel* menu_model = model_->GetContextMenuModel(); + ui::MenuModel* menu_model = item_->GetContextMenuModel(); if (!menu_model) return; @@ -348,7 +348,7 @@ void AppListItemView::StateChanged() { } else { if (!is_folder_ui_enabled) apps_grid_view_->ClearSelectedView(this); - model_->SetHighlighted(false); + item_->SetHighlighted(false); title_->SetEnabledColor(kGridTitleColor); } title_->Invalidate(); diff --git a/ui/app_list/views/app_list_item_view.h b/ui/app_list/views/app_list_item_view.h index 2d41461..5a140c4 100644 --- a/ui/app_list/views/app_list_item_view.h +++ b/ui/app_list/views/app_list_item_view.h @@ -11,7 +11,7 @@ #include "base/memory/scoped_ptr.h" #include "base/timer/timer.h" #include "ui/app_list/app_list_export.h" -#include "ui/app_list/app_list_item_model_observer.h" +#include "ui/app_list/app_list_item_observer.h" #include "ui/app_list/views/cached_label.h" #include "ui/gfx/shadow_value.h" #include "ui/views/context_menu_controller.h" @@ -27,18 +27,18 @@ class MenuRunner; namespace app_list { -class AppListItemModel; +class AppListItem; class AppsGridView; class ProgressBarView; class APP_LIST_EXPORT AppListItemView : public views::CustomButton, public views::ContextMenuController, - public AppListItemModelObserver { + public AppListItemObserver { public: // Internal class name. static const char kViewClassName[]; - AppListItemView(AppsGridView* apps_grid_view, AppListItemModel* model); + AppListItemView(AppsGridView* apps_grid_view, AppListItem* item); virtual ~AppListItemView(); void SetIconSize(const gfx::Size& size); @@ -53,7 +53,7 @@ class APP_LIST_EXPORT AppListItemView : public views::CustomButton, void SetAsAttemptedFolderTarget(bool is_target_folder); - AppListItemModel* model() const { return model_; } + AppListItem* item() const { return item_; } const views::Label* title() const { return title_; } @@ -68,10 +68,10 @@ class APP_LIST_EXPORT AppListItemView : public views::CustomButton, UI_STATE_DROPPING_IN_FOLDER, // Folder dropping preview UI }; - // Get icon from model and schedule background processing. + // Get icon from |item_| and schedule background processing. void UpdateIcon(); - // Update the tooltip text from the model. + // Update the tooltip text from |item_|. void UpdateTooltip(); void SetUIState(UIState state); @@ -82,7 +82,7 @@ class APP_LIST_EXPORT AppListItemView : public views::CustomButton, // Invoked when |mouse_drag_timer_| fires to show dragging UI. void OnMouseDragTimer(); - // AppListItemModelObserver overrides: + // AppListItemObserver overrides: virtual void ItemIconChanged() OVERRIDE; virtual void ItemTitleChanged() OVERRIDE; virtual void ItemHighlightedChanged() OVERRIDE; @@ -114,7 +114,7 @@ class APP_LIST_EXPORT AppListItemView : public views::CustomButton, // ui::EventHandler overrides: virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; - AppListItemModel* model_; // Owned by AppListModel. + AppListItem* item_; // Owned by AppListModel. AppsGridView* apps_grid_view_; // Owned by views hierarchy. views::ImageView* icon_; // Owned by views hierarchy. diff --git a/ui/app_list/views/app_list_main_view.cc b/ui/app_list/views/app_list_main_view.cc index e6f7a7c..0011a2c 100644 --- a/ui/app_list/views/app_list_main_view.cc +++ b/ui/app_list/views/app_list_main_view.cc @@ -13,7 +13,7 @@ #include "base/strings/string_util.h" #include "ui/app_list/app_list_constants.h" #include "ui/app_list/app_list_folder_item.h" -#include "ui/app_list/app_list_item_model.h" +#include "ui/app_list/app_list_item.h" #include "ui/app_list/app_list_model.h" #include "ui/app_list/app_list_view_delegate.h" #include "ui/app_list/pagination_model.h" @@ -40,10 +40,10 @@ const int kMaxIconLoadingWaitTimeInMs = 50; //////////////////////////////////////////////////////////////////////////////// // AppListMainView::IconLoader -class AppListMainView::IconLoader : public AppListItemModelObserver { +class AppListMainView::IconLoader : public AppListItemObserver { public: IconLoader(AppListMainView* owner, - AppListItemModel* item, + AppListItem* item, float scale) : owner_(owner), item_(item) { @@ -58,7 +58,7 @@ class AppListMainView::IconLoader : public AppListItemModelObserver { } private: - // AppListItemModelObserver overrides: + // AppListItemObserver overrides: virtual void ItemIconChanged() OVERRIDE { owner_->OnItemIconLoaded(this); // Note that IconLoader is released here. @@ -69,7 +69,7 @@ class AppListMainView::IconLoader : public AppListItemModelObserver { virtual void ItemPercentDownloadedChanged() OVERRIDE {} AppListMainView* owner_; - AppListItemModel* item_; + AppListItem* item_; DISALLOW_COPY_AND_ASSIGN(IconLoader); }; @@ -179,7 +179,7 @@ void AppListMainView::PreloadIcons(gfx::NativeView parent) { pending_icon_loaders_.clear(); for (int i = start_model_index; i < end_model_index; ++i) { - AppListItemModel* item = model_->item_list()->item_at(i); + AppListItem* item = model_->item_list()->item_at(i); if (item->icon().HasRepresentation(scale)) continue; @@ -203,7 +203,7 @@ void AppListMainView::OnItemIconLoaded(IconLoader* loader) { } } -void AppListMainView::ActivateApp(AppListItemModel* item, int event_flags) { +void AppListMainView::ActivateApp(AppListItem* item, int event_flags) { // TODO(jennyz): Activate the folder via AppListModel notification. if (item->GetAppType() == AppListFolderItem::kAppType) contents_view_->ShowFolderContent(static_cast<AppListFolderItem*>(item)); diff --git a/ui/app_list/views/app_list_main_view.h b/ui/app_list/views/app_list_main_view.h index 1e119aa..07d360d 100644 --- a/ui/app_list/views/app_list_main_view.h +++ b/ui/app_list/views/app_list_main_view.h @@ -22,10 +22,10 @@ class Widget; namespace app_list { -class ApplicationDragAndDropHost; +class AppListItem; class AppListModel; -class AppListItemModel; class AppListViewDelegate; +class ApplicationDragAndDropHost; class ContentsView; class PaginationModel; class SearchBoxView; @@ -76,7 +76,7 @@ class APP_LIST_EXPORT AppListMainView : public views::View, void OnItemIconLoaded(IconLoader* loader); // Overridden from AppsGridViewDelegate: - virtual void ActivateApp(AppListItemModel* item, int event_flags) OVERRIDE; + virtual void ActivateApp(AppListItem* item, int event_flags) OVERRIDE; virtual void GetShortcutPathForApp( const std::string& app_id, const base::Callback<void(const base::FilePath&)>& callback) OVERRIDE; diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc index 242501d..096ea708 100644 --- a/ui/app_list/views/apps_grid_view.cc +++ b/ui/app_list/views/apps_grid_view.cc @@ -12,7 +12,7 @@ #include "content/public/browser/web_contents.h" #include "ui/app_list/app_list_constants.h" #include "ui/app_list/app_list_folder_item.h" -#include "ui/app_list/app_list_item_model.h" +#include "ui/app_list/app_list_item.h" #include "ui/app_list/app_list_switches.h" #include "ui/app_list/pagination_model.h" #include "ui/app_list/views/app_list_drag_and_drop_host.h" @@ -177,7 +177,7 @@ int GetDistanceBetweenRects(gfx::Rect rect_1, } // Returns true if the |item| is an folder item. -bool IsFolderItem(AppListItemModel* item) { +bool IsFolderItem(AppListItem* item) { return (item->GetAppType() == AppListFolderItem::kAppType); } @@ -187,21 +187,21 @@ bool IsFolderItem(AppListItemModel* item) { // Returns the index of the target folder. size_t MergeItems(AppListItemList* item_list, const std::string& target_item_id, - AppListItemModel* source_item) { - scoped_ptr<AppListItemModel> source_item_ptr = + AppListItem* source_item) { + scoped_ptr<AppListItem> source_item_ptr = item_list->RemoveItem(source_item->id()); DCHECK_EQ(source_item, source_item_ptr.get()); size_t target_index; bool found_target_item = item_list->FindItemIndex(target_item_id, &target_index); DCHECK(found_target_item); - AppListItemModel* target_item = item_list->item_at(target_index); + AppListItem* target_item = item_list->item_at(target_index); if (IsFolderItem(target_item)) { AppListFolderItem* target_folder = static_cast<AppListFolderItem*>(target_item); target_folder->item_list()->AddItem(source_item_ptr.release()); } else { - scoped_ptr<AppListItemModel> target_item_ptr = + scoped_ptr<AppListItem> target_item_ptr = item_list->RemoveItemAt(target_index); DCHECK_EQ(target_item, target_item_ptr.get()); AppListFolderItem* new_folder = @@ -488,7 +488,7 @@ void AppsGridView::StartSettingUpSynchronousDrag() { return; delegate_->GetShortcutPathForApp( - drag_view_->model()->id(), + drag_view_->item()->id(), base::Bind(&AppsGridView::OnGotShortcutPath, base::Unretained(this))); synchronous_drag_ = new SynchronousDrag(this, drag_view_, drag_view_offset_); #endif @@ -1238,7 +1238,7 @@ void AppsGridView::StartDragAndDropHostDrag(const gfx::Point& grid_location) { // We have to hide the original item since the drag and drop host will do // the OS dependent code to "lift off the dragged item". drag_and_drop_host_->CreateDragIconProxy(screen_location, - drag_view_->model()->icon(), + drag_view_->item()->icon(), drag_view_, delta, kDragAndDropProxyScale); @@ -1269,7 +1269,7 @@ void AppsGridView::DispatchDragEventToDragAndDropHost( drag_and_drop_host_->EndDrag(true); } } else { - if (drag_and_drop_host_->StartDrag(drag_view_->model()->id(), + if (drag_and_drop_host_->StartDrag(drag_view_->item()->id(), location_in_screen_coordinates)) { // From now on we forward the drag events. forward_events_to_drag_and_drop_host_ = true; @@ -1342,11 +1342,11 @@ void AppsGridView::MoveItemInModel(views::View* item_view, void AppsGridView::MoveItemToFolder(views::View* item_view, const Index& target) { - AppListItemModel* source_item = - static_cast<AppListItemView*>(item_view)->model(); + AppListItem* source_item = + static_cast<AppListItemView*>(item_view)->item(); AppListItemView* target_view = static_cast<AppListItemView*>(GetViewAtSlotOnCurrentPage(target.slot)); - AppListItemModel* target_item = target_view->model(); + AppListItem* target_item = target_view->item(); bool target_is_folder = IsFolderItem(target_item); // Make change to data model. @@ -1401,7 +1401,7 @@ void AppsGridView::ButtonPressed(views::Button* sender, return; if (delegate_) { - delegate_->ActivateApp(static_cast<AppListItemView*>(sender)->model(), + delegate_->ActivateApp(static_cast<AppListItemView*>(sender)->item(), event.flags()); } } @@ -1429,7 +1429,7 @@ void AppsGridView::LayoutStartPage() { start_page_view_->SetBoundsRect(start_page_bounds); } -void AppsGridView::OnListItemAdded(size_t index, AppListItemModel* item) { +void AppsGridView::OnListItemAdded(size_t index, AppListItem* item) { EndDrag(true); views::View* view = CreateViewForItemAtIndex(index); @@ -1442,7 +1442,7 @@ void AppsGridView::OnListItemAdded(size_t index, AppListItemModel* item) { SchedulePaint(); } -void AppsGridView::OnListItemRemoved(size_t index, AppListItemModel* item) { +void AppsGridView::OnListItemRemoved(size_t index, AppListItem* item) { EndDrag(true); views::View* view = view_model_.view_at(index); @@ -1457,7 +1457,7 @@ void AppsGridView::OnListItemRemoved(size_t index, AppListItemModel* item) { void AppsGridView::OnListItemMoved(size_t from_index, size_t to_index, - AppListItemModel* item) { + AppListItem* item) { EndDrag(true); view_model_.Move(from_index, to_index); @@ -1520,8 +1520,8 @@ bool AppsGridView::CanDropIntoTarget(const Index& drop_target) { if (!target_view) return true; - AppListItemModel* target_item = - static_cast<AppListItemView*>(target_view)->model(); + AppListItem* target_item = + static_cast<AppListItemView*>(target_view)->item(); if (!IsFolderItem(target_item)) return true; @@ -1561,7 +1561,7 @@ AppsGridView::Index AppsGridView::GetNearestTileForDragView() { if (d_min < d_folder_dropping) { views::View* target_view = GetViewAtSlotOnCurrentPage(nearest_tile.slot); if (target_view && - !IsFolderItem(static_cast<AppListItemView*>(drag_view_)->model())) { + !IsFolderItem(static_cast<AppListItemView*>(drag_view_)->item())) { // If a non-folder item is dragged to the target slot with an item // sitting on it, attempt to drop the dragged item into the folder // containing the item on nearest_tile. diff --git a/ui/app_list/views/apps_grid_view.h b/ui/app_list/views/apps_grid_view.h index 043f6fa..db09469 100644 --- a/ui/app_list/views/apps_grid_view.h +++ b/ui/app_list/views/apps_grid_view.h @@ -276,11 +276,11 @@ class APP_LIST_EXPORT AppsGridView : public views::View, const ui::Event& event) OVERRIDE; // Overridden from AppListItemListObserver: - virtual void OnListItemAdded(size_t index, AppListItemModel* item) OVERRIDE; - virtual void OnListItemRemoved(size_t index, AppListItemModel* item) OVERRIDE; + virtual void OnListItemAdded(size_t index, AppListItem* item) OVERRIDE; + virtual void OnListItemRemoved(size_t index, AppListItem* item) OVERRIDE; virtual void OnListItemMoved(size_t from_index, size_t to_index, - AppListItemModel* item) OVERRIDE; + AppListItem* item) OVERRIDE; // Overridden from PaginationModelObserver: virtual void TotalPagesChanged() OVERRIDE; diff --git a/ui/app_list/views/apps_grid_view_delegate.h b/ui/app_list/views/apps_grid_view_delegate.h index 8174222..14b31a0 100644 --- a/ui/app_list/views/apps_grid_view_delegate.h +++ b/ui/app_list/views/apps_grid_view_delegate.h @@ -16,13 +16,13 @@ class FilePath; namespace app_list { -class AppListItemModel; +class AppListItem; class APP_LIST_EXPORT AppsGridViewDelegate { public: // Invoked when an item is activated on the grid view. |event_flags| contains // the flags of the keyboard/mouse event that triggers the activation request. - virtual void ActivateApp(AppListItemModel* item, int event_flags) = 0; + virtual void ActivateApp(AppListItem* item, int event_flags) = 0; // Gets the path to a shortcut for the app represented by |item|. |callback| // may be run immediately. diff --git a/ui/app_list/views/apps_grid_view_unittest.cc b/ui/app_list/views/apps_grid_view_unittest.cc index 47cdb89..2e43d21 100644 --- a/ui/app_list/views/apps_grid_view_unittest.cc +++ b/ui/app_list/views/apps_grid_view_unittest.cc @@ -13,7 +13,7 @@ #include "base/strings/utf_string_conversions.h" #include "base/timer/timer.h" #include "testing/gtest/include/gtest/gtest.h" -#include "ui/app_list/app_list_item_model.h" +#include "ui/app_list/app_list_item.h" #include "ui/app_list/app_list_model.h" #include "ui/app_list/pagination_model.h" #include "ui/app_list/test/app_list_test_model.h" diff --git a/ui/app_list/views/folder_header_view.h b/ui/app_list/views/folder_header_view.h index f8d471b..fb11830 100644 --- a/ui/app_list/views/folder_header_view.h +++ b/ui/app_list/views/folder_header_view.h @@ -7,7 +7,7 @@ #include <string> -#include "ui/app_list/app_list_item_model_observer.h" +#include "ui/app_list/app_list_item_observer.h" #include "ui/views/controls/button/button.h" #include "ui/views/controls/textfield/textfield_controller.h" #include "ui/views/view.h" @@ -26,7 +26,7 @@ class FolderHeaderViewDelegate; class FolderHeaderView : public views::View, public views::TextfieldController, public views::ButtonListener, - public AppListItemModelObserver { + public AppListItemObserver { public: explicit FolderHeaderView(FolderHeaderViewDelegate* delegate); virtual ~FolderHeaderView(); @@ -54,7 +54,7 @@ class FolderHeaderView : public views::View, virtual void ButtonPressed(views::Button* sender, const ui::Event& event) OVERRIDE; - // Overridden from AppListItemModelObserver: + // Overridden from AppListItemObserver: virtual void ItemIconChanged() OVERRIDE; virtual void ItemTitleChanged() OVERRIDE; virtual void ItemHighlightedChanged() OVERRIDE; |