ash: Rename LauncherModelObserver to ShelfModelObserver.
- move launcher_model_observer.h from launcher/ to shelf/ - rename to shelf_model_observer.h BUG=248353 TEST=None, no functional changes R=harrym@chromium.org,jamescook@chromium.org Review URL: https://codereview.chromium.org/68243002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234686 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
ash
ash.gyp
launcher
launcher_item_delegate_manager.cclauncher_item_delegate_manager.hlauncher_model.cclauncher_model.hlauncher_model_observer.hlauncher_model_unittest.cc
shelf
chrome/browser/ui/ash/launcher
@@ -166,7 +166,6 @@
|
|||||||
'launcher/launcher_item_delegate.h',
|
'launcher/launcher_item_delegate.h',
|
||||||
'launcher/launcher_model.cc',
|
'launcher/launcher_model.cc',
|
||||||
'launcher/launcher_model.h',
|
'launcher/launcher_model.h',
|
||||||
'launcher/launcher_model_observer.h',
|
|
||||||
'launcher/launcher_types.cc',
|
'launcher/launcher_types.cc',
|
||||||
'launcher/launcher_types.h',
|
'launcher/launcher_types.h',
|
||||||
'magnifier/magnification_controller.cc',
|
'magnifier/magnification_controller.cc',
|
||||||
@@ -215,6 +214,7 @@
|
|||||||
'shelf/shelf_layout_manager.cc',
|
'shelf/shelf_layout_manager.cc',
|
||||||
'shelf/shelf_layout_manager.h',
|
'shelf/shelf_layout_manager.h',
|
||||||
'shelf/shelf_layout_manager_observer.h',
|
'shelf/shelf_layout_manager_observer.h',
|
||||||
|
'shelf/shelf_model_observer.h',
|
||||||
'shelf/shelf_model_util.cc',
|
'shelf/shelf_model_util.cc',
|
||||||
'shelf/shelf_model_util.h',
|
'shelf/shelf_model_util.h',
|
||||||
'shelf/shelf_navigator.cc',
|
'shelf/shelf_navigator.cc',
|
||||||
|
@@ -44,24 +44,23 @@ LauncherItemDelegate* LauncherItemDelegateManager::GetLauncherItemDelegate(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherItemDelegateManager::LauncherItemAdded(int index) {
|
void LauncherItemDelegateManager::ShelfItemAdded(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherItemDelegateManager::LauncherItemRemoved(int index,
|
void LauncherItemDelegateManager::ShelfItemRemoved(int index, LauncherID id) {
|
||||||
ash::LauncherID id) {
|
|
||||||
RemoveLauncherItemDelegate(id);
|
RemoveLauncherItemDelegate(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherItemDelegateManager::LauncherItemMoved(int start_index,
|
void LauncherItemDelegateManager::ShelfItemMoved(int start_index,
|
||||||
int target_index) {
|
int target_index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherItemDelegateManager::LauncherItemChanged(
|
void LauncherItemDelegateManager::ShelfItemChanged(
|
||||||
int index,
|
int index,
|
||||||
const LauncherItem& old_item) {
|
const LauncherItem& old_item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherItemDelegateManager::LauncherStatusChanged() {
|
void LauncherItemDelegateManager::ShelfStatusChanged() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherItemDelegateManager::RemoveLauncherItemDelegate(
|
void LauncherItemDelegateManager::RemoveLauncherItemDelegate(
|
||||||
|
@@ -8,8 +8,8 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "ash/ash_export.h"
|
#include "ash/ash_export.h"
|
||||||
#include "ash/launcher/launcher_model_observer.h"
|
|
||||||
#include "ash/launcher/launcher_types.h"
|
#include "ash/launcher/launcher_types.h"
|
||||||
|
#include "ash/shelf/shelf_model_observer.h"
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
|
|
||||||
@@ -26,8 +26,7 @@ class LauncherItemDelegateManagerTestAPI;
|
|||||||
// rather it is expected that someone else invokes SetLauncherItemDelegate
|
// rather it is expected that someone else invokes SetLauncherItemDelegate
|
||||||
// appropriately. On the other hand, LauncherItemDelegateManager destroys
|
// appropriately. On the other hand, LauncherItemDelegateManager destroys
|
||||||
// LauncherItemDelegates when the corresponding item from the model is removed.
|
// LauncherItemDelegates when the corresponding item from the model is removed.
|
||||||
class ASH_EXPORT LauncherItemDelegateManager
|
class ASH_EXPORT LauncherItemDelegateManager : public ShelfModelObserver {
|
||||||
: public ash::LauncherModelObserver {
|
|
||||||
public:
|
public:
|
||||||
explicit LauncherItemDelegateManager(ash::LauncherModel* model);
|
explicit LauncherItemDelegateManager(ash::LauncherModel* model);
|
||||||
virtual ~LauncherItemDelegateManager();
|
virtual ~LauncherItemDelegateManager();
|
||||||
@@ -40,14 +39,13 @@ class ASH_EXPORT LauncherItemDelegateManager
|
|||||||
// Returns LauncherItemDelegate for |item_type|. Always returns non-NULL.
|
// Returns LauncherItemDelegate for |item_type|. Always returns non-NULL.
|
||||||
LauncherItemDelegate* GetLauncherItemDelegate(ash::LauncherID id);
|
LauncherItemDelegate* GetLauncherItemDelegate(ash::LauncherID id);
|
||||||
|
|
||||||
// ash::LauncherModelObserver overrides:
|
// ShelfModelObserver overrides:
|
||||||
virtual void LauncherItemAdded(int model_index) OVERRIDE;
|
virtual void ShelfItemAdded(int model_index) OVERRIDE;
|
||||||
virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE;
|
virtual void ShelfItemRemoved(int index, ash::LauncherID id) OVERRIDE;
|
||||||
virtual void LauncherItemMoved(int start_index, int targetindex) OVERRIDE;
|
virtual void ShelfItemMoved(int start_index, int targetindex) OVERRIDE;
|
||||||
virtual void LauncherItemChanged(
|
virtual void ShelfItemChanged(int index,
|
||||||
int index,
|
const LauncherItem& old_item) OVERRIDE;
|
||||||
const ash::LauncherItem& old_item) OVERRIDE;
|
virtual void ShelfStatusChanged() OVERRIDE;
|
||||||
virtual void LauncherStatusChanged() OVERRIDE;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class ash::test::LauncherItemDelegateManagerTestAPI;
|
friend class ash::test::LauncherItemDelegateManagerTestAPI;
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "ash/ash_switches.h"
|
#include "ash/ash_switches.h"
|
||||||
#include "ash/launcher/launcher_model_observer.h"
|
#include "ash/shelf/shelf_model_observer.h"
|
||||||
|
|
||||||
namespace ash {
|
namespace ash {
|
||||||
|
|
||||||
@@ -74,8 +74,7 @@ int LauncherModel::AddAt(int index, const LauncherItem& item) {
|
|||||||
index = ValidateInsertionIndex(item.type, index);
|
index = ValidateInsertionIndex(item.type, index);
|
||||||
items_.insert(items_.begin() + index, item);
|
items_.insert(items_.begin() + index, item);
|
||||||
items_[index].id = next_id_++;
|
items_[index].id = next_id_++;
|
||||||
FOR_EACH_OBSERVER(LauncherModelObserver, observers_,
|
FOR_EACH_OBSERVER(ShelfModelObserver, observers_, ShelfItemAdded(index));
|
||||||
LauncherItemAdded(index));
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,8 +85,8 @@ void LauncherModel::RemoveItemAt(int index) {
|
|||||||
items_[index].type != TYPE_BROWSER_SHORTCUT);
|
items_[index].type != TYPE_BROWSER_SHORTCUT);
|
||||||
LauncherID id = items_[index].id;
|
LauncherID id = items_[index].id;
|
||||||
items_.erase(items_.begin() + index);
|
items_.erase(items_.begin() + index);
|
||||||
FOR_EACH_OBSERVER(LauncherModelObserver, observers_,
|
FOR_EACH_OBSERVER(ShelfModelObserver, observers_,
|
||||||
LauncherItemRemoved(index, id));
|
ShelfItemRemoved(index, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherModel::Move(int index, int target_index) {
|
void LauncherModel::Move(int index, int target_index) {
|
||||||
@@ -97,8 +96,8 @@ void LauncherModel::Move(int index, int target_index) {
|
|||||||
LauncherItem item(items_[index]);
|
LauncherItem item(items_[index]);
|
||||||
items_.erase(items_.begin() + index);
|
items_.erase(items_.begin() + index);
|
||||||
items_.insert(items_.begin() + target_index, item);
|
items_.insert(items_.begin() + target_index, item);
|
||||||
FOR_EACH_OBSERVER(LauncherModelObserver, observers_,
|
FOR_EACH_OBSERVER(ShelfModelObserver, observers_,
|
||||||
LauncherItemMoved(index, target_index));
|
ShelfItemMoved(index, target_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherModel::Set(int index, const LauncherItem& item) {
|
void LauncherModel::Set(int index, const LauncherItem& item) {
|
||||||
@@ -109,8 +108,8 @@ void LauncherModel::Set(int index, const LauncherItem& item) {
|
|||||||
LauncherItem old_item(items_[index]);
|
LauncherItem old_item(items_[index]);
|
||||||
items_[index] = item;
|
items_[index] = item;
|
||||||
items_[index].id = old_item.id;
|
items_[index].id = old_item.id;
|
||||||
FOR_EACH_OBSERVER(LauncherModelObserver, observers_,
|
FOR_EACH_OBSERVER(ShelfModelObserver, observers_,
|
||||||
LauncherItemChanged(index, old_item));
|
ShelfItemChanged(index, old_item));
|
||||||
|
|
||||||
// If the type changes confirm that the item is still in the right order.
|
// If the type changes confirm that the item is still in the right order.
|
||||||
if (new_index != index) {
|
if (new_index != index) {
|
||||||
@@ -153,15 +152,14 @@ void LauncherModel::SetStatus(Status status) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
status_ = status;
|
status_ = status;
|
||||||
FOR_EACH_OBSERVER(LauncherModelObserver, observers_,
|
FOR_EACH_OBSERVER(ShelfModelObserver, observers_, ShelfStatusChanged());
|
||||||
LauncherStatusChanged());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherModel::AddObserver(LauncherModelObserver* observer) {
|
void LauncherModel::AddObserver(ShelfModelObserver* observer) {
|
||||||
observers_.AddObserver(observer);
|
observers_.AddObserver(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherModel::RemoveObserver(LauncherModelObserver* observer) {
|
void LauncherModel::RemoveObserver(ShelfModelObserver* observer) {
|
||||||
observers_.RemoveObserver(observer);
|
observers_.RemoveObserver(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace ash {
|
namespace ash {
|
||||||
|
|
||||||
class LauncherModelObserver;
|
class ShelfModelObserver;
|
||||||
|
|
||||||
// Model used by ShelfView.
|
// Model used by ShelfView.
|
||||||
class ASH_EXPORT LauncherModel {
|
class ASH_EXPORT LauncherModel {
|
||||||
@@ -67,8 +67,8 @@ class ASH_EXPORT LauncherModel {
|
|||||||
void SetStatus(Status status);
|
void SetStatus(Status status);
|
||||||
Status status() const { return status_; }
|
Status status() const { return status_; }
|
||||||
|
|
||||||
void AddObserver(LauncherModelObserver* observer);
|
void AddObserver(ShelfModelObserver* observer);
|
||||||
void RemoveObserver(LauncherModelObserver* observer);
|
void RemoveObserver(ShelfModelObserver* observer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Makes sure |index| is in line with the type-based order of items. If that
|
// Makes sure |index| is in line with the type-based order of items. If that
|
||||||
@@ -81,7 +81,7 @@ class ASH_EXPORT LauncherModel {
|
|||||||
|
|
||||||
LauncherItems items_;
|
LauncherItems items_;
|
||||||
Status status_;
|
Status status_;
|
||||||
ObserverList<LauncherModelObserver> observers_;
|
ObserverList<ShelfModelObserver> observers_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(LauncherModel);
|
DISALLOW_COPY_AND_ASSIGN(LauncherModel);
|
||||||
};
|
};
|
||||||
|
@@ -1,41 +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.
|
|
||||||
|
|
||||||
#ifndef ASH_LAUNCHER_LAUNCHER_MODEL_OBSERVER_H_
|
|
||||||
#define ASH_LAUNCHER_LAUNCHER_MODEL_OBSERVER_H_
|
|
||||||
|
|
||||||
#include "ash/ash_export.h"
|
|
||||||
#include "ash/launcher/launcher_types.h"
|
|
||||||
|
|
||||||
namespace ash {
|
|
||||||
|
|
||||||
struct LauncherItem;
|
|
||||||
|
|
||||||
class ASH_EXPORT LauncherModelObserver {
|
|
||||||
public:
|
|
||||||
// Invoked after an item has been added to the model.
|
|
||||||
virtual void LauncherItemAdded(int index) = 0;
|
|
||||||
|
|
||||||
// Invoked after an item has been removed. |index| is the index the item was
|
|
||||||
// at.
|
|
||||||
virtual void LauncherItemRemoved(int index, LauncherID id) = 0;
|
|
||||||
|
|
||||||
// Invoked after an item has been moved. See LauncherModel::Move() for details
|
|
||||||
// of the arguments.
|
|
||||||
virtual void LauncherItemMoved(int start_index, int target_index) = 0;
|
|
||||||
|
|
||||||
// Invoked when the state of an item changes. |old_item| is the item
|
|
||||||
// before the change.
|
|
||||||
virtual void LauncherItemChanged(int index, const LauncherItem& old_item) = 0;
|
|
||||||
|
|
||||||
// Invoked when launcher status is changed.
|
|
||||||
virtual void LauncherStatusChanged() = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual ~LauncherModelObserver() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ash
|
|
||||||
|
|
||||||
#endif // ASH_LAUNCHER_LAUNCHER_MODEL_OBSERVER_H_
|
|
@@ -8,7 +8,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "ash/ash_switches.h"
|
#include "ash/ash_switches.h"
|
||||||
#include "ash/launcher/launcher_model_observer.h"
|
#include "ash/shelf/shelf_model_observer.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
@@ -17,10 +17,10 @@ namespace ash {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// LauncherModelObserver implementation that tracks what message are invoked.
|
// ShelfModelObserver implementation that tracks what message are invoked.
|
||||||
class TestLauncherModelObserver : public LauncherModelObserver {
|
class TestShelfModelObserver : public ShelfModelObserver {
|
||||||
public:
|
public:
|
||||||
TestLauncherModelObserver()
|
TestShelfModelObserver()
|
||||||
: added_count_(0),
|
: added_count_(0),
|
||||||
removed_count_(0),
|
removed_count_(0),
|
||||||
changed_count_(0),
|
changed_count_(0),
|
||||||
@@ -39,21 +39,21 @@ class TestLauncherModelObserver : public LauncherModelObserver {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// LauncherModelObserver overrides:
|
// ShelfModelObserver overrides:
|
||||||
virtual void LauncherItemAdded(int index) OVERRIDE {
|
virtual void ShelfItemAdded(int index) OVERRIDE {
|
||||||
added_count_++;
|
added_count_++;
|
||||||
}
|
}
|
||||||
virtual void LauncherItemRemoved(int index, LauncherID id) OVERRIDE {
|
virtual void ShelfItemRemoved(int index, LauncherID id) OVERRIDE {
|
||||||
removed_count_++;
|
removed_count_++;
|
||||||
}
|
}
|
||||||
virtual void LauncherItemChanged(int index,
|
virtual void ShelfItemChanged(int index,
|
||||||
const LauncherItem& old_item) OVERRIDE {
|
const LauncherItem& old_item) OVERRIDE {
|
||||||
changed_count_++;
|
changed_count_++;
|
||||||
}
|
}
|
||||||
virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE {
|
virtual void ShelfItemMoved(int start_index, int target_index) OVERRIDE {
|
||||||
moved_count_++;
|
moved_count_++;
|
||||||
}
|
}
|
||||||
virtual void LauncherStatusChanged() OVERRIDE {
|
virtual void ShelfStatusChanged() OVERRIDE {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -70,7 +70,7 @@ class TestLauncherModelObserver : public LauncherModelObserver {
|
|||||||
int changed_count_;
|
int changed_count_;
|
||||||
int moved_count_;
|
int moved_count_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(TestLauncherModelObserver);
|
DISALLOW_COPY_AND_ASSIGN(TestShelfModelObserver);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@@ -82,7 +82,7 @@ class LauncherModelTest : public testing::Test {
|
|||||||
|
|
||||||
virtual void SetUp() {
|
virtual void SetUp() {
|
||||||
model_.reset(new LauncherModel);
|
model_.reset(new LauncherModel);
|
||||||
observer_.reset(new TestLauncherModelObserver);
|
observer_.reset(new TestShelfModelObserver);
|
||||||
EXPECT_EQ(0, model_->item_count());
|
EXPECT_EQ(0, model_->item_count());
|
||||||
|
|
||||||
LauncherItem item;
|
LauncherItem item;
|
||||||
@@ -99,7 +99,7 @@ class LauncherModelTest : public testing::Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
scoped_ptr<LauncherModel> model_;
|
scoped_ptr<LauncherModel> model_;
|
||||||
scoped_ptr<TestLauncherModelObserver> observer_;
|
scoped_ptr<TestShelfModelObserver> observer_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(LauncherModelTest);
|
DISALLOW_COPY_AND_ASSIGN(LauncherModelTest);
|
||||||
|
41
ash/shelf/shelf_model_observer.h
Normal file
41
ash/shelf/shelf_model_observer.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// 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 ASH_SHELF_SHELF_MODEL_OBSERVER_H_
|
||||||
|
#define ASH_SHELF_SHELF_MODEL_OBSERVER_H_
|
||||||
|
|
||||||
|
#include "ash/ash_export.h"
|
||||||
|
#include "ash/launcher/launcher_types.h"
|
||||||
|
|
||||||
|
namespace ash {
|
||||||
|
|
||||||
|
struct LauncherItem;
|
||||||
|
|
||||||
|
class ASH_EXPORT ShelfModelObserver {
|
||||||
|
public:
|
||||||
|
// Invoked after an item has been added to the model.
|
||||||
|
virtual void ShelfItemAdded(int index) = 0;
|
||||||
|
|
||||||
|
// Invoked after an item has been removed. |index| is the index the item was
|
||||||
|
// at.
|
||||||
|
virtual void ShelfItemRemoved(int index, LauncherID id) = 0;
|
||||||
|
|
||||||
|
// Invoked after an item has been moved. See LauncherModel::Move() for details
|
||||||
|
// of the arguments.
|
||||||
|
virtual void ShelfItemMoved(int start_index, int target_index) = 0;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
// Invoked when shelf status is changed.
|
||||||
|
virtual void ShelfStatusChanged() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~ShelfModelObserver() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ash
|
||||||
|
|
||||||
|
#endif // ASH_SHELF_SHELF_MODEL_OBSERVER_H_
|
@@ -429,7 +429,7 @@ void ShelfView::Init() {
|
|||||||
view_model_->Add(child, static_cast<int>(i - items.begin()));
|
view_model_->Add(child, static_cast<int>(i - items.begin()));
|
||||||
AddChildView(child);
|
AddChildView(child);
|
||||||
}
|
}
|
||||||
LauncherStatusChanged();
|
ShelfStatusChanged();
|
||||||
overflow_button_ = new OverflowButton(this);
|
overflow_button_ = new OverflowButton(this);
|
||||||
overflow_button_->set_context_menu_controller(this);
|
overflow_button_->set_context_menu_controller(this);
|
||||||
ConfigureChildView(overflow_button_);
|
ConfigureChildView(overflow_button_);
|
||||||
@@ -1416,7 +1416,7 @@ void ShelfView::OnGestureEvent(ui::GestureEvent* event) {
|
|||||||
event->StopPropagation();
|
event->StopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShelfView::LauncherItemAdded(int model_index) {
|
void ShelfView::ShelfItemAdded(int model_index) {
|
||||||
{
|
{
|
||||||
base::AutoReset<bool> cancelling_drag(
|
base::AutoReset<bool> cancelling_drag(
|
||||||
&cancelling_drag_model_changed_, true);
|
&cancelling_drag_model_changed_, true);
|
||||||
@@ -1452,7 +1452,7 @@ void ShelfView::LauncherItemAdded(int model_index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShelfView::LauncherItemRemoved(int model_index, LauncherID id) {
|
void ShelfView::ShelfItemRemoved(int model_index, LauncherID id) {
|
||||||
if (id == context_menu_id_)
|
if (id == context_menu_id_)
|
||||||
launcher_menu_runner_.reset();
|
launcher_menu_runner_.reset();
|
||||||
{
|
{
|
||||||
@@ -1492,8 +1492,8 @@ void ShelfView::LauncherItemRemoved(int model_index, LauncherID id) {
|
|||||||
tooltip_->Close();
|
tooltip_->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShelfView::LauncherItemChanged(int model_index,
|
void ShelfView::ShelfItemChanged(int model_index,
|
||||||
const ash::LauncherItem& old_item) {
|
const LauncherItem& old_item) {
|
||||||
const LauncherItem& item(model_->items()[model_index]);
|
const LauncherItem& item(model_->items()[model_index]);
|
||||||
if (old_item.type != item.type) {
|
if (old_item.type != item.type) {
|
||||||
// Type changed, swap the views.
|
// Type changed, swap the views.
|
||||||
@@ -1537,7 +1537,7 @@ void ShelfView::LauncherItemChanged(int model_index,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShelfView::LauncherItemMoved(int start_index, int target_index) {
|
void ShelfView::ShelfItemMoved(int start_index, int target_index) {
|
||||||
view_model_->Move(start_index, target_index);
|
view_model_->Move(start_index, target_index);
|
||||||
// When cancelling a drag due to a launcher item being added, the currently
|
// When cancelling a drag due to a launcher item being added, the currently
|
||||||
// dragged item is moved back to its initial position. AnimateToIdealBounds
|
// dragged item is moved back to its initial position. AnimateToIdealBounds
|
||||||
@@ -1547,7 +1547,7 @@ void ShelfView::LauncherItemMoved(int start_index, int target_index) {
|
|||||||
AnimateToIdealBounds();
|
AnimateToIdealBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShelfView::LauncherStatusChanged() {
|
void ShelfView::ShelfStatusChanged() {
|
||||||
if (ash::switches::UseAlternateShelfLayout())
|
if (ash::switches::UseAlternateShelfLayout())
|
||||||
return;
|
return;
|
||||||
AppListButton* app_list_button =
|
AppListButton* app_list_button =
|
||||||
|
@@ -8,8 +8,8 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "ash/launcher/launcher_model_observer.h"
|
|
||||||
#include "ash/shelf/shelf_button_host.h"
|
#include "ash/shelf/shelf_button_host.h"
|
||||||
|
#include "ash/shelf/shelf_model_observer.h"
|
||||||
#include "ash/wm/gestures/shelf_gesture_handler.h"
|
#include "ash/wm/gestures/shelf_gesture_handler.h"
|
||||||
#include "base/observer_list.h"
|
#include "base/observer_list.h"
|
||||||
#include "ui/app_list/views/app_list_drag_and_drop_host.h"
|
#include "ui/app_list/views/app_list_drag_and_drop_host.h"
|
||||||
@@ -48,7 +48,7 @@ class ShelfLayoutManager;
|
|||||||
class ShelfTooltipManager;
|
class ShelfTooltipManager;
|
||||||
|
|
||||||
class ASH_EXPORT ShelfView : public views::View,
|
class ASH_EXPORT ShelfView : public views::View,
|
||||||
public LauncherModelObserver,
|
public ShelfModelObserver,
|
||||||
public views::ButtonListener,
|
public views::ButtonListener,
|
||||||
public ShelfButtonHost,
|
public ShelfButtonHost,
|
||||||
public views::ContextMenuController,
|
public views::ContextMenuController,
|
||||||
@@ -247,13 +247,13 @@ class ASH_EXPORT ShelfView : public views::View,
|
|||||||
// Overridden from ui::EventHandler:
|
// Overridden from ui::EventHandler:
|
||||||
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
|
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
|
||||||
|
|
||||||
// Overridden from LauncherModelObserver:
|
// Overridden from ShelfModelObserver:
|
||||||
virtual void LauncherItemAdded(int model_index) OVERRIDE;
|
virtual void ShelfItemAdded(int model_index) OVERRIDE;
|
||||||
virtual void LauncherItemRemoved(int model_index, LauncherID id) OVERRIDE;
|
virtual void ShelfItemRemoved(int model_index, LauncherID id) OVERRIDE;
|
||||||
virtual void LauncherItemChanged(int model_index,
|
virtual void ShelfItemChanged(int model_index,
|
||||||
const ash::LauncherItem& old_item) OVERRIDE;
|
const LauncherItem& old_item) OVERRIDE;
|
||||||
virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE;
|
virtual void ShelfItemMoved(int start_index, int target_index) OVERRIDE;
|
||||||
virtual void LauncherStatusChanged() OVERRIDE;
|
virtual void ShelfStatusChanged() OVERRIDE;
|
||||||
|
|
||||||
// Overridden from ShelfButtonHost:
|
// Overridden from ShelfButtonHost:
|
||||||
virtual void PointerPressedOnButton(views::View* view,
|
virtual void PointerPressedOnButton(views::View* view,
|
||||||
|
@@ -1113,7 +1113,7 @@ void ChromeLauncherController::OnLauncherDestroyed(ash::Launcher* launcher) {
|
|||||||
// Launcher is already in its destructor.
|
// Launcher is already in its destructor.
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeLauncherController::LauncherItemAdded(int index) {
|
void ChromeLauncherController::ShelfItemAdded(int index) {
|
||||||
// The app list launcher can get added to the shelf after we applied the
|
// The app list launcher can get added to the shelf after we applied the
|
||||||
// preferences. In that case the item might be at the wrong spot. As such we
|
// preferences. In that case the item might be at the wrong spot. As such we
|
||||||
// call the function again.
|
// call the function again.
|
||||||
@@ -1122,12 +1122,11 @@ void ChromeLauncherController::LauncherItemAdded(int index) {
|
|||||||
UpdateAppLaunchersFromPref();
|
UpdateAppLaunchersFromPref();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeLauncherController::LauncherItemRemoved(int index,
|
void ChromeLauncherController::ShelfItemRemoved(int index, ash::LauncherID id) {
|
||||||
ash::LauncherID id) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeLauncherController::LauncherItemMoved(int start_index,
|
void ChromeLauncherController::ShelfItemMoved(int start_index,
|
||||||
int target_index) {
|
int target_index) {
|
||||||
const ash::LauncherItem& item = model_->items()[target_index];
|
const ash::LauncherItem& item = model_->items()[target_index];
|
||||||
// We remember the moved item position if it is either pinnable or
|
// We remember the moved item position if it is either pinnable or
|
||||||
// it is the app list with the alternate shelf layout.
|
// it is the app list with the alternate shelf layout.
|
||||||
@@ -1137,12 +1136,12 @@ void ChromeLauncherController::LauncherItemMoved(int start_index,
|
|||||||
PersistPinnedState();
|
PersistPinnedState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeLauncherController::LauncherItemChanged(
|
void ChromeLauncherController::ShelfItemChanged(
|
||||||
int index,
|
int index,
|
||||||
const ash::LauncherItem& old_item) {
|
const ash::LauncherItem& old_item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeLauncherController::LauncherStatusChanged() {
|
void ChromeLauncherController::ShelfStatusChanged() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeLauncherController::ActiveUserChanged(
|
void ChromeLauncherController::ActiveUserChanged(
|
||||||
|
@@ -14,9 +14,9 @@
|
|||||||
#include "ash/display/display_controller.h"
|
#include "ash/display/display_controller.h"
|
||||||
#include "ash/launcher/launcher_delegate.h"
|
#include "ash/launcher/launcher_delegate.h"
|
||||||
#include "ash/launcher/launcher_item_delegate.h"
|
#include "ash/launcher/launcher_item_delegate.h"
|
||||||
#include "ash/launcher/launcher_model_observer.h"
|
|
||||||
#include "ash/launcher/launcher_types.h"
|
#include "ash/launcher/launcher_types.h"
|
||||||
#include "ash/shelf/shelf_layout_manager_observer.h"
|
#include "ash/shelf/shelf_layout_manager_observer.h"
|
||||||
|
#include "ash/shelf/shelf_model_observer.h"
|
||||||
#include "ash/shelf/shelf_types.h"
|
#include "ash/shelf/shelf_types.h"
|
||||||
#include "ash/shell_observer.h"
|
#include "ash/shell_observer.h"
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
@@ -87,7 +87,7 @@ class ChromeLauncherControllerUserSwitchObserver {
|
|||||||
// ShellWindowLauncherController.
|
// ShellWindowLauncherController.
|
||||||
// * Shortcuts have no LauncherItemController.
|
// * Shortcuts have no LauncherItemController.
|
||||||
class ChromeLauncherController : public ash::LauncherDelegate,
|
class ChromeLauncherController : public ash::LauncherDelegate,
|
||||||
public ash::LauncherModelObserver,
|
public ash::ShelfModelObserver,
|
||||||
public ash::ShellObserver,
|
public ash::ShellObserver,
|
||||||
public ash::DisplayController::Observer,
|
public ash::DisplayController::Observer,
|
||||||
public content::NotificationObserver,
|
public content::NotificationObserver,
|
||||||
@@ -294,13 +294,13 @@ class ChromeLauncherController : public ash::LauncherDelegate,
|
|||||||
virtual bool CanPin() const OVERRIDE;
|
virtual bool CanPin() const OVERRIDE;
|
||||||
virtual void UnpinAppWithID(const std::string& app_id) OVERRIDE;
|
virtual void UnpinAppWithID(const std::string& app_id) OVERRIDE;
|
||||||
|
|
||||||
// ash::LauncherModelObserver overrides:
|
// ash::ShelfModelObserver overrides:
|
||||||
virtual void LauncherItemAdded(int index) OVERRIDE;
|
virtual void ShelfItemAdded(int index) OVERRIDE;
|
||||||
virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE;
|
virtual void ShelfItemRemoved(int index, ash::LauncherID id) OVERRIDE;
|
||||||
virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE;
|
virtual void ShelfItemMoved(int start_index, int target_index) OVERRIDE;
|
||||||
virtual void LauncherItemChanged(int index,
|
virtual void ShelfItemChanged(int index,
|
||||||
const ash::LauncherItem& old_item) OVERRIDE;
|
const ash::LauncherItem& old_item) OVERRIDE;
|
||||||
virtual void LauncherStatusChanged() OVERRIDE;
|
virtual void ShelfStatusChanged() OVERRIDE;
|
||||||
|
|
||||||
// content::NotificationObserver overrides:
|
// content::NotificationObserver overrides:
|
||||||
virtual void Observe(int type,
|
virtual void Observe(int type,
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
#include "ash/ash_switches.h"
|
#include "ash/ash_switches.h"
|
||||||
#include "ash/launcher/launcher_item_delegate_manager.h"
|
#include "ash/launcher/launcher_item_delegate_manager.h"
|
||||||
#include "ash/launcher/launcher_model.h"
|
#include "ash/launcher/launcher_model.h"
|
||||||
#include "ash/launcher/launcher_model_observer.h"
|
#include "ash/shelf/shelf_model_observer.h"
|
||||||
#include "ash/shell.h"
|
#include "ash/shell.h"
|
||||||
#include "ash/test/launcher_item_delegate_manager_test_api.h"
|
#include "ash/test/launcher_item_delegate_manager_test_api.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
@@ -86,40 +86,40 @@ const char kCrxAppPrefix[] = "_crx_";
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// LauncherModelObserver implementation that tracks what messages are invoked.
|
// ShelfModelObserver implementation that tracks what messages are invoked.
|
||||||
class TestLauncherModelObserver : public ash::LauncherModelObserver {
|
class TestShelfModelObserver : public ash::ShelfModelObserver {
|
||||||
public:
|
public:
|
||||||
TestLauncherModelObserver()
|
TestShelfModelObserver()
|
||||||
: added_(0),
|
: added_(0),
|
||||||
removed_(0),
|
removed_(0),
|
||||||
changed_(0) {
|
changed_(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~TestLauncherModelObserver() {
|
virtual ~TestShelfModelObserver() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// LauncherModelObserver
|
// Overridden from ash::ShelfModelObserver:
|
||||||
virtual void LauncherItemAdded(int index) OVERRIDE {
|
virtual void ShelfItemAdded(int index) OVERRIDE {
|
||||||
++added_;
|
++added_;
|
||||||
last_index_ = index;
|
last_index_ = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE {
|
virtual void ShelfItemRemoved(int index, ash::LauncherID id) OVERRIDE {
|
||||||
++removed_;
|
++removed_;
|
||||||
last_index_ = index;
|
last_index_ = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void LauncherItemChanged(int index,
|
virtual void ShelfItemChanged(int index,
|
||||||
const ash::LauncherItem& old_item) OVERRIDE {
|
const ash::LauncherItem& old_item) OVERRIDE {
|
||||||
++changed_;
|
++changed_;
|
||||||
last_index_ = index;
|
last_index_ = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE {
|
virtual void ShelfItemMoved(int start_index, int target_index) OVERRIDE {
|
||||||
last_index_ = target_index;
|
last_index_ = target_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void LauncherStatusChanged() OVERRIDE {
|
virtual void ShelfStatusChanged() OVERRIDE {
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_counts() {
|
void clear_counts() {
|
||||||
@@ -140,7 +140,7 @@ class TestLauncherModelObserver : public ash::LauncherModelObserver {
|
|||||||
int changed_;
|
int changed_;
|
||||||
int last_index_;
|
int last_index_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(TestLauncherModelObserver);
|
DISALLOW_COPY_AND_ASSIGN(TestShelfModelObserver);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Test implementation of AppIconLoader.
|
// Test implementation of AppIconLoader.
|
||||||
@@ -273,7 +273,7 @@ class ChromeLauncherControllerTest : public BrowserWithTestWindowTest {
|
|||||||
BrowserWithTestWindowTest::SetUp();
|
BrowserWithTestWindowTest::SetUp();
|
||||||
|
|
||||||
model_.reset(new ash::LauncherModel);
|
model_.reset(new ash::LauncherModel);
|
||||||
model_observer_.reset(new TestLauncherModelObserver);
|
model_observer_.reset(new TestShelfModelObserver);
|
||||||
model_->AddObserver(model_observer_.get());
|
model_->AddObserver(model_observer_.get());
|
||||||
|
|
||||||
if (ash::Shell::HasInstance()) {
|
if (ash::Shell::HasInstance()) {
|
||||||
@@ -591,7 +591,7 @@ class ChromeLauncherControllerTest : public BrowserWithTestWindowTest {
|
|||||||
scoped_refptr<Extension> extension7_;
|
scoped_refptr<Extension> extension7_;
|
||||||
scoped_refptr<Extension> extension8_;
|
scoped_refptr<Extension> extension8_;
|
||||||
scoped_ptr<ChromeLauncherController> launcher_controller_;
|
scoped_ptr<ChromeLauncherController> launcher_controller_;
|
||||||
scoped_ptr<TestLauncherModelObserver> model_observer_;
|
scoped_ptr<TestShelfModelObserver> model_observer_;
|
||||||
scoped_ptr<ash::LauncherModel> model_;
|
scoped_ptr<ash::LauncherModel> model_;
|
||||||
|
|
||||||
// |item_delegate_manager_| owns |test_controller_|.
|
// |item_delegate_manager_| owns |test_controller_|.
|
||||||
|
Reference in New Issue
Block a user