diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-03 23:51:27 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-03 23:51:27 +0000 |
commit | eec097142c4b7d09ff01a03e2e2117f290d68cfc (patch) | |
tree | e31de7ef3985e92eabbfb65ed10dac797c0ba0b6 /ash/shelf | |
parent | 3b3af9753ec5dd2796df0555900515bb8ba0c613 (diff) | |
download | chromium_src-eec097142c4b7d09ff01a03e2e2117f290d68cfc.zip chromium_src-eec097142c4b7d09ff01a03e2e2117f290d68cfc.tar.gz chromium_src-eec097142c4b7d09ff01a03e2e2117f290d68cfc.tar.bz2 |
Renames LauncherID, LauncherItem and LauncherItems...
to ShelfID, ShelfItem and ShelfItems.
BUG=248353
TEST=None
R=jamescook@chromium.org,harrym@chromium.org
Review URL: https://codereview.chromium.org/152223002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248619 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/shelf')
27 files changed, 325 insertions, 298 deletions
diff --git a/ash/shelf/OWNERS b/ash/shelf/OWNERS index 34506bf..59d6acc 100644 --- a/ash/shelf/OWNERS +++ b/ash/shelf/OWNERS @@ -1 +1,3 @@ +davemoore@chromium.org harrym@chromium.org +skuhne@chromium.org diff --git a/ash/shelf/alternate_app_list_button.cc b/ash/shelf/alternate_app_list_button.cc index bf442d1..d71191b 100644 --- a/ash/shelf/alternate_app_list_button.cc +++ b/ash/shelf/alternate_app_list_button.cc @@ -6,9 +6,9 @@ #include "ash/ash_constants.h" #include "ash/ash_switches.h" -#include "ash/launcher/launcher_types.h" #include "ash/shelf/shelf_button.h" #include "ash/shelf/shelf_button_host.h" +#include "ash/shelf/shelf_item_types.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" diff --git a/ash/shelf/app_list_shelf_item_delegate.cc b/ash/shelf/app_list_shelf_item_delegate.cc index 51562ca..18ff11d 100644 --- a/ash/shelf/app_list_shelf_item_delegate.cc +++ b/ash/shelf/app_list_shelf_item_delegate.cc @@ -14,7 +14,7 @@ namespace ash { namespace internal { AppListShelfItemDelegate::AppListShelfItemDelegate() { - LauncherItem app_list; + ShelfItem app_list; app_list.type = TYPE_APP_LIST; Shell::GetInstance()->shelf_model()->Add(app_list); } diff --git a/ash/shelf/shelf.cc b/ash/shelf/shelf.cc index 51a90d1..0beb2d5 100644 --- a/ash/shelf/shelf.cc +++ b/ash/shelf/shelf.cc @@ -82,7 +82,7 @@ void Shelf::SetAlignment(ShelfAlignment alignment) { } gfx::Rect Shelf::GetScreenBoundsOfItemIconForWindow(aura::Window* window) { - LauncherID id = GetLauncherIDForWindow(window); + ShelfID id = GetShelfIDForWindow(window); gfx::Rect bounds(shelf_view_->GetIdealBoundsOfItemIcon(id)); gfx::Point screen_origin; views::View::ConvertPointToScreen(shelf_view_, &screen_origin); @@ -94,7 +94,7 @@ gfx::Rect Shelf::GetScreenBoundsOfItemIconForWindow(aura::Window* window) { void Shelf::UpdateIconPositionForWindow(aura::Window* window) { shelf_view_->UpdatePanelIconPosition( - GetLauncherIDForWindow(window), + GetShelfIDForWindow(window), ScreenUtil::ConvertRectFromScreen( shelf_widget()->GetNativeView(), window->GetBoundsInScreen()).CenterPoint()); @@ -108,7 +108,7 @@ void Shelf::ActivateShelfItem(int index) { ui::EF_NONE, false); - const LauncherItem& item = shelf_view_->model()->items()[index]; + const ShelfItem& item = shelf_view_->model()->items()[index]; ShelfItemDelegate* item_delegate = Shell::GetInstance()->shelf_item_delegate_manager()->GetShelfItemDelegate( item.id); @@ -156,7 +156,7 @@ views::View* Shelf::GetAppListButtonView() const { void Shelf::LaunchAppIndexAt(int item_index) { ShelfModel* shelf_model = shelf_view_->model(); - const LauncherItems& items = shelf_model->items(); + const ShelfItems& items = shelf_model->items(); int item_count = shelf_model->item_count(); int indexes_left = item_index >= 0 ? item_index : item_count; int found_index = -1; diff --git a/ash/shelf/shelf_button.h b/ash/shelf/shelf_button.h index 60158f2..b83f7f3 100644 --- a/ash/shelf/shelf_button.h +++ b/ash/shelf/shelf_button.h @@ -26,11 +26,11 @@ class ASH_EXPORT ShelfButton : public views::CustomButton { STATE_NORMAL = 0, // Button has mouse hovering on it. STATE_HOVERED = 1 << 0, - // Underlying LauncherItem has a running instance. + // Underlying ShelfItem has a running instance. STATE_RUNNING = 1 << 1, - // Underlying LauncherItem is active (i.e. has focus). + // Underlying ShelfItem is active (i.e. has focus). STATE_ACTIVE = 1 << 2, - // Underlying LauncherItem needs user's attention. + // Underlying ShelfItem needs user's attention. STATE_ATTENTION = 1 << 3, STATE_FOCUSED = 1 << 4, // Hide the status (temporarily for some animations). diff --git a/ash/shelf/shelf_delegate.h b/ash/shelf/shelf_delegate.h index 03c2beb..4900bd0 100644 --- a/ash/shelf/shelf_delegate.h +++ b/ash/shelf/shelf_delegate.h @@ -6,7 +6,7 @@ #define ASH_SHELF_SHELF_DELEGATE_H_ #include "ash/ash_export.h" -#include "ash/launcher/launcher_types.h" +#include "ash/shelf/shelf_item_types.h" namespace ash { class Shelf; @@ -26,10 +26,10 @@ class ASH_EXPORT ShelfDelegate { virtual void OnShelfDestroyed(Shelf* shelf) = 0; // Get the shelf ID from an application ID. - virtual LauncherID GetLauncherIDForAppID(const std::string& app_id) = 0; + virtual ShelfID GetShelfIDForAppID(const std::string& app_id) = 0; - // Get the application ID for a given launcher ID. - virtual const std::string& GetAppIDForLauncherID(LauncherID id) = 0; + // Get the application ID for a given shelf ID. + virtual const std::string& GetAppIDForShelfID(ShelfID id) = 0; // Pins an app with |app_id| to shelf. A running instance will get pinned. // In case there is no running instance a new shelf item is created and diff --git a/ash/shelf/shelf_item_delegate.h b/ash/shelf/shelf_item_delegate.h index 6ac81b3..46f282a 100644 --- a/ash/shelf/shelf_item_delegate.h +++ b/ash/shelf/shelf_item_delegate.h @@ -21,7 +21,7 @@ namespace ash { class ShelfMenuModel; -// Delegate for the LauncherItem. +// Delegate for the ShelfItem. class ASH_EXPORT ShelfItemDelegate { public: virtual ~ShelfItemDelegate() {} diff --git a/ash/shelf/shelf_item_delegate_manager.cc b/ash/shelf/shelf_item_delegate_manager.cc index 79124ca..d5b3d04 100644 --- a/ash/shelf/shelf_item_delegate_manager.cc +++ b/ash/shelf/shelf_item_delegate_manager.cc @@ -25,7 +25,7 @@ ShelfItemDelegateManager::~ShelfItemDelegateManager() { } void ShelfItemDelegateManager::SetShelfItemDelegate( - LauncherID id, + ShelfID id, scoped_ptr<ShelfItemDelegate> item_delegate) { // If another ShelfItemDelegate is already registered for |id|, we assume // that this request is replacing ShelfItemDelegate for |id| with @@ -34,10 +34,9 @@ void ShelfItemDelegateManager::SetShelfItemDelegate( id_to_item_delegate_map_[id] = item_delegate.release(); } -ShelfItemDelegate* ShelfItemDelegateManager::GetShelfItemDelegate( - LauncherID id) { +ShelfItemDelegate* ShelfItemDelegateManager::GetShelfItemDelegate(ShelfID id) { if (model_->ItemIndexByID(id) != -1) { - // Each LauncherItem has to have a ShelfItemDelegate. + // Each ShelfItem has to have a ShelfItemDelegate. DCHECK(id_to_item_delegate_map_.find(id) != id_to_item_delegate_map_.end()); return id_to_item_delegate_map_[id]; } @@ -47,7 +46,7 @@ ShelfItemDelegate* ShelfItemDelegateManager::GetShelfItemDelegate( void ShelfItemDelegateManager::ShelfItemAdded(int index) { } -void ShelfItemDelegateManager::ShelfItemRemoved(int index, LauncherID id) { +void ShelfItemDelegateManager::ShelfItemRemoved(int index, ShelfID id) { RemoveShelfItemDelegate(id); } @@ -56,13 +55,13 @@ void ShelfItemDelegateManager::ShelfItemMoved(int start_index, } void ShelfItemDelegateManager::ShelfItemChanged(int index, - const LauncherItem& old_item) { + const ShelfItem& old_item) { } void ShelfItemDelegateManager::ShelfStatusChanged() { } -void ShelfItemDelegateManager::RemoveShelfItemDelegate(LauncherID id) { +void ShelfItemDelegateManager::RemoveShelfItemDelegate(ShelfID id) { if (id_to_item_delegate_map_.find(id) != id_to_item_delegate_map_.end()) { delete id_to_item_delegate_map_[id]; id_to_item_delegate_map_.erase(id); diff --git a/ash/shelf/shelf_item_delegate_manager.h b/ash/shelf/shelf_item_delegate_manager.h index dc4df73..ef11f68 100644 --- a/ash/shelf/shelf_item_delegate_manager.h +++ b/ash/shelf/shelf_item_delegate_manager.h @@ -8,7 +8,7 @@ #include <map> #include "ash/ash_export.h" -#include "ash/launcher/launcher_types.h" +#include "ash/shelf/shelf_item_types.h" #include "ash/shelf/shelf_model_observer.h" #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" @@ -32,32 +32,32 @@ class ASH_EXPORT ShelfItemDelegateManager : public ShelfModelObserver { virtual ~ShelfItemDelegateManager(); // Set |item_delegate| for |id| and take an ownership. - void SetShelfItemDelegate(LauncherID id, + void SetShelfItemDelegate(ShelfID id, scoped_ptr<ShelfItemDelegate> item_delegate); // Returns ShelfItemDelegate for |item_type|. Always returns non-NULL. - ShelfItemDelegate* GetShelfItemDelegate(LauncherID id); + ShelfItemDelegate* GetShelfItemDelegate(ShelfID id); // ShelfModelObserver overrides: virtual void ShelfItemAdded(int model_index) OVERRIDE; - virtual void ShelfItemRemoved(int index, LauncherID id) OVERRIDE; + virtual void ShelfItemRemoved(int index, ShelfID id) OVERRIDE; virtual void ShelfItemMoved(int start_index, int targetindex) OVERRIDE; virtual void ShelfItemChanged(int index, - const LauncherItem& old_item) OVERRIDE; + const ShelfItem& old_item) OVERRIDE; virtual void ShelfStatusChanged() OVERRIDE; private: friend class test::ShelfItemDelegateManagerTestAPI; - typedef std::map<LauncherID, ShelfItemDelegate*> LauncherIDToItemDelegateMap; + typedef std::map<ShelfID, ShelfItemDelegate*> ShelfIDToItemDelegateMap; // Remove and destroy ShelfItemDelegate for |id|. - void RemoveShelfItemDelegate(LauncherID id); + void RemoveShelfItemDelegate(ShelfID id); // Owned by Shell. ShelfModel* model_; - LauncherIDToItemDelegateMap id_to_item_delegate_map_; + ShelfIDToItemDelegateMap id_to_item_delegate_map_; DISALLOW_COPY_AND_ASSIGN(ShelfItemDelegateManager); }; diff --git a/ash/shelf/shelf_item_types.cc b/ash/shelf/shelf_item_types.cc index 609e7bd..2e312bf 100644 --- a/ash/shelf/shelf_item_types.cc +++ b/ash/shelf/shelf_item_types.cc @@ -8,6 +8,15 @@ namespace ash { +ShelfItem::ShelfItem() + : type(TYPE_UNDEFINED), + id(kInvalidShelfID), + status(STATUS_CLOSED) { +} + +ShelfItem::~ShelfItem() { +} + ShelfItemDetails::ShelfItemDetails() : type(TYPE_UNDEFINED), image_resource_id(kInvalidImageResourceID) { diff --git a/ash/shelf/shelf_item_types.h b/ash/shelf/shelf_item_types.h index d18c41a..9dc8355 100644 --- a/ash/shelf/shelf_item_types.h +++ b/ash/shelf/shelf_item_types.h @@ -5,11 +5,16 @@ #ifndef ASH_SHELF_SHELF_ITEM_TYPES_H_ #define ASH_SHELF_SHELF_ITEM_TYPES_H_ +#include <vector> + #include "ash/ash_export.h" #include "base/strings/string16.h" +#include "ui/gfx/image/image_skia.h" namespace ash { +typedef int ShelfID; + // The type of a shelf item. enum ShelfItemType { // Represents a running app panel. @@ -49,6 +54,24 @@ enum ShelfItemStatus { STATUS_ATTENTION, }; +struct ASH_EXPORT ShelfItem { + ShelfItem(); + ~ShelfItem(); + + ShelfItemType type; + + // Image to display in the shelf. + gfx::ImageSkia image; + + // Assigned by the model when the item is added. + ShelfID id; + + // Running status. + ShelfItemStatus status; +}; + +typedef std::vector<ShelfItem> ShelfItems; + // ShelfItemDetails may be set on Window (by way of // SetShelfItemDetailsForWindow) to make the window appear in the shelf. See // ShelfWindowWatcher for details. diff --git a/ash/shelf/shelf_model.cc b/ash/shelf/shelf_model.cc index 7f98bba..2760d8f 100644 --- a/ash/shelf/shelf_model.cc +++ b/ash/shelf/shelf_model.cc @@ -58,7 +58,7 @@ int ShelfItemTypeToWeight(ShelfItemType type) { return 1; } -bool CompareByWeight(const LauncherItem& a, const LauncherItem& b) { +bool CompareByWeight(const ShelfItem& a, const ShelfItem& b) { return ShelfItemTypeToWeight(a.type) < ShelfItemTypeToWeight(b.type); } @@ -70,11 +70,11 @@ ShelfModel::ShelfModel() : next_id_(1), status_(STATUS_NORMAL) { ShelfModel::~ShelfModel() { } -int ShelfModel::Add(const LauncherItem& item) { +int ShelfModel::Add(const ShelfItem& item) { return AddAt(items_.size(), item); } -int ShelfModel::AddAt(int index, const LauncherItem& item) { +int ShelfModel::AddAt(int index, const ShelfItem& item) { index = ValidateInsertionIndex(item.type, index); items_.insert(items_.begin() + index, item); items_[index].id = next_id_++; @@ -87,7 +87,7 @@ void ShelfModel::RemoveItemAt(int index) { // The app list and browser shortcut can't be removed. DCHECK(items_[index].type != TYPE_APP_LIST && items_[index].type != TYPE_BROWSER_SHORTCUT); - LauncherID id = items_[index].id; + ShelfID id = items_[index].id; items_.erase(items_.begin() + index); FOR_EACH_OBSERVER(ShelfModelObserver, observers_, ShelfItemRemoved(index, id)); @@ -97,19 +97,19 @@ void ShelfModel::Move(int index, int target_index) { if (index == target_index) return; // TODO: this needs to enforce valid ranges. - LauncherItem item(items_[index]); + ShelfItem item(items_[index]); items_.erase(items_.begin() + index); items_.insert(items_.begin() + target_index, item); FOR_EACH_OBSERVER(ShelfModelObserver, observers_, ShelfItemMoved(index, target_index)); } -void ShelfModel::Set(int index, const LauncherItem& item) { +void ShelfModel::Set(int index, const ShelfItem& item) { DCHECK(index >= 0 && index < item_count()); int new_index = item.type == items_[index].type ? index : ValidateInsertionIndex(item.type, index); - LauncherItem old_item(items_[index]); + ShelfItem old_item(items_[index]); items_[index] = item; items_[index].id = old_item.id; FOR_EACH_OBSERVER(ShelfModelObserver, observers_, @@ -130,8 +130,8 @@ void ShelfModel::Set(int index, const LauncherItem& item) { } } -int ShelfModel::ItemIndexByID(LauncherID id) const { - LauncherItems::const_iterator i = ItemByID(id); +int ShelfModel::ItemIndexByID(ShelfID id) const { + ShelfItems::const_iterator i = ItemByID(id); return i == items_.end() ? -1 : static_cast<int>(i - items_.begin()); } @@ -143,8 +143,8 @@ int ShelfModel::GetItemIndexForType(ShelfItemType type) { return -1; } -LauncherItems::const_iterator ShelfModel::ItemByID(int id) const { - for (LauncherItems::const_iterator i = items_.begin(); +ShelfItems::const_iterator ShelfModel::ItemByID(int id) const { + for (ShelfItems::const_iterator i = items_.begin(); i != items_.end(); ++i) { if (i->id == id) return i; @@ -157,14 +157,14 @@ int ShelfModel::FirstRunningAppIndex() const { // to explicitly change different running application types. DCHECK_EQ(ShelfItemTypeToWeight(TYPE_WINDOWED_APP), ShelfItemTypeToWeight(TYPE_PLATFORM_APP)); - LauncherItem weight_dummy; + ShelfItem weight_dummy; weight_dummy.type = TYPE_WINDOWED_APP; return std::lower_bound(items_.begin(), items_.end(), weight_dummy, CompareByWeight) - items_.begin(); } int ShelfModel::FirstPanelIndex() const { - LauncherItem weight_dummy; + ShelfItem weight_dummy; weight_dummy.type = TYPE_APP_PANEL; return std::lower_bound(items_.begin(), items_.end(), weight_dummy, CompareByWeight) - items_.begin(); @@ -191,14 +191,14 @@ int ShelfModel::ValidateInsertionIndex(ShelfItemType type, int index) const { (ash::switches::UseAlternateShelfLayout() ? 1 : 0)); // Clamp |index| to the allowed range for the type as determined by |weight|. - LauncherItem weight_dummy; + ShelfItem weight_dummy; weight_dummy.type = type; index = std::max(std::lower_bound(items_.begin(), items_.end(), weight_dummy, CompareByWeight) - items_.begin(), - static_cast<LauncherItems::difference_type>(index)); + static_cast<ShelfItems::difference_type>(index)); index = std::min(std::upper_bound(items_.begin(), items_.end(), weight_dummy, CompareByWeight) - items_.begin(), - static_cast<LauncherItems::difference_type>(index)); + static_cast<ShelfItems::difference_type>(index)); return index; } diff --git a/ash/shelf/shelf_model.h b/ash/shelf/shelf_model.h index 1e89462..3b57c2a 100644 --- a/ash/shelf/shelf_model.h +++ b/ash/shelf/shelf_model.h @@ -6,7 +6,7 @@ #define ASH_SHELF_SHELF_MODEL_H_ #include "ash/ash_export.h" -#include "ash/launcher/launcher_types.h" +#include "ash/shelf/shelf_item_types.h" #include "base/basictypes.h" #include "base/observer_list.h" @@ -27,11 +27,11 @@ class ASH_EXPORT ShelfModel { ~ShelfModel(); // Adds a new item to the model. Returns the resulting index. - int Add(const LauncherItem& item); + int Add(const ShelfItem& item); // Adds the item. |index| is the requested insertion index, which may be // modified to meet type-based ordering. Returns the actual insertion index. - int AddAt(int index, const LauncherItem& item); + int AddAt(int index, const ShelfItem& item); // Removes the item at |index|. void RemoveItemAt(int index); @@ -42,10 +42,10 @@ class ASH_EXPORT ShelfModel { // Resets the item at the specified index. The item maintains its existing // id and type. - void Set(int index, const LauncherItem& item); + void Set(int index, const ShelfItem& item); // Returns the index of the item by id. - int ItemIndexByID(LauncherID id) const; + int ItemIndexByID(ShelfID id) const; // Returns the |index| of the item matching |type| in |items_|. // Returns -1 if the matching item is not found. @@ -62,16 +62,16 @@ class ASH_EXPORT ShelfModel { int FirstPanelIndex() const; // Returns the id assigned to the next item added. - LauncherID next_id() const { return next_id_; } + ShelfID next_id() const { return next_id_; } // Returns a reserved id which will not be used by the |ShelfModel|. - LauncherID reserve_external_id() { return next_id_++; } + ShelfID reserve_external_id() { return next_id_++; } // Returns an iterator into items() for the item with the specified id, or // items().end() if there is no item with the specified id. - LauncherItems::const_iterator ItemByID(LauncherID id) const; + ShelfItems::const_iterator ItemByID(ShelfID id) const; - const LauncherItems& items() const { return items_; } + const ShelfItems& items() const { return items_; } int item_count() const { return static_cast<int>(items_.size()); } void SetStatus(Status status); @@ -87,9 +87,9 @@ class ASH_EXPORT ShelfModel { int ValidateInsertionIndex(ShelfItemType type, int index) const; // ID assigned to the next item. - LauncherID next_id_; + ShelfID next_id_; - LauncherItems items_; + ShelfItems items_; Status status_; ObserverList<ShelfModelObserver> observers_; diff --git a/ash/shelf/shelf_model_observer.h b/ash/shelf/shelf_model_observer.h index 6d9f21f..a65e5cf 100644 --- a/ash/shelf/shelf_model_observer.h +++ b/ash/shelf/shelf_model_observer.h @@ -6,11 +6,11 @@ #define ASH_SHELF_SHELF_MODEL_OBSERVER_H_ #include "ash/ash_export.h" -#include "ash/launcher/launcher_types.h" +#include "ash/shelf/shelf_item_types.h" namespace ash { -struct LauncherItem; +struct ShelfItem; class ASH_EXPORT ShelfModelObserver { public: @@ -19,7 +19,7 @@ class ASH_EXPORT ShelfModelObserver { // Invoked after an item has been removed. |index| is the index the item was // at. - virtual void ShelfItemRemoved(int index, LauncherID id) = 0; + virtual void ShelfItemRemoved(int index, ShelfID id) = 0; // Invoked after an item has been moved. See ShelfModel::Move() for details // of the arguments. @@ -27,7 +27,7 @@ class ASH_EXPORT ShelfModelObserver { // Invoked when the state of an item changes. |old_item| is the item // before the change. - virtual void ShelfItemChanged(int index, const LauncherItem& old_item) = 0; + virtual void ShelfItemChanged(int index, const ShelfItem& old_item) = 0; // Invoked when shelf status is changed. virtual void ShelfStatusChanged() = 0; diff --git a/ash/shelf/shelf_model_unittest.cc b/ash/shelf/shelf_model_unittest.cc index 7a36d0e..8fc120c 100644 --- a/ash/shelf/shelf_model_unittest.cc +++ b/ash/shelf/shelf_model_unittest.cc @@ -43,11 +43,11 @@ class TestShelfModelObserver : public ShelfModelObserver { virtual void ShelfItemAdded(int index) OVERRIDE { added_count_++; } - virtual void ShelfItemRemoved(int index, LauncherID id) OVERRIDE { + virtual void ShelfItemRemoved(int index, ShelfID id) OVERRIDE { removed_count_++; } virtual void ShelfItemChanged(int index, - const LauncherItem& old_item) OVERRIDE { + const ShelfItem& old_item) OVERRIDE { changed_count_++; } virtual void ShelfItemMoved(int start_index, int target_index) OVERRIDE { @@ -85,7 +85,7 @@ class ShelfModelTest : public testing::Test { observer_.reset(new TestShelfModelObserver); EXPECT_EQ(0, model_->item_count()); - LauncherItem item; + ShelfItem item; item.type = TYPE_APP_LIST; model_->Add(item); EXPECT_EQ(1, model_->item_count()); @@ -107,14 +107,14 @@ class ShelfModelTest : public testing::Test { TEST_F(ShelfModelTest, BasicAssertions) { // Add an item. - LauncherItem item; + ShelfItem item; item.type = TYPE_APP_SHORTCUT; int index = model_->Add(item); EXPECT_EQ(2, model_->item_count()); EXPECT_EQ("added=1", observer_->StateStringAndClear()); // Change to a platform app item. - LauncherID original_id = model_->items()[index].id; + ShelfID original_id = model_->items()[index].id; item.type = TYPE_PLATFORM_APP; model_->Set(index, item); EXPECT_EQ(original_id, model_->items()[index].id); @@ -150,7 +150,7 @@ TEST_F(ShelfModelTest, BasicAssertions) { EXPECT_EQ("moved=1", observer_->StateStringAndClear()); // Verifies all the items get unique ids. - std::set<LauncherID> ids; + std::set<ShelfID> ids; for (int i = 0; i < model_->item_count(); ++i) ids.insert(model_->items()[i].id); EXPECT_EQ(model_->item_count(), static_cast<int>(ids.size())); @@ -159,13 +159,13 @@ TEST_F(ShelfModelTest, BasicAssertions) { // Assertions around where items are added. TEST_F(ShelfModelTest, AddIndices) { // Insert browser short cut at index 1. - LauncherItem browser_shortcut; + ShelfItem browser_shortcut; browser_shortcut.type = TYPE_BROWSER_SHORTCUT; int browser_shortcut_index = model_->Add(browser_shortcut); EXPECT_EQ(1, browser_shortcut_index); // platform app items should be after browser shortcut. - LauncherItem item; + ShelfItem item; item.type = TYPE_PLATFORM_APP; int platform_app_index1 = model_->Add(item); EXPECT_EQ(2, platform_app_index1); @@ -241,7 +241,7 @@ TEST_F(ShelfModelTest, AddIndices) { TEST_F(ShelfModelTest, FirstRunningAppIndexUsingWindowedAppFirst) { // Insert the browser shortcut at index 1 and check that the running // application index would be behind it. - LauncherItem item; + ShelfItem item; item.type = TYPE_BROWSER_SHORTCUT; EXPECT_EQ(1, model_->Add(item)); EXPECT_EQ(2, model_->FirstRunningAppIndex()); @@ -274,7 +274,7 @@ TEST_F(ShelfModelTest, FirstRunningAppIndexUsingWindowedAppFirst) { TEST_F(ShelfModelTest, FirstRunningAppIndexUsingPlatformAppFirst) { // Insert the browser shortcut at index 1 and check that the running // application index would be behind it. - LauncherItem item; + ShelfItem item; item.type = TYPE_BROWSER_SHORTCUT; EXPECT_EQ(1, model_->Add(item)); EXPECT_EQ(2, model_->FirstRunningAppIndex()); @@ -308,13 +308,13 @@ TEST_F(ShelfModelTest, AddIndicesForLegacyShelfLayout) { ash::switches::kAshDisableAlternateShelfLayout); // Insert browser short cut at index 0. - LauncherItem browser_shortcut; + ShelfItem browser_shortcut; browser_shortcut.type = TYPE_BROWSER_SHORTCUT; int browser_shortcut_index = model_->Add(browser_shortcut); EXPECT_EQ(0, browser_shortcut_index); // platform app items should be after browser shortcut. - LauncherItem item; + ShelfItem item; item.type = TYPE_PLATFORM_APP; int platform_app_index1 = model_->Add(item); EXPECT_EQ(1, platform_app_index1); @@ -386,9 +386,9 @@ TEST_F(ShelfModelTest, AddIndicesForLegacyShelfLayout) { } // Assertions around id generation and usage. -TEST_F(ShelfModelTest, LauncherIDTests) { +TEST_F(ShelfModelTest, ShelfIDTests) { // Get the next to use ID counter. - LauncherID id = model_->next_id(); + ShelfID id = model_->next_id(); // Calling this function multiple times does not change the returned ID. EXPECT_EQ(model_->next_id(), id); @@ -398,11 +398,11 @@ TEST_F(ShelfModelTest, LauncherIDTests) { // produce something new. EXPECT_EQ(model_->reserve_external_id(), id); EXPECT_EQ(1, model_->item_count()); - LauncherID id2 = model_->next_id(); + ShelfID id2 = model_->next_id(); EXPECT_NE(id2, id); // Adding another item to the list should also produce a new ID. - LauncherItem item; + ShelfItem item; item.type = TYPE_PLATFORM_APP; model_->Add(item); EXPECT_NE(model_->next_id(), id2); @@ -413,14 +413,14 @@ TEST_F(ShelfModelTest, LauncherIDTests) { // location. See crbug.com/248769. TEST_F(ShelfModelTest, CorrectMoveItemsWhenStateChange) { // The first item is the app list and last item is the browser. - LauncherItem browser_shortcut; + ShelfItem browser_shortcut; browser_shortcut.type = TYPE_BROWSER_SHORTCUT; int browser_shortcut_index = model_->Add(browser_shortcut); EXPECT_EQ(TYPE_APP_LIST, model_->items()[0].type); EXPECT_EQ(1, browser_shortcut_index); // Add three shortcuts. They should all be moved between the two. - LauncherItem item; + ShelfItem item; item.type = TYPE_APP_SHORTCUT; int app1_index = model_->Add(item); EXPECT_EQ(2, app1_index); @@ -443,14 +443,14 @@ TEST_F(ShelfModelTest, CorrectMoveItemsWhenStateChangeForLegacyShelfLayout) { ash::switches::kAshDisableAlternateShelfLayout); // The first item is the browser and the second item is app list. - LauncherItem browser_shortcut; + ShelfItem browser_shortcut; browser_shortcut.type = TYPE_BROWSER_SHORTCUT; int browser_shortcut_index = model_->Add(browser_shortcut); EXPECT_EQ(0, browser_shortcut_index); EXPECT_EQ(TYPE_APP_LIST, model_->items()[1].type); // Add three shortcuts. They should all be moved between the two. - LauncherItem item; + ShelfItem item; item.type = TYPE_APP_SHORTCUT; int app1_index = model_->Add(item); EXPECT_EQ(1, app1_index); diff --git a/ash/shelf/shelf_navigator.cc b/ash/shelf/shelf_navigator.cc index 9530b31..7a9310c 100644 --- a/ash/shelf/shelf_navigator.cc +++ b/ash/shelf/shelf_navigator.cc @@ -23,13 +23,13 @@ bool ShouldSkip(ShelfItemType type) { int GetNextActivatedItemIndex(const ShelfModel& model, CycleDirection direction) { - const LauncherItems& items = model.items(); + const ShelfItems& items = model.items(); int item_count = model.item_count(); int current_index = -1; int first_running = -1; for (int i = 0; i < item_count; ++i) { - const LauncherItem& item = items[i]; + const ShelfItem& item = items[i]; if (ShouldSkip(item.type)) continue; @@ -55,7 +55,7 @@ int GetNextActivatedItemIndex(const ShelfModel& model, // Find the next item and activate it. for (int i = (current_index + step + item_count) % item_count; i != current_index; i = (i + step + item_count) % item_count) { - const LauncherItem& item = items[i]; + const ShelfItem& item = items[i]; if (ShouldSkip(item.type)) continue; diff --git a/ash/shelf/shelf_navigator_unittest.cc b/ash/shelf/shelf_navigator_unittest.cc index cf9e5d3..7807ecc 100644 --- a/ash/shelf/shelf_navigator_unittest.cc +++ b/ash/shelf/shelf_navigator_unittest.cc @@ -25,7 +25,7 @@ class ShelfNavigatorTest : public testing::Test { model_.reset(new ShelfModel); // Add APP_LIST for test. - LauncherItem app_list; + ShelfItem app_list; app_list.type = TYPE_APP_LIST; model_->Add(app_list); @@ -35,7 +35,7 @@ class ShelfNavigatorTest : public testing::Test { EXPECT_TRUE(model_->items()[0].type == TYPE_APP_LIST); // Add BROWSER_SHORTCUT for test. - LauncherItem browser_shortcut; + ShelfItem browser_shortcut; browser_shortcut.type = TYPE_BROWSER_SHORTCUT; model_->Add(browser_shortcut); } @@ -44,7 +44,7 @@ class ShelfNavigatorTest : public testing::Test { int types_length, int focused_index) { for (int i = 0; i < types_length; ++i) { - LauncherItem new_item; + ShelfItem new_item; new_item.type = types[i]; new_item.status = (types[i] == TYPE_PLATFORM_APP) ? STATUS_RUNNING : STATUS_CLOSED; @@ -53,7 +53,7 @@ class ShelfNavigatorTest : public testing::Test { // Set the focused item. if (focused_index >= 0) { - LauncherItem focused_item =model_->items()[focused_index]; + ShelfItem focused_item =model_->items()[focused_index]; if (focused_item.type == TYPE_PLATFORM_APP) { focused_item.status = STATUS_ACTIVE; model_->Set(focused_index, focused_item); diff --git a/ash/shelf/shelf_unittest.cc b/ash/shelf/shelf_unittest.cc index 5a7369e..475ee83 100644 --- a/ash/shelf/shelf_unittest.cc +++ b/ash/shelf/shelf_unittest.cc @@ -89,13 +89,13 @@ class ShelfTest : public ash::test::AshTestBase { DISALLOW_COPY_AND_ASSIGN(ShelfTest); }; -// Confirms that LauncherItem reflects the appropriated state. +// Confirms that ShelfItem reflects the appropriated state. TEST_F(ShelfTest, StatusReflection) { // Initially we have the app list. int button_count = test_api()->GetButtonCount(); // Add running platform app. - LauncherItem item; + ShelfItem item; item.type = TYPE_PLATFORM_APP; item.status = STATUS_RUNNING; int index = shelf_model()->Add(item); @@ -115,7 +115,7 @@ TEST_F(ShelfTest, checkHoverAfterMenu) { int button_count = test_api()->GetButtonCount(); // Add running platform app. - LauncherItem item; + ShelfItem item; item.type = TYPE_PLATFORM_APP; item.status = STATUS_RUNNING; int index = shelf_model()->Add(item); @@ -136,12 +136,12 @@ TEST_F(ShelfTest, checkHoverAfterMenu) { } TEST_F(ShelfTest, ShowOverflowBubble) { - LauncherID first_item_id = shelf_model()->next_id(); + ShelfID first_item_id = shelf_model()->next_id(); // Add platform app button until overflow. int items_added = 0; while (!test_api()->IsOverflowButtonVisible()) { - LauncherItem item; + ShelfItem item; item.type = TYPE_PLATFORM_APP; item.status = STATUS_RUNNING; shelf_model()->Add(item); diff --git a/ash/shelf/shelf_util.cc b/ash/shelf/shelf_util.cc index 8149640..7a7b151 100644 --- a/ash/shelf/shelf_util.cc +++ b/ash/shelf/shelf_util.cc @@ -7,29 +7,29 @@ #include "ash/shelf/shelf_constants.h" #include "ui/aura/window_property.h" -DECLARE_WINDOW_PROPERTY_TYPE(ash::LauncherID); +DECLARE_WINDOW_PROPERTY_TYPE(ash::ShelfID); DECLARE_WINDOW_PROPERTY_TYPE(ash::ShelfItemDetails*); namespace ash { -DEFINE_LOCAL_WINDOW_PROPERTY_KEY(LauncherID, kLauncherID, kInvalidShelfID); +DEFINE_LOCAL_WINDOW_PROPERTY_KEY(ShelfID, kShelfID, kInvalidShelfID); -// ShelfItemDetails for kLauncherItemDetaildKey is owned by the window +// ShelfItemDetails for kShelfItemDetaildKey is owned by the window // and will be freed automatically. DEFINE_OWNED_WINDOW_PROPERTY_KEY(ShelfItemDetails, kShelfItemDetailsKey, NULL); -void SetLauncherIDForWindow(LauncherID id, aura::Window* window) { +void SetShelfIDForWindow(ShelfID id, aura::Window* window) { if (!window) return; - window->SetProperty(kLauncherID, id); + window->SetProperty(kShelfID, id); } -LauncherID GetLauncherIDForWindow(aura::Window* window) { +ShelfID GetShelfIDForWindow(aura::Window* window) { DCHECK(window); - return window->GetProperty(kLauncherID); + return window->GetProperty(kShelfID); } void SetShelfItemDetailsForWindow(aura::Window* window, diff --git a/ash/shelf/shelf_util.h b/ash/shelf/shelf_util.h index ce83dcc..f4c4b80 100644 --- a/ash/shelf/shelf_util.h +++ b/ash/shelf/shelf_util.h @@ -6,7 +6,6 @@ #define ASH_SHELF_SHELF_UTIL_H_ #include "ash/ash_export.h" -#include "ash/launcher/launcher_types.h" #include "ash/shelf/shelf_item_types.h" #include "ui/aura/window.h" @@ -19,21 +18,21 @@ namespace ash { extern const aura::WindowProperty<ShelfItemDetails*>* const kShelfItemDetailsKey; -// Associates LauncherItem of |id| with specified |window|. -ASH_EXPORT void SetLauncherIDForWindow(LauncherID id, aura::Window* window); +// Associates ShelfItem of |id| with specified |window|. +ASH_EXPORT void SetShelfIDForWindow(ShelfID id, aura::Window* window); -// Returns the id of the LauncherItem associated with the specified |window|, +// Returns the id of the ShelfItem associated with the specified |window|, // or 0 if there isn't one. -// Note: Window of a tabbed browser will return the |LauncherID| of the +// Note: Window of a tabbed browser will return the |ShelfID| of the // currently active tab. -ASH_EXPORT LauncherID GetLauncherIDForWindow(aura::Window* window); +ASH_EXPORT ShelfID GetShelfIDForWindow(aura::Window* window); // Sets ShelfItemDetails for |window|. ASH_EXPORT void SetShelfItemDetailsForWindow(aura::Window* window, const ShelfItemDetails& details); // Clears ShelfItemDetails for |window|. -// If |window| has a LauncherItem by SetShelfItemDetailsForWindow(), it will +// If |window| has a ShelfItem by SetShelfItemDetailsForWindow(), it will // be removed. ASH_EXPORT void ClearShelfItemDetailsForWindow(aura::Window* window); diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc index 5796796..8ce493e 100644 --- a/ash/shelf/shelf_view.cc +++ b/ash/shelf/shelf_view.cc @@ -294,7 +294,7 @@ class FadeInAnimationDelegate DISALLOW_COPY_AND_ASSIGN(FadeInAnimationDelegate); }; -void ReflectItemStatus(const LauncherItem& item, ShelfButton* button) { +void ReflectItemStatus(const ShelfItem& item, ShelfButton* button) { switch (item.status) { case STATUS_CLOSED: button->ClearState(ShelfButton::STATE_ACTIVE); @@ -397,7 +397,7 @@ ShelfView::ShelfView(ShelfModel* model, closing_event_time_(base::TimeDelta()), got_deleted_(NULL), drag_and_drop_item_pinned_(false), - drag_and_drop_launcher_id_(0), + drag_and_drop_shelf_id_(0), dragged_off_shelf_(false), snap_back_from_rip_off_view_(NULL), item_manager_(Shell::GetInstance()->shelf_item_delegate_manager()), @@ -425,8 +425,8 @@ ShelfView::~ShelfView() { void ShelfView::Init() { model_->AddObserver(this); - const LauncherItems& items(model_->items()); - for (LauncherItems::const_iterator i = items.begin(); i != items.end(); ++i) { + const ShelfItems& items(model_->items()); + for (ShelfItems::const_iterator i = items.begin(); i != items.end(); ++i) { views::View* child = CreateViewForItem(*i); child->SetPaintToLayer(true); view_model_->Add(child, static_cast<int>(i - items.begin())); @@ -479,7 +479,7 @@ void ShelfView::SchedulePaintForAllButtons() { overflow_button_->SchedulePaint(); } -gfx::Rect ShelfView::GetIdealBoundsOfItemIcon(LauncherID id) { +gfx::Rect ShelfView::GetIdealBoundsOfItemIcon(ShelfID id) { int index = model_->ItemIndexByID(id); if (index == -1 || (index > last_visible_index_ && index < model_->FirstPanelIndex())) @@ -495,7 +495,7 @@ gfx::Rect ShelfView::GetIdealBoundsOfItemIcon(LauncherID id) { icon_bounds.height()); } -void ShelfView::UpdatePanelIconPosition(LauncherID id, +void ShelfView::UpdatePanelIconPosition(ShelfID id, const gfx::Point& midpoint) { int current_index = model_->ItemIndexByID(id); int first_panel_index = model_->FirstPanelIndex(); @@ -597,7 +597,7 @@ bool ShelfView::StartDrag(const std::string& app_id, const gfx::Point& location_in_screen_coordinates) { // Bail if an operation is already going on - or the cursor is not inside. // This could happen if mouse / touch operations overlap. - if (drag_and_drop_launcher_id_ || + if (drag_and_drop_shelf_id_ || !GetBoundsInScreen().Contains(location_in_screen_coordinates)) return false; @@ -606,25 +606,25 @@ bool ShelfView::StartDrag(const std::string& app_id, CancelDrag(-1); drag_and_drop_item_pinned_ = false; drag_and_drop_app_id_ = app_id; - drag_and_drop_launcher_id_ = - delegate_->GetLauncherIDForAppID(drag_and_drop_app_id_); + drag_and_drop_shelf_id_ = + delegate_->GetShelfIDForAppID(drag_and_drop_app_id_); // Check if the application is known and pinned - if not, we have to pin it so // that we can re-arrange the shelf order accordingly. Note that items have // to be pinned to give them the same (order) possibilities as a shortcut. // When an item is dragged from overflow to shelf, IsShowingOverflowBubble() // returns true. At this time, we don't need to pin the item. if (!IsShowingOverflowBubble() && - (!drag_and_drop_launcher_id_ || + (!drag_and_drop_shelf_id_ || !delegate_->IsAppPinned(app_id))) { delegate_->PinAppWithID(app_id); - drag_and_drop_launcher_id_ = - delegate_->GetLauncherIDForAppID(drag_and_drop_app_id_); - if (!drag_and_drop_launcher_id_) + drag_and_drop_shelf_id_ = + delegate_->GetShelfIDForAppID(drag_and_drop_app_id_); + if (!drag_and_drop_shelf_id_) return false; drag_and_drop_item_pinned_ = true; } views::View* drag_and_drop_view = view_model_->view_at( - model_->ItemIndexByID(drag_and_drop_launcher_id_)); + model_->ItemIndexByID(drag_and_drop_shelf_id_)); DCHECK(drag_and_drop_view); // Since there is already an icon presented by the caller, we hide this item @@ -651,13 +651,13 @@ bool ShelfView::StartDrag(const std::string& app_id, } bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) { - if (!drag_and_drop_launcher_id_ || + if (!drag_and_drop_shelf_id_ || !GetBoundsInScreen().Contains(location_in_screen_coordinates)) return false; gfx::Point pt = location_in_screen_coordinates; views::View* drag_and_drop_view = view_model_->view_at( - model_->ItemIndexByID(drag_and_drop_launcher_id_)); + model_->ItemIndexByID(drag_and_drop_shelf_id_)); ConvertPointFromScreen(drag_and_drop_view, &pt); gfx::Point point_in_root = location_in_screen_coordinates; ash::wm::ConvertPointFromScreen( @@ -671,11 +671,11 @@ bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) { } void ShelfView::EndDrag(bool cancel) { - if (!drag_and_drop_launcher_id_) + if (!drag_and_drop_shelf_id_) return; views::View* drag_and_drop_view = view_model_->view_at( - model_->ItemIndexByID(drag_and_drop_launcher_id_)); + model_->ItemIndexByID(drag_and_drop_shelf_id_)); PointerReleasedOnButton( drag_and_drop_view, ShelfButtonHost::DRAG_AND_DROP, cancel); @@ -693,7 +693,7 @@ void ShelfView::EndDrag(bool cancel) { } } - drag_and_drop_launcher_id_ = 0; + drag_and_drop_shelf_id_ = 0; } void ShelfView::LayoutToIdealBounds() { @@ -934,7 +934,7 @@ void ShelfView::AnimateToIdealBounds() { overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds); } -views::View* ShelfView::CreateViewForItem(const LauncherItem& item) { +views::View* ShelfView::CreateViewForItem(const ShelfItem& item) { views::View* view = NULL; switch (item.type) { case TYPE_BROWSER_SHORTCUT: @@ -1031,7 +1031,7 @@ void ShelfView::ContinueDrag(const ui::LocatedEvent& event) { // If this is not a drag and drop host operation and not the app list item, // check if the item got ripped off the shelf - if it did we are done. - if (!drag_and_drop_launcher_id_ && ash::switches::UseDragOffShelf() && + if (!drag_and_drop_shelf_id_ && ash::switches::UseDragOffShelf() && RemovableByRipOff(current_index) != NOT_REMOVABLE) { if (HandleRipOffDrag(event)) return; @@ -1095,7 +1095,7 @@ bool ShelfView::HandleRipOffDrag(const ui::LocatedEvent& event) { int current_index = view_model_->GetIndexOfView(drag_view_); DCHECK_NE(-1, current_index); std::string dragged_app_id = - delegate_->GetAppIDForLauncherID(model_->items()[current_index].id); + delegate_->GetAppIDForShelfID(model_->items()[current_index].id); gfx::Point screen_location = event.root_location(); ash::wm::ConvertPointToScreen(GetWidget()->GetNativeWindow()->GetRootWindow(), @@ -1220,7 +1220,7 @@ void ShelfView::FinalizeRipOffDrag(bool cancel) { // Make sure the item stays invisible upon removal. drag_view_->SetVisible(false); std::string app_id = - delegate_->GetAppIDForLauncherID(model_->items()[current_index].id); + delegate_->GetAppIDForShelfID(model_->items()[current_index].id); delegate_->UnpinAppWithID(app_id); } } @@ -1260,8 +1260,7 @@ ShelfView::RemovableState ShelfView::RemovableByRipOff(int index) { if (type == TYPE_APP_LIST || type == TYPE_DIALOG || !delegate_->CanPin()) return NOT_REMOVABLE; - std::string app_id = - delegate_->GetAppIDForLauncherID(model_->items()[index].id); + std::string app_id = delegate_->GetAppIDForShelfID(model_->items()[index].id); // Note: Only pinned app shortcuts can be removed! return (type == TYPE_APP_SHORTCUT && delegate_->IsAppPinned(app_id)) ? REMOVABLE : DRAGGABLE; @@ -1576,7 +1575,7 @@ void ShelfView::ShelfItemAdded(int model_index) { } } -void ShelfView::ShelfItemRemoved(int model_index, LauncherID id) { +void ShelfView::ShelfItemRemoved(int model_index, ShelfID id) { if (id == context_menu_id_) launcher_menu_runner_.reset(); { @@ -1616,9 +1615,8 @@ void ShelfView::ShelfItemRemoved(int model_index, LauncherID id) { tooltip_->Close(); } -void ShelfView::ShelfItemChanged(int model_index, - const LauncherItem& old_item) { - const LauncherItem& item(model_->items()[model_index]); +void ShelfView::ShelfItemChanged(int model_index, const ShelfItem& old_item) { + const ShelfItem& item(model_->items()[model_index]); if (old_item.type != item.type) { // Type changed, swap the views. model_index = CancelDrag(model_index); @@ -1835,7 +1833,7 @@ void ShelfView::ButtonPressed(views::Button* sender, const ui::Event& event) { } } -bool ShelfView::ShowListMenuForView(const LauncherItem& item, +bool ShelfView::ShowListMenuForView(const ShelfItem& item, views::View* source, const ui::Event& event) { scoped_ptr<ShelfMenuModel> menu_model; @@ -1874,7 +1872,7 @@ void ShelfView::ShowContextMenuForView(views::View* source, if (!menu_model) return; - base::AutoReset<LauncherID> reseter( + base::AutoReset<ShelfID> reseter( &context_menu_id_, view_index == -1 ? 0 : model_->items()[view_index].id); @@ -2013,8 +2011,7 @@ bool ShelfView::IsUsableEvent(const ui::Event& event) { return (delta.InMilliseconds() < 0 || delta.InMilliseconds() > 130); } -const LauncherItem* ShelfView::LauncherItemForView( - const views::View* view) const { +const ShelfItem* ShelfView::ShelfItemForView(const views::View* view) const { int view_index = view_model_->GetIndexOfView(view); if (view_index == -1) return NULL; @@ -2025,7 +2022,7 @@ bool ShelfView::ShouldShowTooltipForView(const views::View* view) const { if (view == GetAppListButtonView() && Shell::GetInstance()->GetAppListWindow()) return false; - const LauncherItem* item = LauncherItemForView(view); + const ShelfItem* item = ShelfItemForView(view); if (!item) return true; ShelfItemDelegate* item_delegate = diff --git a/ash/shelf/shelf_view.h b/ash/shelf/shelf_view.h index 975f617..5f95416 100644 --- a/ash/shelf/shelf_view.h +++ b/ash/shelf/shelf_view.h @@ -36,7 +36,7 @@ class ShelfDelegate; class ShelfIconObserver; class ShelfItemDelegateManager; class ShelfModel; -struct LauncherItem; +struct ShelfItem; namespace internal { @@ -79,10 +79,10 @@ class ASH_EXPORT ShelfView : public views::View, // Returns the ideal bounds of the specified item, or an empty rect if id // isn't know. - gfx::Rect GetIdealBoundsOfItemIcon(LauncherID id); + gfx::Rect GetIdealBoundsOfItemIcon(ShelfID id); // Repositions the icon for the specified item by the midpoint of the window. - void UpdatePanelIconPosition(LauncherID id, const gfx::Point& midpoint); + void UpdatePanelIconPosition(ShelfID id, const gfx::Point& midpoint); void AddIconObserver(ShelfIconObserver* observer); void RemoveIconObserver(ShelfIconObserver* observer); @@ -187,7 +187,7 @@ class ASH_EXPORT ShelfView : public views::View, void AnimateToIdealBounds(); // Creates the view used to represent |item|. - views::View* CreateViewForItem(const LauncherItem& item); + views::View* CreateViewForItem(const ShelfItem& item); // Fades |view| from an opacity of 0 to 1. This is when adding a new item. void FadeIn(views::View* view); @@ -266,9 +266,9 @@ class ASH_EXPORT ShelfView : public views::View, // Overridden from ShelfModelObserver: virtual void ShelfItemAdded(int model_index) OVERRIDE; - virtual void ShelfItemRemoved(int model_index, LauncherID id) OVERRIDE; + virtual void ShelfItemRemoved(int model_index, ShelfID id) OVERRIDE; virtual void ShelfItemChanged(int model_index, - const LauncherItem& old_item) OVERRIDE; + const ShelfItem& old_item) OVERRIDE; virtual void ShelfItemMoved(int start_index, int target_index) OVERRIDE; virtual void ShelfStatusChanged() OVERRIDE; @@ -296,7 +296,7 @@ class ASH_EXPORT ShelfView : public views::View, // choose from. |source| specifies the view which is responsible for showing // the menu, and the bubble will point towards it. // The |event_flags| are the flags of the event which triggered this menu. - bool ShowListMenuForView(const LauncherItem& item, + bool ShowListMenuForView(const ShelfItem& item, views::View* source, const ui::Event& event); @@ -325,7 +325,7 @@ class ASH_EXPORT ShelfView : public views::View, bool IsUsableEvent(const ui::Event& event); // Convenience accessor to model_->items(). - const LauncherItem* LauncherItemForView(const views::View* view) const; + const ShelfItem* ShelfItemForView(const views::View* view) const; // Returns true if a tooltip should be shown for |view|. bool ShouldShowTooltipForView(const views::View* view) const; @@ -376,7 +376,7 @@ class ASH_EXPORT ShelfView : public views::View, int start_drag_index_; // Used for the context menu of a particular item. - LauncherID context_menu_id_; + ShelfID context_menu_id_; scoped_ptr<views::FocusSearch> focus_search_; @@ -408,9 +408,9 @@ class ASH_EXPORT ShelfView : public views::View, // and it needs to be deleted/unpinned again if the operation gets cancelled. bool drag_and_drop_item_pinned_; - // The launcher item which is currently used for a drag and a drop operation + // The ShelfItem which is currently used for a drag and a drop operation // or 0 otherwise. - LauncherID drag_and_drop_launcher_id_; + ShelfID drag_and_drop_shelf_id_; // The application ID of the application which we drag and drop. std::string drag_and_drop_app_id_; diff --git a/ash/shelf/shelf_view_unittest.cc b/ash/shelf/shelf_view_unittest.cc index 5b99ed1..c044ad8 100644 --- a/ash/shelf/shelf_view_unittest.cc +++ b/ash/shelf/shelf_view_unittest.cc @@ -131,7 +131,7 @@ TEST_F(ShelfViewIconObserverTest, AddRemove) { scoped_ptr<views::Widget> widget(new views::Widget()); widget->Init(params); - shelf_delegate->AddLauncherItem(widget->GetNativeWindow()); + shelf_delegate->AddShelfItem(widget->GetNativeWindow()); shelf_view_test()->RunMessageLoopUntilAnimationsDone(); EXPECT_TRUE(observer()->change_notified()); observer()->Reset(); @@ -167,7 +167,7 @@ TEST_F(ShelfViewIconObserverTest, MAYBE_AddRemoveWithMultipleDisplays) { scoped_ptr<views::Widget> widget(new views::Widget()); widget->Init(params); - shelf_delegate->AddLauncherItem(widget->GetNativeWindow()); + shelf_delegate->AddShelfItem(widget->GetNativeWindow()); shelf_view_test()->RunMessageLoopUntilAnimationsDone(); EXPECT_TRUE(observer()->change_notified()); EXPECT_TRUE(second_observer.change_notified()); @@ -211,13 +211,13 @@ class TestShelfDelegateForShelfView : public ShelfDelegate { virtual void OnShelfDestroyed(Shelf* shelf) OVERRIDE {} - virtual LauncherID GetLauncherIDForAppID(const std::string& app_id) OVERRIDE { - LauncherID id = 0; + virtual ShelfID GetShelfIDForAppID(const std::string& app_id) OVERRIDE { + ShelfID id = 0; EXPECT_TRUE(base::StringToInt(app_id, &id)); return id; } - virtual const std::string& GetAppIDForLauncherID(LauncherID id) OVERRIDE { + virtual const std::string& GetAppIDForShelfID(ShelfID id) OVERRIDE { // Use |app_id_| member variable because returning a reference to local // variable is not allowed. app_id_ = base::IntToString(id); @@ -238,7 +238,7 @@ class TestShelfDelegateForShelfView : public ShelfDelegate { } virtual void UnpinAppWithID(const std::string& app_id) OVERRIDE { - LauncherID id = 0; + ShelfID id = 0; EXPECT_TRUE(base::StringToInt(app_id, &id)); ASSERT_GT(id, 0); int index = model_->ItemIndexByID(id); @@ -251,7 +251,7 @@ class TestShelfDelegateForShelfView : public ShelfDelegate { ShelfModel* model_; // Temp member variable for returning a value. See the comment in the - // GetAppIDForLauncherID(). + // GetAppIDForShelfID(). std::string app_id_; DISALLOW_COPY_AND_ASSIGN(TestShelfDelegateForShelfView); @@ -289,91 +289,91 @@ class ShelfViewTest : public AshTestBase { } protected: - void CreateAndSetShelfItemDelegateForID(LauncherID id) { + void CreateAndSetShelfItemDelegateForID(ShelfID id) { scoped_ptr<ShelfItemDelegate> delegate(new TestShelfItemDelegate(NULL)); item_manager_->SetShelfItemDelegate(id, delegate.Pass()); } - LauncherID AddBrowserShortcut() { - LauncherItem browser_shortcut; + ShelfID AddBrowserShortcut() { + ShelfItem browser_shortcut; browser_shortcut.type = TYPE_BROWSER_SHORTCUT; - LauncherID id = model_->next_id(); + ShelfID id = model_->next_id(); model_->AddAt(browser_index_, browser_shortcut); CreateAndSetShelfItemDelegateForID(id); test_api_->RunMessageLoopUntilAnimationsDone(); return id; } - LauncherID AddAppShortcut() { - LauncherItem item; + ShelfID AddAppShortcut() { + ShelfItem item; item.type = TYPE_APP_SHORTCUT; item.status = STATUS_CLOSED; - LauncherID id = model_->next_id(); + ShelfID id = model_->next_id(); model_->Add(item); CreateAndSetShelfItemDelegateForID(id); test_api_->RunMessageLoopUntilAnimationsDone(); return id; } - LauncherID AddPanel() { - LauncherID id = AddPanelNoWait(); + ShelfID AddPanel() { + ShelfID id = AddPanelNoWait(); test_api_->RunMessageLoopUntilAnimationsDone(); return id; } - LauncherID AddPlatformAppNoWait() { - LauncherItem item; + ShelfID AddPlatformAppNoWait() { + ShelfItem item; item.type = TYPE_PLATFORM_APP; item.status = STATUS_RUNNING; - LauncherID id = model_->next_id(); + ShelfID id = model_->next_id(); model_->Add(item); CreateAndSetShelfItemDelegateForID(id); return id; } - LauncherID AddPanelNoWait() { - LauncherItem item; + ShelfID AddPanelNoWait() { + ShelfItem item; item.type = TYPE_APP_PANEL; item.status = STATUS_RUNNING; - LauncherID id = model_->next_id(); + ShelfID id = model_->next_id(); model_->Add(item); CreateAndSetShelfItemDelegateForID(id); return id; } - LauncherID AddPlatformApp() { - LauncherID id = AddPlatformAppNoWait(); + ShelfID AddPlatformApp() { + ShelfID id = AddPlatformAppNoWait(); test_api_->RunMessageLoopUntilAnimationsDone(); return id; } - void RemoveByID(LauncherID id) { + void RemoveByID(ShelfID id) { model_->RemoveItemAt(model_->ItemIndexByID(id)); test_api_->RunMessageLoopUntilAnimationsDone(); } - internal::ShelfButton* GetButtonByID(LauncherID id) { + internal::ShelfButton* GetButtonByID(ShelfID id) { int index = model_->ItemIndexByID(id); return test_api_->GetButton(index); } - LauncherItem GetItemByID(LauncherID id) { - LauncherItems::const_iterator items = model_->ItemByID(id); + ShelfItem GetItemByID(ShelfID id) { + ShelfItems::const_iterator items = model_->ItemByID(id); return *items; } void CheckModelIDs( - const std::vector<std::pair<LauncherID, views::View*> >& id_map) { + const std::vector<std::pair<ShelfID, views::View*> >& id_map) { size_t map_index = 0; for (size_t model_index = 0; model_index < model_->items().size(); ++model_index) { - LauncherItem item = model_->items()[model_index]; - LauncherID id = item.id; + ShelfItem item = model_->items()[model_index]; + ShelfID id = item.id; EXPECT_EQ(id_map[map_index].first, id); EXPECT_EQ(id_map[map_index].second, GetButtonByID(id)); ++map_index; @@ -432,7 +432,7 @@ class ShelfViewTest : public AshTestBase { } void SetupForDragTest( - std::vector<std::pair<LauncherID, views::View*> >* id_map) { + std::vector<std::pair<ShelfID, views::View*> >* id_map) { // Initialize |id_map| with the automatically-created shelf buttons. for (size_t i = 0; i < model_->items().size(); ++i) { internal::ShelfButton* button = test_api_->GetButton(i); @@ -442,7 +442,7 @@ class ShelfViewTest : public AshTestBase { // Add 5 app shelf buttons for testing. for (int i = 0; i < 5; ++i) { - LauncherID id = AddAppShortcut(); + ShelfID id = AddAppShortcut(); // App Icon is located at index 0, and browser shortcut is located at // index 1. So we should start to add app shortcut at index 2. id_map->insert(id_map->begin() + (i + browser_index_ + 1), @@ -489,7 +489,7 @@ class ShelfViewTest : public AshTestBase { int drag_item_index = test_api_for_overflow.GetLastVisibleIndex(); - LauncherID drag_item_id = GetItemId(drag_item_index); + ShelfID drag_item_id = GetItemId(drag_item_index); internal::ShelfButton* drag_button = test_api_for_overflow.GetButton(drag_item_index); gfx::Point center_point_of_drag_item = @@ -555,8 +555,8 @@ class ShelfViewTest : public AshTestBase { } } - // Returns the item's LauncherID at |index|. - LauncherID GetItemId(int index) { + // Returns the item's ShelfID at |index|. + ShelfID GetItemId(int index) { DCHECK_GE(index, 0); return model_->items()[index].id; } @@ -648,7 +648,7 @@ class ShelfViewTextDirectionTest // Checks that the ideal item icon bounds match the view's bounds in the screen // in both LTR and RTL. TEST_P(ShelfViewTextDirectionTest, IdealBoundsOfItemIcon) { - LauncherID id = AddPlatformApp(); + ShelfID id = AddPlatformApp(); internal::ShelfButton* button = GetButtonByID(id); gfx::Rect item_bounds = button->GetBoundsInScreen(); gfx::Point icon_offset = button->GetIconBounds().origin(); @@ -705,7 +705,7 @@ TEST_F(ShelfViewTest, AddBrowserUntilOverflow) { // Add platform app button until overflow. int items_added = 0; - LauncherID last_added = AddPlatformApp(); + ShelfID last_added = AddPlatformApp(); while (!test_api_->IsOverflowButtonVisible()) { // Added button is visible after animation while in this loop. EXPECT_TRUE(GetButtonByID(last_added)->visible()); @@ -727,11 +727,11 @@ TEST_F(ShelfViewTest, AddAppShortcutWithBrowserButtonUntilOverflow) { ASSERT_EQ(test_api_->GetButtonCount(), test_api_->GetLastVisibleIndex() + 1); - LauncherID browser_button_id = AddPlatformApp(); + ShelfID browser_button_id = AddPlatformApp(); // Add app shortcut until overflow. int items_added = 0; - LauncherID last_added = AddAppShortcut(); + ShelfID last_added = AddAppShortcut(); while (!test_api_->IsOverflowButtonVisible()) { // Added button is visible after animation while in this loop. EXPECT_TRUE(GetButtonByID(last_added)->visible()); @@ -752,11 +752,11 @@ TEST_F(ShelfViewLegacyShelfLayoutTest, test_api_->GetLastVisibleIndex() + 1); - LauncherID browser_button_id = AddPlatformApp(); + ShelfID browser_button_id = AddPlatformApp(); // Add app shortcut until overflow. int items_added = 0; - LauncherID last_added = AddAppShortcut(); + ShelfID last_added = AddAppShortcut(); while (!test_api_->IsOverflowButtonVisible()) { // Added button is visible after animation while in this loop. EXPECT_TRUE(GetButtonByID(last_added)->visible()); @@ -780,10 +780,10 @@ TEST_F(ShelfViewTest, AddPanelHidesPlatformAppButton) { // Add platform app button until overflow, remember last visible platform app // button. int items_added = 0; - LauncherID first_added = AddPlatformApp(); + ShelfID first_added = AddPlatformApp(); EXPECT_TRUE(GetButtonByID(first_added)->visible()); while (true) { - LauncherID added = AddPlatformApp(); + ShelfID added = AddPlatformApp(); if (test_api_->IsOverflowButtonVisible()) { EXPECT_FALSE(GetButtonByID(added)->visible()); RemoveByID(added); @@ -793,7 +793,7 @@ TEST_F(ShelfViewTest, AddPanelHidesPlatformAppButton) { ASSERT_LT(items_added, 10000); } - LauncherID panel = AddPanel(); + ShelfID panel = AddPanel(); EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); RemoveByID(panel); @@ -808,11 +808,11 @@ TEST_F(ShelfViewLegacyShelfLayoutTest, AddPanelHidesPlatformAppButton) { // Add platform app button until overflow, remember last visible platform app // button. int items_added = 0; - LauncherID first_added = AddPlatformApp(); + ShelfID first_added = AddPlatformApp(); EXPECT_TRUE(GetButtonByID(first_added)->visible()); - LauncherID last_visible = first_added; + ShelfID last_visible = first_added; while (true) { - LauncherID added = AddPlatformApp(); + ShelfID added = AddPlatformApp(); if (test_api_->IsOverflowButtonVisible()) { EXPECT_FALSE(GetButtonByID(added)->visible()); break; @@ -822,7 +822,7 @@ TEST_F(ShelfViewLegacyShelfLayoutTest, AddPanelHidesPlatformAppButton) { ASSERT_LT(items_added, 10000); } - LauncherID panel = AddPanel(); + ShelfID panel = AddPanel(); EXPECT_TRUE(GetButtonByID(panel)->visible()); EXPECT_FALSE(GetButtonByID(last_visible)->visible()); @@ -838,14 +838,14 @@ TEST_F(ShelfViewTest, PlatformAppHidesExcessPanels) { test_api_->GetLastVisibleIndex() + 1); // Add platform app button. - LauncherID platform_app = AddPlatformApp(); - LauncherID first_panel = AddPanel(); + ShelfID platform_app = AddPlatformApp(); + ShelfID first_panel = AddPanel(); EXPECT_TRUE(GetButtonByID(platform_app)->visible()); EXPECT_TRUE(GetButtonByID(first_panel)->visible()); // Add panels until there is an overflow. - LauncherID last_panel = first_panel; + ShelfID last_panel = first_panel; int items_added = 0; while (!test_api_->IsOverflowButtonVisible()) { last_panel = AddPanel(); @@ -882,8 +882,8 @@ TEST_F(ShelfViewTest, RemoveButtonRevealsOverflowed) { // Add platform app buttons until overflow. int items_added = 0; - LauncherID first_added = AddPlatformApp(); - LauncherID last_added = first_added; + ShelfID first_added = AddPlatformApp(); + ShelfID last_added = first_added; while (!test_api_->IsOverflowButtonVisible()) { last_added = AddPlatformApp(); ++items_added; @@ -912,7 +912,7 @@ TEST_F(ShelfViewTest, RemoveLastOverflowed) { // Add platform app button until overflow. int items_added = 0; - LauncherID last_added = AddPlatformApp(); + ShelfID last_added = AddPlatformApp(); while (!test_api_->IsOverflowButtonVisible()) { last_added = AddPlatformApp(); ++items_added; @@ -959,7 +959,7 @@ TEST_F(ShelfViewTest, AddButtonQuickly) { TEST_F(ShelfViewTest, ModelChangesWhileDragging) { internal::ShelfButtonHost* button_host = shelf_view_; - std::vector<std::pair<LauncherID, views::View*> > id_map; + std::vector<std::pair<ShelfID, views::View*> > id_map; SetupForDragTest(&id_map); // Dragging browser shortcut at index 1. @@ -1002,7 +1002,7 @@ TEST_F(ShelfViewTest, ModelChangesWhileDragging) { // Adding a shelf item cancels the drag and respects the order. dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 1, 3); - LauncherID new_id = AddAppShortcut(); + ShelfID new_id = AddAppShortcut(); id_map.insert(id_map.begin() + 6, std::make_pair(new_id, GetButtonByID(new_id))); ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); @@ -1025,7 +1025,7 @@ TEST_F(ShelfViewTest, ModelChangesWhileDragging) { TEST_F(ShelfViewLegacyShelfLayoutTest, ModelChangesWhileDragging) { internal::ShelfButtonHost* button_host = shelf_view_; - std::vector<std::pair<LauncherID, views::View*> > id_map; + std::vector<std::pair<ShelfID, views::View*> > id_map; SetupForDragTest(&id_map); // Dragging browser shortcut at index 0. @@ -1068,7 +1068,7 @@ TEST_F(ShelfViewLegacyShelfLayoutTest, ModelChangesWhileDragging) { // Adding a shelf item cancels the drag and respects the order. dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 0, 2); - LauncherID new_id = AddAppShortcut(); + ShelfID new_id = AddAppShortcut(); id_map.insert(id_map.begin() + 5, std::make_pair(new_id, GetButtonByID(new_id))); ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); @@ -1092,7 +1092,7 @@ TEST_F(ShelfViewLegacyShelfLayoutTest, ModelChangesWhileDragging) { TEST_F(ShelfViewTest, SimultaneousDrag) { internal::ShelfButtonHost* button_host = shelf_view_; - std::vector<std::pair<LauncherID, views::View*> > id_map; + std::vector<std::pair<ShelfID, views::View*> > id_map; SetupForDragTest(&id_map); // Start a mouse drag. @@ -1139,7 +1139,7 @@ TEST_F(ShelfViewTest, SimultaneousDrag) { TEST_F(ShelfViewTest, ClickOneDragAnother) { internal::ShelfButtonHost* button_host = shelf_view_; - std::vector<std::pair<LauncherID, views::View*> > id_map; + std::vector<std::pair<ShelfID, views::View*> > id_map; SetupForDragTest(&id_map); // A click on item 1 is simulated. @@ -1166,8 +1166,8 @@ TEST_F(ShelfViewTest, ShelfItemStatus) { test_api_->GetLastVisibleIndex() + 1); // Add platform app button. - LauncherID last_added = AddPlatformApp(); - LauncherItem item = GetItemByID(last_added); + ShelfID last_added = AddPlatformApp(); + ShelfItem item = GetItemByID(last_added); int index = model_->ItemIndexByID(last_added); internal::ShelfButton* button = GetButtonByID(last_added); ASSERT_EQ(internal::ShelfButton::STATE_RUNNING, button->state()); @@ -1186,8 +1186,8 @@ TEST_F(ShelfViewLegacyShelfLayoutTest, test_api_->GetLastVisibleIndex() + 1); // Add 2 items to the shelf. - LauncherID item1_id = AddPlatformApp(); - LauncherID item2_id = AddPlatformAppNoWait(); + ShelfID item1_id = AddPlatformApp(); + ShelfID item2_id = AddPlatformAppNoWait(); internal::ShelfButton* item1_button = GetButtonByID(item1_id); internal::ShelfButton* item2_button = GetButtonByID(item2_id); @@ -1221,8 +1221,8 @@ TEST_F(ShelfViewTest, ShelfItemStatusPlatformApp) { test_api_->GetLastVisibleIndex() + 1); // Add platform app button. - LauncherID last_added = AddPlatformApp(); - LauncherItem item = GetItemByID(last_added); + ShelfID last_added = AddPlatformApp(); + ShelfItem item = GetItemByID(last_added); int index = model_->ItemIndexByID(last_added); internal::ShelfButton* button = GetButtonByID(last_added); ASSERT_EQ(internal::ShelfButton::STATE_RUNNING, button->state()); @@ -1252,8 +1252,8 @@ TEST_F(ShelfViewTest, ShelfTooltipTest) { test_api_->GetButtonCount()); // Prepare some items to the shelf. - LauncherID app_button_id = AddAppShortcut(); - LauncherID platform_button_id = AddPlatformApp(); + ShelfID app_button_id = AddAppShortcut(); + ShelfID platform_button_id = AddPlatformApp(); internal::ShelfButton* app_button = GetButtonByID(app_button_id); internal::ShelfButton* platform_button = GetButtonByID(platform_button_id); @@ -1301,7 +1301,7 @@ TEST_F(ShelfViewTest, RemovingItemClosesTooltip) { shelf_view_->tooltip_manager(); // Add an item to the shelf. - LauncherID app_button_id = AddAppShortcut(); + ShelfID app_button_id = AddAppShortcut(); internal::ShelfButton* app_button = GetButtonByID(app_button_id); // Spawn a tooltip on that item. @@ -1326,7 +1326,7 @@ TEST_F(ShelfViewTest, ShelfAlignmentClosesTooltip) { shelf_view_->tooltip_manager(); // Add an item to the shelf. - LauncherID app_button_id = AddAppShortcut(); + ShelfID app_button_id = AddAppShortcut(); internal::ShelfButton* app_button = GetButtonByID(app_button_id); // Spawn a tooltip on the item. @@ -1341,8 +1341,8 @@ TEST_F(ShelfViewTest, ShelfAlignmentClosesTooltip) { } TEST_F(ShelfViewTest, ShouldHideTooltipTest) { - LauncherID app_button_id = AddAppShortcut(); - LauncherID platform_button_id = AddPlatformApp(); + ShelfID app_button_id = AddAppShortcut(); + ShelfID platform_button_id = AddPlatformApp(); // The tooltip shouldn't hide if the mouse is on normal buttons. for (int i = 0; i < test_api_->GetButtonCount(); i++) { diff --git a/ash/shelf/shelf_window_watcher.cc b/ash/shelf/shelf_window_watcher.cc index a1f9ab8..59cb38b 100644 --- a/ash/shelf/shelf_window_watcher.cc +++ b/ash/shelf/shelf_window_watcher.cc @@ -24,10 +24,9 @@ namespace { -// Sets LauncherItem property by using the value of |details|. -void SetShelfItemDetailsForLauncherItem( - ash::LauncherItem* item, - const ash::ShelfItemDetails& details) { +// Sets ShelfItem property by using the value of |details|. +void SetShelfItemDetailsForShelfItem(ash::ShelfItem* item, + const ash::ShelfItemDetails& details) { item->type = details.type; if (details.image_resource_id != ash::kInvalidImageResourceID) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); @@ -35,10 +34,10 @@ void SetShelfItemDetailsForLauncherItem( } } -// Returns true if |window| has a LauncherItem added by ShelfWindowWatcher. -bool HasLauncherItemForWindow(aura::Window* window) { +// Returns true if |window| has a ShelfItem added by ShelfWindowWatcher. +bool HasShelfItemForWindow(aura::Window* window) { if (ash::GetShelfItemDetailsForWindow(window) != NULL && - ash::GetLauncherIDForWindow(window) != ash::kInvalidShelfID) + ash::GetShelfIDForWindow(window) != ash::kInvalidShelfID) return true; return false; } @@ -101,7 +100,7 @@ void ShelfWindowWatcher::RemovedWindowObserver::OnWindowParentChanged( void ShelfWindowWatcher::RemovedWindowObserver::OnWindowDestroyed( aura::Window* window) { - DCHECK(HasLauncherItemForWindow(window)); + DCHECK(HasShelfItemForWindow(window)); window_watcher_->FinishObservingRemovedWindow(window); } @@ -130,14 +129,14 @@ ShelfWindowWatcher::~ShelfWindowWatcher() { Shell::GetScreen()->RemoveObserver(this); } -void ShelfWindowWatcher::AddLauncherItem(aura::Window* window) { +void ShelfWindowWatcher::AddShelfItem(aura::Window* window) { const ShelfItemDetails* item_details = GetShelfItemDetailsForWindow(window); - LauncherItem item; - LauncherID id = model_->next_id(); + ShelfItem item; + ShelfID id = model_->next_id(); item.status = wm::IsActiveWindow(window) ? STATUS_ACTIVE: STATUS_RUNNING; - SetShelfItemDetailsForLauncherItem(&item, *item_details); - SetLauncherIDForWindow(id, window); + SetShelfItemDetailsForShelfItem(&item, *item_details); + SetShelfIDForWindow(id, window); scoped_ptr<ShelfItemDelegate> item_delegate( new ShelfWindowWatcherItemDelegate(window, model_)); // |item_delegate| is owned by |item_delegate_manager_|. @@ -145,9 +144,9 @@ void ShelfWindowWatcher::AddLauncherItem(aura::Window* window) { model_->Add(item); } -void ShelfWindowWatcher::RemoveLauncherItem(aura::Window* window) { - model_->RemoveItemAt(model_->ItemIndexByID(GetLauncherIDForWindow(window))); - SetLauncherIDForWindow(kInvalidShelfID, window); +void ShelfWindowWatcher::RemoveShelfItem(aura::Window* window) { + model_->RemoveItemAt(model_->ItemIndexByID(GetShelfIDForWindow(window))); + SetShelfIDForWindow(kInvalidShelfID, window); } void ShelfWindowWatcher::OnRootWindowAdded(aura::Window* root_window) { @@ -173,17 +172,17 @@ void ShelfWindowWatcher::OnRootWindowRemoved(aura::Window* root_window) { void ShelfWindowWatcher::UpdateShelfItemStatus(aura::Window* window, bool is_active) { - int index = GetLauncherItemIndexForWindow(window); + int index = GetShelfItemIndexForWindow(window); DCHECK_GE(index, 0); - LauncherItem item = model_->items()[index]; + ShelfItem item = model_->items()[index]; item.status = is_active ? STATUS_ACTIVE : STATUS_RUNNING; model_->Set(index, item); } -int ShelfWindowWatcher::GetLauncherItemIndexForWindow( +int ShelfWindowWatcher::GetShelfItemIndexForWindow( aura::Window* window) const { - return model_->ItemIndexByID(GetLauncherIDForWindow(window)); + return model_->ItemIndexByID(GetShelfIDForWindow(window)); } void ShelfWindowWatcher::StartObservingRemovedWindow(aura::Window* window) { @@ -192,14 +191,14 @@ void ShelfWindowWatcher::StartObservingRemovedWindow(aura::Window* window) { void ShelfWindowWatcher::FinishObservingRemovedWindow(aura::Window* window) { observed_removed_windows_.Remove(window); - RemoveLauncherItem(window); + RemoveShelfItem(window); } void ShelfWindowWatcher::OnWindowActivated(aura::Window* gained_active, aura::Window* lost_active) { - if (gained_active && HasLauncherItemForWindow(gained_active)) + if (gained_active && HasShelfItemForWindow(gained_active)) UpdateShelfItemStatus(gained_active, true); - if (lost_active && HasLauncherItemForWindow(lost_active)) + if (lost_active && HasShelfItemForWindow(lost_active)) UpdateShelfItemStatus(lost_active, false); } @@ -209,17 +208,17 @@ void ShelfWindowWatcher::OnWindowAdded(aura::Window* window) { if (observed_removed_windows_.IsObserving(window)) { // When |window| is added and it is already observed by // |dragged_window_observer_|, |window| already has its item. - DCHECK(HasLauncherItemForWindow(window)); + DCHECK(HasShelfItemForWindow(window)); observed_removed_windows_.Remove(window); return; } - // Add LauncherItem if |window| already has a ShelfItemDetails when it is - // created. Don't make a new LauncherItem for the re-parented |window| that - // already has a LauncherItem. - if (GetLauncherIDForWindow(window) == kInvalidShelfID && + // Add ShelfItem if |window| already has a ShelfItemDetails when it is + // created. Don't make a new ShelfItem for the re-parented |window| that + // already has a ShelfItem. + if (GetShelfIDForWindow(window) == kInvalidShelfID && GetShelfItemDetailsForWindow(window)) - AddLauncherItem(window); + AddShelfItem(window); } void ShelfWindowWatcher::OnWillRemoveWindow(aura::Window* window) { @@ -230,7 +229,7 @@ void ShelfWindowWatcher::OnWillRemoveWindow(aura::Window* window) { // Don't remove |window| item immediately. Instead, defer handling of removing // |window|'s item to RemovedWindowObserver because |window| could be added // again to default container. - if (HasLauncherItemForWindow(window)) + if (HasShelfItemForWindow(window)) StartObservingRemovedWindow(window); } @@ -247,26 +246,26 @@ void ShelfWindowWatcher::OnWindowPropertyChanged(aura::Window* window, return; if (GetShelfItemDetailsForWindow(window) == NULL) { - // Removes LauncherItem for |window| when it has a LauncherItem. + // Removes ShelfItem for |window| when it has a ShelfItem. if (reinterpret_cast<ShelfItemDetails*>(old) != NULL) - RemoveLauncherItem(window); + RemoveShelfItem(window); return; } - // When ShelfItemDetails is changed, update LauncherItem. - if (HasLauncherItemForWindow(window)) { - int index = GetLauncherItemIndexForWindow(window); + // When ShelfItemDetails is changed, update ShelfItem. + if (HasShelfItemForWindow(window)) { + int index = GetShelfItemIndexForWindow(window); DCHECK_GE(index, 0); - LauncherItem item = model_->items()[index]; + ShelfItem item = model_->items()[index]; const ShelfItemDetails* details = GetShelfItemDetailsForWindow(window); - SetShelfItemDetailsForLauncherItem(&item, *details); + SetShelfItemDetailsForShelfItem(&item, *details); model_->Set(index, item); return; } - // Creates a new LauncherItem for |window|. - AddLauncherItem(window); + // Creates a new ShelfItem for |window|. + AddShelfItem(window); } void ShelfWindowWatcher::OnDisplayBoundsChanged(const gfx::Display& display) { diff --git a/ash/shelf/shelf_window_watcher.h b/ash/shelf/shelf_window_watcher.h index e69138f..57b4ed2 100644 --- a/ash/shelf/shelf_window_watcher.h +++ b/ash/shelf/shelf_window_watcher.h @@ -30,7 +30,7 @@ class ShelfModel; class ShelfItemDelegateManager; namespace internal { -// ShelfWindowWatcher creates and handles a LauncherItem for windows that have +// ShelfWindowWatcher creates and handles a ShelfItem for windows that have // a ShelfItemDetails property in the default container. class ShelfWindowWatcher : public aura::client::ActivationChangeObserver, public aura::WindowObserver, @@ -75,11 +75,11 @@ class ShelfWindowWatcher : public aura::client::ActivationChangeObserver, DISALLOW_COPY_AND_ASSIGN(RemovedWindowObserver); }; - // Creates a LauncherItem for |window| that has ShelfItemDetails. - void AddLauncherItem(aura::Window* window); + // Creates a ShelfItem for |window| that has ShelfItemDetails. + void AddShelfItem(aura::Window* window); - // Removes a LauncherItem for |window|. - void RemoveLauncherItem(aura::Window* window); + // Removes a ShelfItem for |window|. + void RemoveShelfItem(aura::Window* window); // Adds observer to default container and ActivationClient of |root_window|. void OnRootWindowAdded(aura::Window* root_window); @@ -90,8 +90,8 @@ class ShelfWindowWatcher : public aura::client::ActivationChangeObserver, // Updates the status of ShelfItem for |window|. void UpdateShelfItemStatus(aura::Window* window, bool is_active); - // Returns the index of LauncherItem associated with |window|. - int GetLauncherItemIndexForWindow(aura::Window* window) const; + // Returns the index of ShelfItem associated with |window|. + int GetShelfItemIndexForWindow(aura::Window* window) const; // Used when a window is removed. During the dragging a window may be removed // and when the drag completes added back. When this happens we don't want to diff --git a/ash/shelf/shelf_window_watcher_item_delegate.cc b/ash/shelf/shelf_window_watcher_item_delegate.cc index 48d582b..fcae1af 100644 --- a/ash/shelf/shelf_window_watcher_item_delegate.cc +++ b/ash/shelf/shelf_window_watcher_item_delegate.cc @@ -51,8 +51,7 @@ base::string16 ShelfWindowWatcherItemDelegate::GetTitle() { ui::MenuModel* ShelfWindowWatcherItemDelegate::CreateContextMenu( aura::Window* root_window) { - ash::LauncherItem item = - *(model_->ItemByID(GetLauncherIDForWindow(window_))); + ash::ShelfItem item = *(model_->ItemByID(GetShelfIDForWindow(window_))); return Shell::GetInstance()->delegate()->CreateContextMenu(root_window, this, &item); diff --git a/ash/shelf/shelf_window_watcher_unittest.cc b/ash/shelf/shelf_window_watcher_unittest.cc index bc9727f..f4ba99d 100644 --- a/ash/shelf/shelf_window_watcher_unittest.cc +++ b/ash/shelf/shelf_window_watcher_unittest.cc @@ -5,7 +5,7 @@ #include "ash/shelf/shelf_window_watcher.h" #include "ash/ash_switches.h" -#include "ash/launcher/launcher_types.h" +#include "ash/shelf/shelf_item_types.h" #include "ash/shelf/shelf_model.h" #include "ash/shelf/shelf_util.h" #include "ash/shell.h" @@ -38,8 +38,8 @@ class ShelfWindowWatcherTest : public test::AshTestBase { test::AshTestBase::TearDown(); } - LauncherID CreateShelfItem(aura::Window* window) { - LauncherID id = model_->next_id(); + ShelfID CreateShelfItem(aura::Window* window) { + ShelfID id = model_->next_id(); ShelfItemDetails item_details; item_details.type = TYPE_PLATFORM_APP; SetShelfItemDetailsForWindow(window, item_details); @@ -53,28 +53,28 @@ class ShelfWindowWatcherTest : public test::AshTestBase { DISALLOW_COPY_AND_ASSIGN(ShelfWindowWatcherTest); }; -TEST_F(ShelfWindowWatcherTest, CreateAndRemoveLauncherItem) { +TEST_F(ShelfWindowWatcherTest, CreateAndRemoveShelfItem) { // ShelfModel only has an APP_LIST item. EXPECT_EQ(1, model_->item_count()); scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithId(0)); scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithId(0)); - // Create a LauncherItem for w1. - LauncherID id_w1 = CreateShelfItem(w1.get()); + // Create a ShelfItem for w1. + ShelfID id_w1 = CreateShelfItem(w1.get()); EXPECT_EQ(2, model_->item_count()); int index_w1 = model_->ItemIndexByID(id_w1); EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w1].status); - // Create a LauncherItem for w2. - LauncherID id_w2 = CreateShelfItem(w2.get()); + // Create a ShelfItem for w2. + ShelfID id_w2 = CreateShelfItem(w2.get()); EXPECT_EQ(3, model_->item_count()); int index_w2 = model_->ItemIndexByID(id_w2); EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w2].status); - // LauncherItem is removed when assoicated window is destroyed. + // ShelfItem is removed when assoicated window is destroyed. ClearShelfItemDetailsForWindow(w1.get()); EXPECT_EQ(2, model_->item_count()); ClearShelfItemDetailsForWindow(w2.get()); @@ -91,24 +91,24 @@ TEST_F(ShelfWindowWatcherTest, ActivateWindow) { scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithId(0)); scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithId(0)); - // Create a LauncherItem for w1. - LauncherID id_w1 = CreateShelfItem(w1.get()); + // Create a ShelfItem for w1. + ShelfID id_w1 = CreateShelfItem(w1.get()); EXPECT_EQ(2, model_->item_count()); int index_w1 = model_->ItemIndexByID(id_w1); EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w1].status); - // Create a LauncherItem for w2. - LauncherID id_w2 = CreateShelfItem(w2.get()); + // Create a ShelfItem for w2. + ShelfID id_w2 = CreateShelfItem(w2.get()); EXPECT_EQ(3, model_->item_count()); int index_w2 = model_->ItemIndexByID(id_w2); EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w1].status); EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w2].status); - // LauncherItem for w1 is active when w1 is activated. + // ShelfItem for w1 is active when w1 is activated. wm::ActivateWindow(w1.get()); EXPECT_EQ(STATUS_ACTIVE, model_->items()[index_w1].status); - // LauncherItem for w2 is active state when w2 is activated. + // ShelfItem for w2 is active state when w2 is activated. wm::ActivateWindow(w2.get()); EXPECT_EQ(STATUS_RUNNING, model_->items()[index_w1].status); EXPECT_EQ(STATUS_ACTIVE, model_->items()[index_w2].status); @@ -120,14 +120,14 @@ TEST_F(ShelfWindowWatcherTest, UpdateWindowProperty) { scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); - // Create a LauncherItem for |window|. - LauncherID id = CreateShelfItem(window.get()); + // Create a ShelfItem for |window|. + ShelfID id = CreateShelfItem(window.get()); EXPECT_EQ(2, model_->item_count()); int index = model_->ItemIndexByID(id); EXPECT_EQ(STATUS_RUNNING, model_->items()[index].status); - // Update LauncherItem for |window|. + // Update ShelfItem for |window|. ShelfItemDetails details; details.type = TYPE_PLATFORM_APP; @@ -146,8 +146,8 @@ TEST_F(ShelfWindowWatcherTest, MaximizeAndRestoreWindow) { scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); wm::WindowState* window_state = wm::GetWindowState(window.get()); - // Create a LauncherItem for |window|. - LauncherID id = CreateShelfItem(window.get()); + // Create a ShelfItem for |window|. + ShelfID id = CreateShelfItem(window.get()); EXPECT_EQ(2, model_->item_count()); int index = model_->ItemIndexByID(id); @@ -181,8 +181,8 @@ TEST_F(ShelfWindowWatcherTest, ReparentWindow) { scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); window->set_owned_by_parent(false); - // Create a LauncherItem for |window|. - LauncherID id = CreateShelfItem(window.get()); + // Create a ShelfItem for |window|. + ShelfID id = CreateShelfItem(window.get()); EXPECT_EQ(2, model_->item_count()); int index = model_->ItemIndexByID(id); @@ -217,8 +217,8 @@ TEST_F(ShelfWindowWatcherTest, DragWindow) { scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); - // Create a LauncherItem for |window|. - LauncherID id = CreateShelfItem(window.get()); + // Create a ShelfItem for |window|. + ShelfID id = CreateShelfItem(window.get()); EXPECT_EQ(2, model_->item_count()); int index = model_->ItemIndexByID(id); @@ -248,8 +248,8 @@ TEST_F(ShelfWindowWatcherTest, ReparentWindowDuringTheDragging) { scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); window->set_owned_by_parent(false); - // Create a LauncherItem for |window|. - LauncherID id = CreateShelfItem(window.get()); + // Create a ShelfItem for |window|. + ShelfID id = CreateShelfItem(window.get()); EXPECT_EQ(2, model_->item_count()); int index = model_->ItemIndexByID(id); EXPECT_EQ(STATUS_RUNNING, model_->items()[index].status); |