summaryrefslogtreecommitdiffstats
path: root/ash/shelf
diff options
context:
space:
mode:
authorsimon.hong81@gmail.com <simon.hong81@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-16 02:35:58 +0000
committersimon.hong81@gmail.com <simon.hong81@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-16 02:35:58 +0000
commit472fc7f59c7c7d23d5ca50de3beb51e14134e6b7 (patch)
tree07fef4a0ea51c351f8b7482d37c4f3029e0e5f43 /ash/shelf
parent99dd365e7826d12687ffa9e4a3b372c554889efd (diff)
downloadchromium_src-472fc7f59c7c7d23d5ca50de3beb51e14134e6b7.zip
chromium_src-472fc7f59c7c7d23d5ca50de3beb51e14134e6b7.tar.gz
chromium_src-472fc7f59c7c7d23d5ca50de3beb51e14134e6b7.tar.bz2
Set LauncherID as a Window's Property
Currently, we need to query all LauncherItemController when we need to get window's id. This is very inefficient way. Instead, LauncherID associated with window is set as a window property. R=sky@chromium.org BUG=NONE TEST=browser_tests --gtest_filter=*.MatchingLauncherIDandActiveTab Review URL: https://codereview.chromium.org/27335006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235496 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/shelf')
-rw-r--r--ash/shelf/shelf_util.cc28
-rw-r--r--ash/shelf/shelf_util.h28
2 files changed, 56 insertions, 0 deletions
diff --git a/ash/shelf/shelf_util.cc b/ash/shelf/shelf_util.cc
new file mode 100644
index 0000000..2e86814
--- /dev/null
+++ b/ash/shelf/shelf_util.cc
@@ -0,0 +1,28 @@
+// 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.h"
+#include "ui/aura/window_property.h"
+
+DECLARE_WINDOW_PROPERTY_TYPE(ash::LauncherID);
+
+namespace ash {
+
+DEFINE_LOCAL_WINDOW_PROPERTY_KEY(LauncherID, kLauncherID, 0);
+
+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);
+}
+
+} // namespace ash
diff --git a/ash/shelf/shelf_util.h b/ash/shelf/shelf_util.h
new file mode 100644
index 0000000..30953a7
--- /dev/null
+++ b/ash/shelf/shelf_util.h
@@ -0,0 +1,28 @@
+// 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.
+
+#ifndef ASH_SHELF_SHELF_UTIL_H_
+#define ASH_SHELF_SHELF_UTIL_H_
+
+#include "ash/ash_export.h"
+#include "ash/launcher/launcher_types.h"
+
+namespace aura {
+class Window;
+}
+
+namespace ash {
+
+// Associates LauncherItem of |id| with specified |window|.
+ASH_EXPORT void SetLauncherIDForWindow(LauncherID id, aura::Window* window);
+
+// Returns the id of the LauncherItem associated with the specified |window|,
+// or 0 if there isn't one.
+// Note: Window of a tabbed browser will return the |LauncherID| of the
+// currently active tab.
+ASH_EXPORT LauncherID GetLauncherIDForWindow(aura::Window* window);
+
+} // namespace ash
+
+#endif // ASH_SHELF_SHELF_UTIL_H_