| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_GTK_ACCELERATORS_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_ACCELERATORS_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_ACCELERATORS_GTK_H_ | 6 #define CHROME_BROWSER_GTK_ACCELERATORS_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "app/menus/accelerator_gtk.h" | 9 #include "app/menus/accelerator_gtk.h" |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| 11 | 11 |
| 12 template <typename T> struct DefaultSingletonTraits; |
| 13 |
| 12 class AcceleratorsGtk { | 14 class AcceleratorsGtk { |
| 13 public: | 15 public: |
| 14 AcceleratorsGtk(); | |
| 15 ~AcceleratorsGtk(); | |
| 16 | |
| 17 typedef std::vector<std::pair<int, menus::AcceleratorGtk> > | 16 typedef std::vector<std::pair<int, menus::AcceleratorGtk> > |
| 18 AcceleratorGtkList; | 17 AcceleratorGtkList; |
| 19 typedef AcceleratorGtkList::const_iterator const_iterator; | 18 typedef AcceleratorGtkList::const_iterator const_iterator; |
| 20 | 19 |
| 20 // Returns the singleton instance. |
| 21 static AcceleratorsGtk* GetInstance(); |
| 22 |
| 21 const_iterator const begin() { | 23 const_iterator const begin() { |
| 22 return all_accelerators_.begin(); | 24 return all_accelerators_.begin(); |
| 23 } | 25 } |
| 24 | 26 |
| 25 const_iterator const end() { | 27 const_iterator const end() { |
| 26 return all_accelerators_.end(); | 28 return all_accelerators_.end(); |
| 27 } | 29 } |
| 28 | 30 |
| 29 // Returns NULL if there is no accelerator for the command. | 31 // Returns NULL if there is no accelerator for the command. |
| 30 const menus::AcceleratorGtk* GetPrimaryAcceleratorForCommand(int command_id); | 32 const menus::AcceleratorGtk* GetPrimaryAcceleratorForCommand(int command_id); |
| 31 | 33 |
| 32 private: | 34 private: |
| 35 friend struct DefaultSingletonTraits<AcceleratorsGtk>; |
| 36 |
| 37 AcceleratorsGtk(); |
| 38 ~AcceleratorsGtk(); |
| 39 |
| 33 base::hash_map<int, menus::AcceleratorGtk> primary_accelerators_; | 40 base::hash_map<int, menus::AcceleratorGtk> primary_accelerators_; |
| 34 | 41 |
| 35 AcceleratorGtkList all_accelerators_; | 42 AcceleratorGtkList all_accelerators_; |
| 36 }; | 43 }; |
| 37 | 44 |
| 38 #endif // CHROME_BROWSER_GTK_ACCELERATORS_GTK_H_ | 45 #endif // CHROME_BROWSER_GTK_ACCELERATORS_GTK_H_ |
| OLD | NEW |