Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: chrome/browser/gtk/accelerators_gtk.cc

Issue 5711001: Add a new GetInstance() method for remaining files with singleton classes under chrome/browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/gtk/accelerators_gtk.h" 5 #include "chrome/browser/gtk/accelerators_gtk.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 #include <X11/XF86keysym.h> 9 #include <X11/XF86keysym.h>
10 10
11 #include "base/singleton.h"
11 #include "chrome/app/chrome_command_ids.h" 12 #include "chrome/app/chrome_command_ids.h"
12 13
13 namespace { 14 namespace {
14 15
15 // A mostly complete list of chrome's accelerators. When one command has 16 // A mostly complete list of chrome's accelerators. When one command has
16 // multiple shortcuts, the first one in this list is considered "primary", 17 // multiple shortcuts, the first one in this list is considered "primary",
17 // meaning that it will be displayed in context menus. 18 // meaning that it will be displayed in context menus.
18 const struct AcceleratorMapping { 19 const struct AcceleratorMapping {
19 guint keyval; 20 guint keyval;
20 int command_id; 21 int command_id;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 184
184 if (primary_accelerators_.find(command_id) == 185 if (primary_accelerators_.find(command_id) ==
185 primary_accelerators_.end()) { 186 primary_accelerators_.end()) {
186 primary_accelerators_[command_id] = accelerator; 187 primary_accelerators_[command_id] = accelerator;
187 } 188 }
188 } 189 }
189 } 190 }
190 191
191 AcceleratorsGtk::~AcceleratorsGtk() {} 192 AcceleratorsGtk::~AcceleratorsGtk() {}
192 193
194 // static
195 AcceleratorsGtk* AcceleratorsGtk::GetInstance() {
196 return Singleton<AcceleratorsGtk>::get();
197 }
198
193 const menus::AcceleratorGtk* AcceleratorsGtk::GetPrimaryAcceleratorForCommand( 199 const menus::AcceleratorGtk* AcceleratorsGtk::GetPrimaryAcceleratorForCommand(
194 int command_id) { 200 int command_id) {
195 base::hash_map<int, menus::AcceleratorGtk>::const_iterator iter = 201 base::hash_map<int, menus::AcceleratorGtk>::const_iterator iter =
196 primary_accelerators_.find(command_id); 202 primary_accelerators_.find(command_id);
197 203
198 if (iter == primary_accelerators_.end()) 204 if (iter == primary_accelerators_.end())
199 return NULL; 205 return NULL;
200 206
201 return &iter->second; 207 return &iter->second;
202 } 208 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698