Commit 5b121135 authored by msw's avatar msw Committed by Commit bot

mash: Remove shelf util functions; use WmWindow properties.

Move aura window properties to WmWindowAura.
(towards supporting [Shelf]WindowWatcher in mash)

Cleanup ShelfItem and ShelfItemDetails structs.
Remove unused ash support for UserManagerView

BUG=634150
TEST=Automated tests; no shelf functionality changes.
R=sky@chromium.org

Review-Url: https://codereview.chromium.org/2332393003
Cr-Commit-Position: refs/heads/master@{#418723}
parent 0a7922ab
...@@ -686,8 +686,6 @@ component("ash") { ...@@ -686,8 +686,6 @@ component("ash") {
"shelf/dimmer_view.h", "shelf/dimmer_view.h",
"shelf/shelf_bezel_event_handler.cc", "shelf/shelf_bezel_event_handler.cc",
"shelf/shelf_bezel_event_handler.h", "shelf/shelf_bezel_event_handler.h",
"shelf/shelf_util.cc",
"shelf/shelf_util.h",
"shelf/shelf_window_targeter.cc", "shelf/shelf_window_targeter.cc",
"shelf/shelf_window_targeter.h", "shelf/shelf_window_targeter.h",
"shell.cc", "shell.cc",
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "ash/aura/wm_root_window_controller_aura.h" #include "ash/aura/wm_root_window_controller_aura.h"
#include "ash/aura/wm_shell_aura.h" #include "ash/aura/wm_shell_aura.h"
#include "ash/common/ash_constants.h" #include "ash/common/ash_constants.h"
#include "ash/common/shelf/shelf_item_types.h"
#include "ash/common/shell_window_ids.h" #include "ash/common/shell_window_ids.h"
#include "ash/common/wm/window_state.h" #include "ash/common/wm/window_state.h"
#include "ash/common/wm_layout_manager.h" #include "ash/common/wm_layout_manager.h"
...@@ -15,7 +16,6 @@ ...@@ -15,7 +16,6 @@
#include "ash/common/wm_window_observer.h" #include "ash/common/wm_window_observer.h"
#include "ash/common/wm_window_property.h" #include "ash/common/wm_window_property.h"
#include "ash/screen_util.h" #include "ash/screen_util.h"
#include "ash/shelf/shelf_util.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wm/resize_handle_window_targeter.h" #include "ash/wm/resize_handle_window_targeter.h"
#include "ash/wm/resize_shadow_controller.h" #include "ash/wm/resize_shadow_controller.h"
...@@ -44,11 +44,17 @@ ...@@ -44,11 +44,17 @@
#include "ui/wm/core/visibility_controller.h" #include "ui/wm/core/visibility_controller.h"
#include "ui/wm/core/window_util.h" #include "ui/wm/core/window_util.h"
DECLARE_WINDOW_PROPERTY_TYPE(ash::ShelfItemDetails*);
DECLARE_WINDOW_PROPERTY_TYPE(ash::WmWindowAura*); DECLARE_WINDOW_PROPERTY_TYPE(ash::WmWindowAura*);
namespace ash { namespace ash {
DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::WmWindowAura, kWmWindowKey, nullptr); DEFINE_WINDOW_PROPERTY_KEY(ShelfID, kShelfIDKey, kInvalidShelfID);
DEFINE_OWNED_WINDOW_PROPERTY_KEY(ShelfItemDetails,
kShelfItemDetailsKey,
nullptr);
DEFINE_OWNED_WINDOW_PROPERTY_KEY(WmWindowAura, kWmWindowKey, nullptr);
static_assert(aura::Window::kInitialId == kShellWindowId_Invalid, static_assert(aura::Window::kInitialId == kShellWindowId_Invalid,
"ids must match"); "ids must match");
...@@ -310,7 +316,7 @@ int WmWindowAura::GetIntProperty(WmWindowProperty key) { ...@@ -310,7 +316,7 @@ int WmWindowAura::GetIntProperty(WmWindowProperty key) {
return window_->GetProperty(aura::client::kModalKey); return window_->GetProperty(aura::client::kModalKey);
if (key == WmWindowProperty::SHELF_ID) if (key == WmWindowProperty::SHELF_ID)
return GetShelfIDForWindow(window_); return window_->GetProperty(kShelfIDKey);
if (key == WmWindowProperty::TOP_VIEW_INSET) if (key == WmWindowProperty::TOP_VIEW_INSET)
return window_->GetProperty(aura::client::kTopViewInset); return window_->GetProperty(aura::client::kTopViewInset);
...@@ -321,7 +327,7 @@ int WmWindowAura::GetIntProperty(WmWindowProperty key) { ...@@ -321,7 +327,7 @@ int WmWindowAura::GetIntProperty(WmWindowProperty key) {
void WmWindowAura::SetIntProperty(WmWindowProperty key, int value) { void WmWindowAura::SetIntProperty(WmWindowProperty key, int value) {
if (key == WmWindowProperty::SHELF_ID) { if (key == WmWindowProperty::SHELF_ID) {
SetShelfIDForWindow(value, window_); window_->SetProperty(kShelfIDKey, value);
return; return;
} }
if (key == WmWindowProperty::TOP_VIEW_INSET) { if (key == WmWindowProperty::TOP_VIEW_INSET) {
...@@ -807,7 +813,7 @@ void WmWindowAura::OnWindowPropertyChanged(aura::Window* window, ...@@ -807,7 +813,7 @@ void WmWindowAura::OnWindowPropertyChanged(aura::Window* window,
wm_property = WmWindowProperty::EXCLUDE_FROM_MRU; wm_property = WmWindowProperty::EXCLUDE_FROM_MRU;
} else if (key == aura::client::kModalKey) { } else if (key == aura::client::kModalKey) {
wm_property = WmWindowProperty::MODAL_TYPE; wm_property = WmWindowProperty::MODAL_TYPE;
} else if (key == kShelfID) { } else if (key == kShelfIDKey) {
wm_property = WmWindowProperty::SHELF_ID; wm_property = WmWindowProperty::SHELF_ID;
} else if (key == kShelfItemDetailsKey) { } else if (key == kShelfItemDetailsKey) {
wm_property = WmWindowProperty::SHELF_ITEM_DETAILS; wm_property = WmWindowProperty::SHELF_ITEM_DETAILS;
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
namespace ash { namespace ash {
const int kInvalidImageResourceID = -1;
const int kTimeToSwitchBackgroundMs = 1000; const int kTimeToSwitchBackgroundMs = 1000;
const int kWorkspaceAreaVisibleInset = 2; const int kWorkspaceAreaVisibleInset = 2;
const int kWorkspaceAreaAutoHideInset = 5; const int kWorkspaceAreaAutoHideInset = 5;
......
...@@ -29,7 +29,7 @@ enum ShelfConstant { ...@@ -29,7 +29,7 @@ enum ShelfConstant {
}; };
// Invalid image resource id used for ShelfItemDetails. // Invalid image resource id used for ShelfItemDetails.
extern const int kInvalidImageResourceID; const int kInvalidImageResourceID = -1;
// We reserve a small area on the edge of the workspace area to ensure that // We reserve a small area on the edge of the workspace area to ensure that
// the resize handle at the edge of the window can be hit. // the resize handle at the edge of the window can be hit.
......
...@@ -4,18 +4,12 @@ ...@@ -4,18 +4,12 @@
#include "ash/common/shelf/shelf_item_types.h" #include "ash/common/shelf/shelf_item_types.h"
#include "ash/common/shelf/shelf_constants.h"
namespace ash { namespace ash {
ShelfItem::ShelfItem() ShelfItem::ShelfItem() {}
: type(TYPE_UNDEFINED), id(kInvalidShelfID), status(STATUS_CLOSED) {}
ShelfItem::~ShelfItem() {} ShelfItem::~ShelfItem() {}
ShelfItemDetails::ShelfItemDetails() ShelfItemDetails::ShelfItemDetails() {}
: type(TYPE_UNDEFINED), image_resource_id(kInvalidImageResourceID) {}
ShelfItemDetails::~ShelfItemDetails() {} ShelfItemDetails::~ShelfItemDetails() {}
} // namespace ash } // namespace ash
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <vector> #include <vector>
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/common/shelf/shelf_constants.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
...@@ -61,31 +62,30 @@ struct ASH_EXPORT ShelfItem { ...@@ -61,31 +62,30 @@ struct ASH_EXPORT ShelfItem {
ShelfItem(); ShelfItem();
~ShelfItem(); ~ShelfItem();
ShelfItemType type; ShelfItemType type = TYPE_UNDEFINED;
// Image to display in the shelf. // Image to display in the shelf.
gfx::ImageSkia image; gfx::ImageSkia image;
// Assigned by the model when the item is added. // Assigned by the model when the item is added.
ShelfID id; ShelfID id = kInvalidShelfID;
// Running status. // Running status.
ShelfItemStatus status; ShelfItemStatus status = STATUS_CLOSED;
}; };
typedef std::vector<ShelfItem> ShelfItems; typedef std::vector<ShelfItem> ShelfItems;
// ShelfItemDetails may be set on Window (by way of // Windows with ShelfItemDetails appear in the shelf.
// SetShelfItemDetailsForWindow) to make the window appear in the shelf. See // See ShelfWindowWatcher for details.
// ShelfWindowWatcher for details.
struct ASH_EXPORT ShelfItemDetails { struct ASH_EXPORT ShelfItemDetails {
ShelfItemDetails(); ShelfItemDetails();
~ShelfItemDetails(); ~ShelfItemDetails();
ShelfItemType type; ShelfItemType type = TYPE_UNDEFINED;
// Resource id of the image to display on the shelf. // Resource id of the image to display on the shelf.
int image_resource_id; int image_resource_id = kInvalidImageResourceID;
// Title of the item. // Title of the item.
base::string16 title; base::string16 title;
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "ash/common/login_status.h" #include "ash/common/login_status.h"
#include "ash/common/shelf/shelf_model.h" #include "ash/common/shelf/shelf_model.h"
#include "ash/common/wm_shell.h" #include "ash/common/wm_shell.h"
#include "ash/shelf/shelf_util.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ash/test/test_shelf_delegate.h" #include "ash/test/test_shelf_delegate.h"
#include "ash/test/test_system_tray_delegate.h" #include "ash/test/test_system_tray_delegate.h"
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/shelf/shelf_util.h"
#include "ash/common/shelf/shelf_constants.h"
#include "ui/aura/window_property.h"
DECLARE_WINDOW_PROPERTY_TYPE(ash::ShelfItemDetails*);
namespace ash {
DEFINE_WINDOW_PROPERTY_KEY(ShelfID, kShelfID, kInvalidShelfID);
// ShelfItemDetails for kShelfItemDetaildKey is owned by the window
// and will be freed automatically.
DEFINE_OWNED_WINDOW_PROPERTY_KEY(ShelfItemDetails, kShelfItemDetailsKey, NULL);
void SetShelfIDForWindow(ShelfID id, aura::Window* window) {
if (!window)
return;
window->SetProperty(kShelfID, id);
}
ShelfID GetShelfIDForWindow(const aura::Window* window) {
DCHECK(window);
return window->GetProperty(kShelfID);
}
void SetShelfItemDetailsForWindow(aura::Window* window,
const ShelfItemDetails& details) {
// |item_details| is owned by |window|.
ShelfItemDetails* item_details = new ShelfItemDetails(details);
window->SetProperty(kShelfItemDetailsKey, item_details);
}
void SetShelfItemDetailsForDialogWindow(aura::Window* window,
int image_resource_id,
const base::string16& title) {
// |item_details| is owned by |window|.
ShelfItemDetails* item_details = new ShelfItemDetails;
item_details->type = TYPE_DIALOG;
item_details->image_resource_id = image_resource_id;
item_details->title = title;
window->SetProperty(kShelfItemDetailsKey, item_details);
}
void ClearShelfItemDetailsForWindow(aura::Window* window) {
window->ClearProperty(kShelfItemDetailsKey);
}
const ShelfItemDetails* GetShelfItemDetailsForWindow(aura::Window* window) {
return window->GetProperty(kShelfItemDetailsKey);
}
} // namespace ash
// 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_UTIL_H_
#define ASH_SHELF_SHELF_UTIL_H_
#include "ash/ash_export.h"
#include "ash/common/shelf/shelf_item_types.h"
#include "ash/common/shelf/shelf_types.h"
#include "base/strings/string16.h"
#include "ui/aura/window.h"
namespace aura {
class Window;
}
namespace ash {
// A property key to store the id of the ShelfItem associated with the window.
extern const aura::WindowProperty<ShelfID>* const kShelfID;
// A property key to store the resource id and title of the item shown on the
// shelf for this window.
extern const aura::WindowProperty<ShelfItemDetails*>* const
kShelfItemDetailsKey;
// Associates ShelfItem of |id| with specified |window|.
ASH_EXPORT void SetShelfIDForWindow(ShelfID id, aura::Window* 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 |ShelfID| of the
// currently active tab.
ASH_EXPORT ShelfID GetShelfIDForWindow(const aura::Window* window);
// Creates a new ShelfItemDetails instance from |details| and sets it for
// |window|.
ASH_EXPORT void SetShelfItemDetailsForWindow(aura::Window* window,
const ShelfItemDetails& details);
// Creates a new ShelfItemDetails instance with type DIALOG, image id
// |image_resource_id|, and title |title|, and sets it for |window|.
ASH_EXPORT void SetShelfItemDetailsForDialogWindow(aura::Window* window,
int image_resource_id,
const base::string16& title);
// Clears ShelfItemDetails for |window|.
// If |window| has a ShelfItem by SetShelfItemDetailsForWindow(), it will
// be removed.
ASH_EXPORT void ClearShelfItemDetailsForWindow(aura::Window* window);
// Returns ShelfItemDetails for |window| or NULL if it doesn't have.
// Returned ShelfItemDetails object is owned by the |window|.
ASH_EXPORT const ShelfItemDetails* GetShelfItemDetailsForWindow(
aura::Window* window);
} // namespace ash
#endif // ASH_SHELF_SHELF_UTIL_H_
...@@ -6,12 +6,13 @@ ...@@ -6,12 +6,13 @@
#include <utility> #include <utility>
#include "ash/aura/wm_window_aura.h"
#include "ash/common/shelf/shelf_model.h" #include "ash/common/shelf/shelf_model.h"
#include "ash/common/shelf/shelf_widget.h" #include "ash/common/shelf/shelf_widget.h"
#include "ash/common/shell_window_ids.h" #include "ash/common/shell_window_ids.h"
#include "ash/common/wm_shell.h" #include "ash/common/wm_shell.h"
#include "ash/common/wm_window_property.h"
#include "ash/display/window_tree_host_manager.h" #include "ash/display/window_tree_host_manager.h"
#include "ash/shelf/shelf_util.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/shell/window_watcher_shelf_item_delegate.h" #include "ash/shell/window_watcher_shelf_item_delegate.h"
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
...@@ -115,7 +116,7 @@ void WindowWatcher::OnWindowAdded(aura::Window* new_window) { ...@@ -115,7 +116,7 @@ void WindowWatcher::OnWindowAdded(aura::Window* new_window) {
std::unique_ptr<ShelfItemDelegate> delegate( std::unique_ptr<ShelfItemDelegate> delegate(
new WindowWatcherShelfItemDelegate(id, this)); new WindowWatcherShelfItemDelegate(id, this));
model->SetShelfItemDelegate(id, std::move(delegate)); model->SetShelfItemDelegate(id, std::move(delegate));
SetShelfIDForWindow(id, new_window); WmWindowAura::Get(new_window)->SetIntProperty(WmWindowProperty::SHELF_ID, id);
} }
void WindowWatcher::OnWillRemoveWindow(aura::Window* window) { void WindowWatcher::OnWillRemoveWindow(aura::Window* window) {
......
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
#include <utility> #include <utility>
#include "ash/aura/wm_window_aura.h"
#include "ash/common/shelf/shelf_model.h" #include "ash/common/shelf/shelf_model.h"
#include "ash/shelf/shelf_util.h" #include "ash/common/wm_window_property.h"
#include "ash/test/test_shelf_item_delegate.h" #include "ash/test/test_shelf_item_delegate.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -34,7 +35,9 @@ void TestShelfDelegate::AddShelfItem(aura::Window* window) { ...@@ -34,7 +35,9 @@ void TestShelfDelegate::AddShelfItem(aura::Window* window) {
void TestShelfDelegate::AddShelfItem(aura::Window* window, void TestShelfDelegate::AddShelfItem(aura::Window* window,
const std::string& app_id) { const std::string& app_id) {
AddShelfItem(window, STATUS_CLOSED); AddShelfItem(window, STATUS_CLOSED);
AddShelfIDToAppIDMapping(GetShelfIDForWindow(window), app_id); WmWindow* wm_window = WmWindowAura::Get(window);
ShelfID shelf_id = wm_window->GetIntProperty(WmWindowProperty::SHELF_ID);
AddShelfIDToAppIDMapping(shelf_id, app_id);
} }
void TestShelfDelegate::AddShelfItem(aura::Window* window, void TestShelfDelegate::AddShelfItem(aura::Window* window,
...@@ -52,11 +55,12 @@ void TestShelfDelegate::AddShelfItem(aura::Window* window, ...@@ -52,11 +55,12 @@ void TestShelfDelegate::AddShelfItem(aura::Window* window,
std::unique_ptr<ShelfItemDelegate> delegate( std::unique_ptr<ShelfItemDelegate> delegate(
new TestShelfItemDelegate(window)); new TestShelfItemDelegate(window));
model_->SetShelfItemDelegate(id, std::move(delegate)); model_->SetShelfItemDelegate(id, std::move(delegate));
SetShelfIDForWindow(id, window); WmWindowAura::Get(window)->SetIntProperty(WmWindowProperty::SHELF_ID, id);
} }
void TestShelfDelegate::RemoveShelfItemForWindow(aura::Window* window) { void TestShelfDelegate::RemoveShelfItemForWindow(aura::Window* window) {
ShelfID shelf_id = GetShelfIDForWindow(window); WmWindow* wm_window = WmWindowAura::Get(window);
ShelfID shelf_id = wm_window->GetIntProperty(WmWindowProperty::SHELF_ID);
if (shelf_id == 0) if (shelf_id == 0)
return; return;
int index = model_->ItemIndexByID(shelf_id); int index = model_->ItemIndexByID(shelf_id);
......
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
#include "ash/common/wm/window_state.h" #include "ash/common/wm/window_state.h"
#include "ash/common/wm_root_window_controller.h" #include "ash/common/wm_root_window_controller.h"
#include "ash/common/wm_shell.h" #include "ash/common/wm_shell.h"
#include "ash/common/wm_window_property.h"
#include "ash/display/display_manager.h" #include "ash/display/display_manager.h"
#include "ash/screen_util.h" #include "ash/screen_util.h"
#include "ash/shelf/shelf_util.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ash/test/display_manager_test_api.h" #include "ash/test/display_manager_test_api.h"
...@@ -228,7 +228,7 @@ class PanelLayoutManagerTest : public test::AshTestBase { ...@@ -228,7 +228,7 @@ class PanelLayoutManagerTest : public test::AshTestBase {
test_api.SetAnimationDuration(1); test_api.SetAnimationDuration(1);
test_api.RunMessageLoopUntilAnimationsDone(); test_api.RunMessageLoopUntilAnimationsDone();
int index = WmShell::Get()->shelf_model()->ItemIndexByID( int index = WmShell::Get()->shelf_model()->ItemIndexByID(
GetShelfIDForWindow(window)); WmWindowAura::Get(window)->GetIntProperty(WmWindowProperty::SHELF_ID));
gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen(); gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen();
ui::test::EventGenerator& event_generator = GetEventGenerator(); ui::test::EventGenerator& event_generator = GetEventGenerator();
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
#include "ash/common/wm/window_state.h" #include "ash/common/wm/window_state.h"
#include "ash/common/wm/wm_event.h" #include "ash/common/wm/wm_event.h"
#include "ash/common/wm_shell.h" #include "ash/common/wm_shell.h"
#include "ash/common/wm_window_property.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/shelf/shelf_util.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ash/test/cursor_manager_test_api.h" #include "ash/test/cursor_manager_test_api.h"
...@@ -134,7 +134,8 @@ class PanelWindowResizerTest : public test::AshTestBase { ...@@ -134,7 +134,8 @@ class PanelWindowResizerTest : public test::AshTestBase {
for (std::vector<aura::Window *>::const_iterator for (std::vector<aura::Window *>::const_iterator
iter = window_order.begin(); iter = window_order.begin();
iter != window_order.end(); ++iter, ++panel_index) { iter != window_order.end(); ++iter, ++panel_index) {
ShelfID id = GetShelfIDForWindow(*iter); ShelfID id =
WmWindowAura::Get(*iter)->GetIntProperty(WmWindowProperty::SHELF_ID);
EXPECT_EQ(id, model_->items()[panel_index].id); EXPECT_EQ(id, model_->items()[panel_index].id);
} }
} }
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "ash/common/shelf/shelf_delegate.h" #include "ash/common/shelf/shelf_delegate.h"
#include "ash/common/wm_shell.h" #include "ash/common/wm_shell.h"
#include "ash/shelf/shelf_util.h"
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/run_loop.h" #include "base/run_loop.h"
......
...@@ -5,14 +5,15 @@ ...@@ -5,14 +5,15 @@
#include <string> #include <string>
#include "ash/aura/wm_window_aura.h"
#include "ash/common/shelf/shelf_delegate.h" #include "ash/common/shelf/shelf_delegate.h"
#include "ash/common/wm/maximize_mode/maximize_mode_controller.h" #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
#include "ash/common/wm/window_state.h" #include "ash/common/wm/window_state.h"
#include "ash/common/wm_lookup.h" #include "ash/common/wm_lookup.h"
#include "ash/common/wm_shell.h" #include "ash/common/wm_shell.h"
#include "ash/common/wm_window_property.h"
#include "ash/display/display_manager.h" #include "ash/display/display_manager.h"
#include "ash/display/screen_orientation_controller_chromeos.h" #include "ash/display/screen_orientation_controller_chromeos.h"
#include "ash/shelf/shelf_util.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wm/window_state_aura.h" #include "ash/wm/window_state_aura.h"
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
...@@ -373,7 +374,8 @@ void ArcAppWindowLauncherController::AttachControllerToWindowIfNeeded( ...@@ -373,7 +374,8 @@ void ArcAppWindowLauncherController::AttachControllerToWindowIfNeeded(
app_window->set_widget(views::Widget::GetWidgetForNativeWindow(window)); app_window->set_widget(views::Widget::GetWidgetForNativeWindow(window));
RegisterApp(app_window.get()); RegisterApp(app_window.get());
DCHECK(app_window->controller()); DCHECK(app_window->controller());
ash::SetShelfIDForWindow(app_window->shelf_id(), window); ash::WmWindowAura::Get(window)->SetIntProperty(
ash::WmWindowProperty::SHELF_ID, app_window->shelf_id());
chrome::MultiUserWindowManager::GetInstance()->SetWindowOwner( chrome::MultiUserWindowManager::GetInstance()->SetWindowOwner(
window, window,
user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId()); user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId());
......
...@@ -6,11 +6,12 @@ ...@@ -6,11 +6,12 @@
#include <vector> #include <vector>
#include "ash/aura/wm_window_aura.h"
#include "ash/common/shelf/shelf_delegate.h" #include "ash/common/shelf/shelf_delegate.h"
#include "ash/common/shelf/shelf_model.h" #include "ash/common/shelf/shelf_model.h"
#include "ash/common/wm_shell.h" #include "ash/common/wm_shell.h"
#include "ash/common/wm_window_property.h"
#include "ash/resources/grit/ash_resources.h" #include "ash/resources/grit/ash_resources.h"
#include "ash/shelf/shelf_util.h"
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h"
...@@ -117,15 +118,16 @@ void BrowserShortcutLauncherItemController::UpdateBrowserItemState() { ...@@ -117,15 +118,16 @@ void BrowserShortcutLauncherItemController::UpdateBrowserItemState() {
void BrowserShortcutLauncherItemController::SetShelfIDForBrowserWindowContents( void BrowserShortcutLauncherItemController::SetShelfIDForBrowserWindowContents(
Browser* browser, Browser* browser,
content::WebContents* web_contents) { content::WebContents* web_contents) {
// We need to call SetShelfIDForWindow for V1 applications since they are // We need to set the window ShelfID for V1 applications since they are
// content which might change and as such change the application type. // content which might change and as such change the application type.
if (!browser || !IsBrowserFromActiveUser(browser) || if (!browser || !IsBrowserFromActiveUser(browser) ||
IsSettingsBrowser(browser)) IsSettingsBrowser(browser))
return; return;
ash::SetShelfIDForWindow( ash::WmWindowAura::Get(browser->window()->GetNativeWindow())
launcher_controller()->GetShelfIDForWebContents(web_contents), ->SetIntProperty(
browser->window()->GetNativeWindow()); ash::WmWindowProperty::SHELF_ID,
launcher_controller()->GetShelfIDForWebContents(web_contents));
} }
bool BrowserShortcutLauncherItemController::IsOpen() const { bool BrowserShortcutLauncherItemController::IsOpen() const {
......
...@@ -4,8 +4,10 @@ ...@@ -4,8 +4,10 @@
#include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h"
#include "ash/aura/wm_window_aura.h"
#include "ash/common/shelf/shelf_item_types.h"
#include "ash/common/wm_window_property.h"
#include "ash/resources/grit/ash_resources.h" #include "ash/resources/grit/ash_resources.h"
#include "ash/shelf/shelf_util.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -90,10 +92,12 @@ class BrowserStatusMonitor::SettingsWindowObserver ...@@ -90,10 +92,12 @@ class BrowserStatusMonitor::SettingsWindowObserver
// SettingsWindowManagerObserver // SettingsWindowManagerObserver
void OnNewSettingsWindow(Browser* settings_browser) override { void OnNewSettingsWindow(Browser* settings_browser) override {
ash::SetShelfItemDetailsForDialogWindow( ash::ShelfItemDetails item_details;
settings_browser->window()->GetNativeWindow(), item_details.type = ash::TYPE_DIALOG;
IDR_ASH_SHELF_ICON_SETTINGS, item_details.image_resource_id = IDR_ASH_SHELF_ICON_SETTINGS;
l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); item_details.title = l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE);
aura::Window* aura_window = settings_browser->window()->GetNativeWindow();
ash::WmWindowAura::Get(aura_window)->SetShelfItemDetails(item_details);
} }
private: private:
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "ash/common/shelf/wm_shelf.h" #include "ash/common/shelf/wm_shelf.h"
#include "ash/common/wm/window_state.h" #include "ash/common/wm/window_state.h"
#include "ash/common/wm_shell.h" #include "ash/common/wm_shell.h"
#include "ash/shelf/shelf_util.h" #include "ash/common/wm_window_property.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/test/shelf_view_test_api.h" #include "ash/test/shelf_view_test_api.h"
#include "ash/wm/window_state_aura.h" #include "ash/wm/window_state_aura.h"
...@@ -2125,34 +2125,36 @@ IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, ...@@ -2125,34 +2125,36 @@ IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser,
EXPECT_FALSE(window_state->IsMinimized()); EXPECT_FALSE(window_state->IsMinimized());
} }
// Check that GetShelfIDForWindow() returns |ShelfID| of the active tab. // Check that the window's ShelfID property matches that of the active tab.
IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MatchingShelfIDandActiveTab) { IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MatchingShelfIDandActiveTab) {
EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
EXPECT_EQ(1, browser()->tab_strip_model()->count()); EXPECT_EQ(1, browser()->tab_strip_model()->count());
EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
EXPECT_EQ(2, model_->item_count()); EXPECT_EQ(2, model_->item_count());
aura::Window* window = browser()->window()->GetNativeWindow(); ash::WmWindow* window =
ash::WmWindowAura::Get(browser()->window()->GetNativeWindow());
int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT);
ash::ShelfID browser_id = model_->items()[browser_index].id; ash::ShelfID browser_id = model_->items()[browser_index].id;
EXPECT_EQ(browser_id, ash::GetShelfIDForWindow(window)); ash::ShelfID id = window->GetIntProperty(ash::WmWindowProperty::SHELF_ID);
EXPECT_EQ(browser_id, id);
ash::ShelfID app_id = CreateShortcut("app1"); ash::ShelfID app_id = CreateShortcut("app1");
EXPECT_EQ(3, model_->item_count()); EXPECT_EQ(3, model_->item_count());
// Creates a new tab for "app1" and checks that GetShelfIDForWindow() // Create and activate a new tab for "app1" and expect an application ShelfID.
// returns |ShelfID| of "app1".
WmShelf::ActivateShelfItem(model_->ItemIndexByID(app_id)); WmShelf::ActivateShelfItem(model_->ItemIndexByID(app_id));
EXPECT_EQ(2, browser()->tab_strip_model()->count()); EXPECT_EQ(2, browser()->tab_strip_model()->count());
EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
EXPECT_EQ(app_id, ash::GetShelfIDForWindow(window)); id = window->GetIntProperty(ash::WmWindowProperty::SHELF_ID);
EXPECT_EQ(app_id, id);
// Makes tab at index 0(NTP) as an active tab and checks that // Activate the tab at index 0 (NTP) and expect a browser ShelfID.
// GetShelfIDForWindow() returns |ShelfID| of browser shortcut.
browser()->tab_strip_model()->ActivateTabAt(0, false); browser()->tab_strip_model()->ActivateTabAt(0, false);
EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
EXPECT_EQ(browser_id, ash::GetShelfIDForWindow(window)); id = window->GetIntProperty(ash::WmWindowProperty::SHELF_ID);
EXPECT_EQ(browser_id, id);
} }
IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, OverflowBubble) { IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, OverflowBubble) {
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
#include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_controller.h"
#include "ash/aura/wm_window_aura.h"
#include "ash/common/shelf/shelf_delegate.h" #include "ash/common/shelf/shelf_delegate.h"
#include "ash/common/wm_shell.h" #include "ash/common/wm_shell.h"
#include "ash/shelf/shelf_util.h" #include "ash/common/wm_window_property.h"
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
...@@ -17,6 +18,7 @@ ...@@ -17,6 +18,7 @@
#include "extensions/browser/app_window/app_window.h" #include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/app_window/native_app_window.h" #include "extensions/browser/app_window/native_app_window.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_event_dispatcher.h"
using extensions::AppWindow; using extensions::AppWindow;
...@@ -180,7 +182,8 @@ void ExtensionAppWindowLauncherController::RegisterApp(AppWindow* app_window) { ...@@ -180,7 +182,8 @@ void ExtensionAppWindowLauncherController::RegisterApp(AppWindow* app_window) {
app_controller_map_[app_shelf_id] = controller; app_controller_map_[app_shelf_id] = controller;
} }
owner()->SetItemStatus(shelf_id, status); owner()->SetItemStatus(shelf_id, status);
ash::SetShelfIDForWindow(shelf_id, window); ash::WmWindowAura::Get(window)->SetIntProperty(
ash::WmWindowProperty::SHELF_ID, shelf_id);
} }
void ExtensionAppWindowLauncherController::UnregisterApp(aura::Window* window) { void ExtensionAppWindowLauncherController::UnregisterApp(aura::Window* window) {
......
...@@ -9,14 +9,12 @@ ...@@ -9,14 +9,12 @@
#include <map> #include <map>
#include <string> #include <string>
#include "ash/shelf/shelf_util.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h"
#include "extensions/browser/app_window/app_window_registry.h" #include "extensions/browser/app_window/app_window_registry.h"
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
namespace aura { namespace aura {
class Window; class Window;
} }
......
...@@ -4,8 +4,10 @@ ...@@ -4,8 +4,10 @@
#include "chrome/browser/ui/ash/launcher/multi_profile_browser_status_monitor.h" #include "chrome/browser/ui/ash/launcher/multi_profile_browser_status_monitor.h"
#include "ash/aura/wm_window_aura.h"
#include "ash/common/shelf/shelf_item_types.h"
#include "ash/common/wm_window_property.h"
#include "ash/resources/grit/ash_resources.h" #include "ash/resources/grit/ash_resources.h"
#include "ash/shelf/shelf_util.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
...@@ -86,13 +88,15 @@ void MultiProfileBrowserStatusMonitor::ActiveUserChanged( ...@@ -86,13 +88,15 @@ void MultiProfileBrowserStatusMonitor::ActiveUserChanged(
browser)) { browser)) {
continue; continue;
} }
aura::Window* aura_window = browser->window()->GetNativeWindow();
if (multi_user_util::IsProfileFromActiveUser(browser->profile())) { if (multi_user_util::IsProfileFromActiveUser(browser->profile())) {
ash::SetShelfItemDetailsForDialogWindow( ash::ShelfItemDetails item_details;
browser->window()->GetNativeWindow(), item_details.type = ash::TYPE_DIALOG;
IDR_ASH_SHELF_ICON_SETTINGS, item_details.image_resource_id = IDR_ASH_SHELF_ICON_SETTINGS;
l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); item_details.title = l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE);
ash::WmWindowAura::Get(aura_window)->SetShelfItemDetails(item_details);
} else { } else {
ash::ClearShelfItemDetailsForWindow(browser->window()->GetNativeWindow()); ash::WmWindowAura::Get(aura_window)->ClearShelfItemDetails();
} }
} }
......
...@@ -45,12 +45,6 @@ ...@@ -45,12 +45,6 @@
#include "ui/views/win/hwnd_util.h" #include "ui/views/win/hwnd_util.h"
#endif #endif
#if defined(USE_ASH)
#include "ash/resources/grit/ash_resources.h" // nogncheck
#include "ash/shelf/shelf_util.h" // nogncheck
#include "ash/wm/window_util.h" // nogncheck
#endif
namespace { namespace {
// An open User Manager window. There can only be one open at a time. This // An open User Manager window. There can only be one open at a time. This
...@@ -242,10 +236,8 @@ UserManagerView::UserManagerView() ...@@ -242,10 +236,8 @@ UserManagerView::UserManagerView()
: web_view_(nullptr), : web_view_(nullptr),
delegate_(nullptr), delegate_(nullptr),
user_manager_started_showing_(base::Time()) { user_manager_started_showing_(base::Time()) {
#if !defined(USE_ASH)
keep_alive_.reset(new ScopedKeepAlive(KeepAliveOrigin::USER_MANAGER_VIEW, keep_alive_.reset(new ScopedKeepAlive(KeepAliveOrigin::USER_MANAGER_VIEW,
KeepAliveRestartOption::DISABLED)); KeepAliveRestartOption::DISABLED));
#endif // !defined(USE_ASH)
} }
UserManagerView::~UserManagerView() { UserManagerView::~UserManagerView() {
...@@ -353,12 +345,6 @@ void UserManagerView::Init(Profile* system_profile, const GURL& url) { ...@@ -353,12 +345,6 @@ void UserManagerView::Init(Profile* system_profile, const GURL& url) {
views::HWNDForWidget(GetWidget())); views::HWNDForWidget(GetWidget()));
#endif #endif
#if defined(USE_ASH)
gfx::NativeWindow native_window = GetWidget()->GetNativeWindow();
ash::SetShelfItemDetailsForDialogWindow(
native_window, IDR_ASH_SHELF_LIST_BROWSER, native_window->title());
#endif
web_view_->LoadInitialURL(url); web_view_->LoadInitialURL(url);
content::RenderWidgetHostView* rwhv = content::RenderWidgetHostView* rwhv =
web_view_->GetWebContents()->GetRenderWidgetHostView(); web_view_->GetWebContents()->GetRenderWidgetHostView();
......
...@@ -34,9 +34,12 @@ ...@@ -34,9 +34,12 @@
#include "ui/views/window/dialog_client_view.h" #include "ui/views/window/dialog_client_view.h"
#if defined(USE_ASH) #if defined(USE_ASH)
#include "ash/resources/grit/ash_resources.h" // nogncheck #include "ash/common/shelf/shelf_item_types.h" // nogncheck
#include "ash/shelf/shelf_util.h" // nogncheck #include "ash/common/wm_lookup.h" // nogncheck
#include "ash/wm/window_util.h" // nogncheck #include "ash/common/wm_window.h" // nogncheck
#include "ash/common/wm_window_property.h" // nogncheck
#include "ash/resources/grit/ash_resources.h" // nogncheck
#include "ash/wm/window_util.h" // nogncheck
#endif // defined(USE_ASH) #endif // defined(USE_ASH)
#if defined(OS_WIN) #if defined(OS_WIN)
...@@ -100,10 +103,13 @@ task_manager::TaskManagerTableModel* TaskManagerView::Show(Browser* browser) { ...@@ -100,10 +103,13 @@ task_manager::TaskManagerTableModel* TaskManagerView::Show(Browser* browser) {
focus_manager->SetFocusedView(g_task_manager_view->tab_table_); focus_manager->SetFocusedView(g_task_manager_view->tab_table_);
#if defined(USE_ASH) #if defined(USE_ASH)
gfx::NativeWindow native_window = ash::WmWindow* wm_window = ash::WmLookup::Get()->GetWindowForWidget(
g_task_manager_view->GetWidget()->GetNativeWindow(); g_task_manager_view->GetWidget());
ash::SetShelfItemDetailsForDialogWindow( ash::ShelfItemDetails item_details;
native_window, IDR_ASH_SHELF_ICON_TASK_MANAGER, native_window->title()); item_details.type = ash::TYPE_DIALOG;
item_details.image_resource_id = IDR_ASH_SHELF_ICON_TASK_MANAGER;
item_details.title = wm_window->GetTitle();
wm_window->SetShelfItemDetails(item_details);
#endif #endif
return g_task_manager_view->table_model_.get(); return g_task_manager_view->table_model_.get();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment