| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_WM_WM_UTILS_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_WM_WM_UTILS_H_ |
| 7 |
| 8 #include <list> |
| 9 #include <map> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/memory/singleton.h" |
| 13 #include "ui/gfx/native_widget_types.h" |
| 14 |
| 15 namespace extensions { |
| 16 namespace api { |
| 17 |
| 18 namespace experimental_wm { |
| 19 class WmWindow; |
| 20 } |
| 21 |
| 22 namespace wm { |
| 23 |
| 24 // WindowIdTracker manages the extension-visible IDs of the native Windows. |
| 25 class WindowIdTracker { |
| 26 private: |
| 27 WindowIdTracker(); |
| 28 ~WindowIdTracker(); |
| 29 |
| 30 public: |
| 31 static WindowIdTracker* GetInstance(); |
| 32 |
| 33 // Returns the extension-visible ID for the window. This generates a new |
| 34 // unique ID for the window if it didn't have one already (or if it was |
| 35 // invalidated by calling UntrackWindow(). |
| 36 int GetWindowExtensionId(gfx::NativeWindow window); |
| 37 |
| 38 // Invalidates the extension-visible ID for the window. |
| 39 void UntrackWindow(gfx::NativeWindow window); |
| 40 |
| 41 private: |
| 42 // Requirement for Signleton |
| 43 friend struct DefaultSingletonTraits<WindowIdTracker>; |
| 44 |
| 45 std::list<gfx::NativeWindow> activation_order_; |
| 46 std::list<gfx::NativeWindow> creation_order_; |
| 47 std::map<int, gfx::NativeWindow> reverse_lookup_; |
| 48 std::map<gfx::NativeWindow, int> lookup_; |
| 49 int next_window_id_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(WindowIdTracker); |
| 52 }; |
| 53 |
| 54 namespace utils { |
| 55 |
| 56 void NativeWindowToExtensionWindow(gfx::NativeWindow window, |
| 57 experimental_wm::WmWindow* extension_window); |
| 58 |
| 59 } // namespace utils |
| 60 } // namespace wm |
| 61 } // namespace api |
| 62 } // namespace extensions |
| 63 |
| 64 #endif // CHROME_BROWSER_EXTENSIONS_API_WM_WM_UTILS_H_ |
| OLD | NEW |