Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / ash / shelf / shelf_util.cc
blob70fa02b23ca17402fae4907284ef128904445cbf
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::ShelfItemDetails*);
12 namespace ash {
14 DEFINE_WINDOW_PROPERTY_KEY(ShelfID, kShelfID, kInvalidShelfID);
16 // ShelfItemDetails for kShelfItemDetaildKey is owned by the window
17 // and will be freed automatically.
18 DEFINE_OWNED_WINDOW_PROPERTY_KEY(ShelfItemDetails,
19 kShelfItemDetailsKey,
20 NULL);
22 void SetShelfIDForWindow(ShelfID id, aura::Window* window) {
23 if (!window)
24 return;
26 window->SetProperty(kShelfID, id);
29 ShelfID GetShelfIDForWindow(const aura::Window* window) {
30 DCHECK(window);
31 return window->GetProperty(kShelfID);
34 void SetShelfItemDetailsForWindow(aura::Window* window,
35 const ShelfItemDetails& details) {
36 // |item_details| is owned by |window|.
37 ShelfItemDetails* item_details = new ShelfItemDetails(details);
38 window->SetProperty(kShelfItemDetailsKey, item_details);
41 void SetShelfItemDetailsForDialogWindow(aura::Window* window,
42 int image_resource_id,
43 const base::string16& title) {
44 // |item_details| is owned by |window|.
45 ShelfItemDetails* item_details = new ShelfItemDetails;
46 item_details->type = TYPE_DIALOG;
47 item_details->image_resource_id = image_resource_id;
48 item_details->title = title;
49 window->SetProperty(kShelfItemDetailsKey, item_details);
52 void ClearShelfItemDetailsForWindow(aura::Window* window) {
53 window->ClearProperty(kShelfItemDetailsKey);
56 const ShelfItemDetails* GetShelfItemDetailsForWindow(
57 aura::Window* window) {
58 return window->GetProperty(kShelfItemDetailsKey);
61 } // namespace ash