shelf_util.cc revision a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7
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. 4 5#include "ash/shelf/shelf_util.h" 6 7#include "ui/aura/window_property.h" 8 9DECLARE_WINDOW_PROPERTY_TYPE(ash::LauncherID); 10DECLARE_WINDOW_PROPERTY_TYPE(ash::LauncherItemDetails*); 11 12namespace ash { 13 14DEFINE_LOCAL_WINDOW_PROPERTY_KEY(LauncherID, kLauncherID, kInvalidLauncherID); 15 16// ash::LauncherItemDetails for kLauncherItemDetaildKey is owned by the window 17// and will be freed automatically. 18DEFINE_OWNED_WINDOW_PROPERTY_KEY(LauncherItemDetails, 19 kLauncherItemDetailsKey, 20 NULL); 21 22void SetLauncherIDForWindow(LauncherID id, aura::Window* window) { 23 if (!window) 24 return; 25 26 window->SetProperty(kLauncherID, id); 27} 28 29LauncherID GetLauncherIDForWindow(aura::Window* window) { 30 DCHECK(window); 31 return window->GetProperty(kLauncherID); 32} 33 34void SetLauncherItemDetailsForWindow(aura::Window* window, 35 const LauncherItemDetails& details) { 36 // |item_details| is owned by |window|. 37 LauncherItemDetails* item_details = new LauncherItemDetails(details); 38 window->SetProperty(kLauncherItemDetailsKey, item_details); 39} 40 41void ClearLauncherItemDetailsForWindow(aura::Window* window) { 42 window->ClearProperty(kLauncherItemDetailsKey); 43} 44 45const LauncherItemDetails* GetLauncherItemDetailsForWindow( 46 aura::Window* window) { 47 return window->GetProperty(kLauncherItemDetailsKey); 48} 49 50} // namespace ash 51