Home | History | Annotate | Download | only in shelf
      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 
      9 DECLARE_WINDOW_PROPERTY_TYPE(ash::LauncherID);
     10 DECLARE_WINDOW_PROPERTY_TYPE(ash::LauncherItemDetails*);
     11 
     12 namespace ash {
     13 
     14 DEFINE_LOCAL_WINDOW_PROPERTY_KEY(LauncherID, kLauncherID, kInvalidLauncherID);
     15 
     16 // ash::LauncherItemDetails for kLauncherItemDetaildKey is owned by the window
     17 // and will be freed automatically.
     18 DEFINE_OWNED_WINDOW_PROPERTY_KEY(LauncherItemDetails,
     19                                  kLauncherItemDetailsKey,
     20                                  NULL);
     21 
     22 void SetLauncherIDForWindow(LauncherID id, aura::Window* window) {
     23   if (!window)
     24     return;
     25 
     26   window->SetProperty(kLauncherID, id);
     27 }
     28 
     29 LauncherID GetLauncherIDForWindow(aura::Window* window) {
     30   DCHECK(window);
     31   return window->GetProperty(kLauncherID);
     32 }
     33 
     34 void 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 
     41 void ClearLauncherItemDetailsForWindow(aura::Window* window) {
     42   window->ClearProperty(kLauncherItemDetailsKey);
     43 }
     44 
     45 const LauncherItemDetails* GetLauncherItemDetailsForWindow(
     46     aura::Window* window) {
     47   return window->GetProperty(kLauncherItemDetailsKey);
     48 }
     49 
     50 }  // namespace ash
     51