OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chrome/browser/extensions/extension_install_error_menu_item_id_provide
r.h" | 5 #include "chrome/browser/extensions/extension_install_error_menu_item_id_provide
r.h" |
6 | 6 |
7 #include <bitset> | 7 #include <bitset> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
11 | 11 |
12 namespace extensions { | 12 namespace extensions { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 base::LazyInstance<std::bitset< | 16 base::LazyInstance<std::bitset<IDC_EXTENSION_INSTALL_ERROR_LAST - |
17 IDC_EXTENSION_INSTALL_ERROR_LAST - IDC_EXTENSION_INSTALL_ERROR_FIRST + 1>> | 17 IDC_EXTENSION_INSTALL_ERROR_FIRST + |
18 menu_command_ids = LAZY_INSTANCE_INITIALIZER; | 18 1>>::DestructorAtExit menu_command_ids = |
| 19 LAZY_INSTANCE_INITIALIZER; |
19 | 20 |
20 // Get an available menu ID. | 21 // Get an available menu ID. |
21 int GetMenuCommandID() { | 22 int GetMenuCommandID() { |
22 int id; | 23 int id; |
23 for (id = IDC_EXTENSION_INSTALL_ERROR_FIRST; | 24 for (id = IDC_EXTENSION_INSTALL_ERROR_FIRST; |
24 id <= IDC_EXTENSION_INSTALL_ERROR_LAST; ++id) { | 25 id <= IDC_EXTENSION_INSTALL_ERROR_LAST; ++id) { |
25 if (!menu_command_ids.Get()[id - IDC_EXTENSION_INSTALL_ERROR_FIRST]) { | 26 if (!menu_command_ids.Get()[id - IDC_EXTENSION_INSTALL_ERROR_FIRST]) { |
26 menu_command_ids.Get().set(id - IDC_EXTENSION_INSTALL_ERROR_FIRST); | 27 menu_command_ids.Get().set(id - IDC_EXTENSION_INSTALL_ERROR_FIRST); |
27 return id; | 28 return id; |
28 } | 29 } |
(...skipping 14 matching lines...) Expand all Loading... |
43 ExtensionInstallErrorMenuItemIdProvider:: | 44 ExtensionInstallErrorMenuItemIdProvider:: |
44 ExtensionInstallErrorMenuItemIdProvider() | 45 ExtensionInstallErrorMenuItemIdProvider() |
45 : menu_command_id_(GetMenuCommandID()) {} | 46 : menu_command_id_(GetMenuCommandID()) {} |
46 | 47 |
47 ExtensionInstallErrorMenuItemIdProvider:: | 48 ExtensionInstallErrorMenuItemIdProvider:: |
48 ~ExtensionInstallErrorMenuItemIdProvider() { | 49 ~ExtensionInstallErrorMenuItemIdProvider() { |
49 ReleaseMenuCommandID(menu_command_id_); | 50 ReleaseMenuCommandID(menu_command_id_); |
50 } | 51 } |
51 | 52 |
52 } // namespace extensions | 53 } // namespace extensions |
OLD | NEW |