| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_VIEWS_FOCUS_VIEW_STORAGE_H_ | 5 #ifndef UI_VIEWS_FOCUS_VIEW_STORAGE_H_ |
| 6 #define UI_VIEWS_FOCUS_VIEW_STORAGE_H_ | 6 #define UI_VIEWS_FOCUS_VIEW_STORAGE_H_ |
| 7 | 7 |
| 8 #include "base/memory/singleton.h" | 8 #include <map> |
| 9 #include "ui/views/view.h" | 9 #include <vector> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "ui/views/views_export.h" |
| 13 |
| 14 template <typename T> struct DefaultSingletonTraits; |
| 10 | 15 |
| 11 // This class is a simple storage place for storing/retrieving views. It is | 16 // This class is a simple storage place for storing/retrieving views. It is |
| 12 // used for example in the FocusManager to store/restore focused views when the | 17 // used for example in the FocusManager to store/restore focused views when the |
| 13 // main window becomes active/inactive. | 18 // main window becomes active/inactive. |
| 14 // It automatically removes a view from the storage if the view is removed from | 19 // It automatically removes a view from the storage if the view is removed from |
| 15 // the tree hierarchy. | 20 // the tree hierarchy. |
| 16 // | 21 // |
| 17 // To use it, you first need to create a view storage id that can then be used | 22 // To use it, you first need to create a view storage id that can then be used |
| 18 // to store/retrieve views. | 23 // to store/retrieve views. |
| 19 | 24 |
| 20 namespace views { | 25 namespace views { |
| 26 class View; |
| 21 | 27 |
| 22 class VIEWS_EXPORT ViewStorage { | 28 class VIEWS_EXPORT ViewStorage { |
| 23 public: | 29 public: |
| 24 // Returns the global ViewStorage instance. | 30 // Returns the global ViewStorage instance. |
| 25 // It is guaranted to be non NULL. | 31 // It is guaranted to be non NULL. |
| 26 static ViewStorage* GetInstance(); | 32 static ViewStorage* GetInstance(); |
| 27 | 33 |
| 28 // Returns a unique storage id that can be used to store/retrieve views. | 34 // Returns a unique storage id that can be used to store/retrieve views. |
| 29 int CreateStorageID(); | 35 int CreateStorageID(); |
| 30 | 36 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 60 | 66 |
| 61 // Association View to id, used to speed up view notification removal. | 67 // Association View to id, used to speed up view notification removal. |
| 62 std::map<View*, std::vector<int>*> view_to_ids_; | 68 std::map<View*, std::vector<int>*> view_to_ids_; |
| 63 | 69 |
| 64 DISALLOW_COPY_AND_ASSIGN(ViewStorage); | 70 DISALLOW_COPY_AND_ASSIGN(ViewStorage); |
| 65 }; | 71 }; |
| 66 | 72 |
| 67 } // namespace views | 73 } // namespace views |
| 68 | 74 |
| 69 #endif // UI_VIEWS_FOCUS_VIEW_STORAGE_H_ | 75 #endif // UI_VIEWS_FOCUS_VIEW_STORAGE_H_ |
| OLD | NEW |