summaryrefslogtreecommitdiffstats
path: root/ash/shelf/shelf_util.cc
blob: f914188b0060b69ca5ab465b5302cf550e5ddf1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// 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 "ui/aura/window_property.h"

DECLARE_WINDOW_PROPERTY_TYPE(ash::LauncherID);
DECLARE_WINDOW_PROPERTY_TYPE(ash::LauncherItemDetails*);

namespace ash {

DEFINE_LOCAL_WINDOW_PROPERTY_KEY(LauncherID, kLauncherID, kInvalidLauncherID);

// ash::LauncherItemDetails for kLauncherItemDetaildKey is owned by the window
// and will be freed automatically.
DEFINE_OWNED_WINDOW_PROPERTY_KEY(LauncherItemDetails,
                                 kLauncherItemDetailsKey,
                                 NULL);

void SetLauncherIDForWindow(LauncherID id, aura::Window* window) {
  if (!window)
    return;

  window->SetProperty(kLauncherID, id);
}

LauncherID GetLauncherIDForWindow(aura::Window* window) {
  DCHECK(window);
  return window->GetProperty(kLauncherID);
}

void SetShelfItemDetailsForWindow(aura::Window* window,
                                  const LauncherItemDetails& details) {
  // |item_details| is owned by |window|.
  LauncherItemDetails* item_details = new LauncherItemDetails(details);
  window->SetProperty(kLauncherItemDetailsKey, item_details);
}

void ClearShelfItemDetailsForWindow(aura::Window* window) {
  window->ClearProperty(kLauncherItemDetailsKey);
}

const LauncherItemDetails* GetLauncherItemDetailsForWindow(
    aura::Window* window) {
  return window->GetProperty(kLauncherItemDetailsKey);
}

}  // namespace ash