Use appropriate EXPECT_EQ argument order for BookmarkModelTest assertions
[chromium-blink-merge.git] / ash / shelf / shelf_util.cc
blobf5e26584c0df0c2aa5cb5ca83d4a38370c00038c
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/shelf/shelf_util.h"
7 #include "ash/shelf/shelf_constants.h"
8 #include "ui/aura/window_property.h"
10 DECLARE_WINDOW_PROPERTY_TYPE(ash::ShelfID);
11 DECLARE_WINDOW_PROPERTY_TYPE(ash::ShelfItemDetails*);
13 namespace ash {
15 DEFINE_WINDOW_PROPERTY_KEY(ShelfID, kShelfID, kInvalidShelfID);
17 // ShelfItemDetails for kShelfItemDetaildKey is owned by the window
18 // and will be freed automatically.
19 DEFINE_OWNED_WINDOW_PROPERTY_KEY(ShelfItemDetails,
20 kShelfItemDetailsKey,
21 NULL);
23 void SetShelfIDForWindow(ShelfID id, aura::Window* window) {
24 if (!window)
25 return;
27 window->SetProperty(kShelfID, id);
30 ShelfID GetShelfIDForWindow(const aura::Window* window) {
31 DCHECK(window);
32 return window->GetProperty(kShelfID);
35 void SetShelfItemDetailsForWindow(aura::Window* window,
36 const ShelfItemDetails& details) {
37 // |item_details| is owned by |window|.
38 ShelfItemDetails* item_details = new ShelfItemDetails(details);
39 window->SetProperty(kShelfItemDetailsKey, item_details);
42 void SetShelfItemDetailsForDialogWindow(aura::Window* window,
43 int image_resource_id,
44 const base::string16& title) {
45 // |item_details| is owned by |window|.
46 ShelfItemDetails* item_details = new ShelfItemDetails;
47 item_details->type = TYPE_DIALOG;
48 item_details->image_resource_id = image_resource_id;
49 item_details->title = title;
50 window->SetProperty(kShelfItemDetailsKey, item_details);
53 void ClearShelfItemDetailsForWindow(aura::Window* window) {
54 window->ClearProperty(kShelfItemDetailsKey);
57 const ShelfItemDetails* GetShelfItemDetailsForWindow(
58 aura::Window* window) {
59 return window->GetProperty(kShelfItemDetailsKey);
62 } // namespace ash