summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
authorsail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-27 09:35:38 +0000
committersail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-27 09:35:38 +0000
commit9a6814e36829a671f94ebec06c7f1b42fa927420 (patch)
treeb768b1f52e19fad80a306528e304204a13490352 /chrome/browser/ui
parent8095c85f3ed8508b892d50b9f77bfb7532bb6eb8 (diff)
downloadchromium_src-9a6814e36829a671f94ebec06c7f1b42fa927420.zip
chromium_src-9a6814e36829a671f94ebec06c7f1b42fa927420.tar.gz
chromium_src-9a6814e36829a671f94ebec06c7f1b42fa927420.tar.bz2
Fix ui::Accelerator class hierarchy
Currently ui::Accelerator has two platform specific subclasses (ui::AcceleratorCocoa and ui::AcceleratorGtk). The CL changes the hierarchy so that platform specific data is now stored in a ui::Accelerator::platform_accelerator_ member variable instead. If ui::Accelerator is created by cross platform code or by views code then the member variable is NULL. If it's created by Mac code then it's an instance of ui::PlatformAcceleratorCocoa. If it's create by GTK code then it's an instance of ui::PlatformAcceleratorGtk. This fixes an issue where code would incorrectly cast a ui::Accelerator instance to a platform specific version. With this change the code can instead do a NULL check for ui::Accelerator::platform_accelerator_. I also changed ui::Accelerator::modifiers_ so that it no longer stores cross platform modifier values. It instead store ui::EventFlags values. BUG=160844 Review URL: https://chromiumcodereview.appspot.com/11316071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169615 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/cocoa/accelerators_cocoa.h10
-rw-r--r--chrome/browser/ui/cocoa/accelerators_cocoa.mm10
-rw-r--r--chrome/browser/ui/cocoa/accelerators_cocoa_unittest.mm14
-rw-r--r--chrome/browser/ui/cocoa/confirm_quit_panel_controller.h12
-rw-r--r--chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm57
-rw-r--r--chrome/browser/ui/cocoa/confirm_quit_panel_controller_unittest.mm29
-rw-r--r--chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.mm28
-rw-r--r--chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm10
-rw-r--r--chrome/browser/ui/cocoa/menu_controller.mm15
-rw-r--r--chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.mm18
-rw-r--r--chrome/browser/ui/gtk/accelerators_gtk.cc13
-rw-r--r--chrome/browser/ui/gtk/accelerators_gtk.h14
-rw-r--r--chrome/browser/ui/gtk/accelerators_gtk_unittest.cc11
-rw-r--r--chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc20
-rw-r--r--chrome/browser/ui/gtk/browser_titlebar.cc12
-rw-r--r--chrome/browser/ui/gtk/browser_toolbar_gtk.cc12
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc9
-rw-r--r--chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.cc43
-rw-r--r--chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h7
-rw-r--r--chrome/browser/ui/gtk/global_menu_bar.cc7
-rw-r--r--chrome/browser/ui/gtk/location_bar_view_gtk.cc34
-rw-r--r--chrome/browser/ui/gtk/location_bar_view_gtk.h6
-rw-r--r--chrome/browser/ui/gtk/menu_gtk.cc8
-rw-r--r--chrome/browser/ui/gtk/panels/panel_gtk.cc30
-rw-r--r--chrome/browser/ui/gtk/reload_button_gtk.cc17
-rw-r--r--chrome/browser/ui/gtk/tabs/tab_gtk.cc1
-rw-r--r--chrome/browser/ui/gtk/tabs/tab_strip_menu_controller.cc11
27 files changed, 236 insertions, 222 deletions
diff --git a/chrome/browser/ui/cocoa/accelerators_cocoa.h b/chrome/browser/ui/cocoa/accelerators_cocoa.h
index a04ec03..b0067af 100644
--- a/chrome/browser/ui/cocoa/accelerators_cocoa.h
+++ b/chrome/browser/ui/cocoa/accelerators_cocoa.h
@@ -7,11 +7,11 @@
#include <map>
-#include "ui/base/accelerators/accelerator_cocoa.h"
+#include "ui/base/accelerators/accelerator.h"
template <typename T> struct DefaultSingletonTraits;
-// This class maintains a map of command_ids to AcceleratorCocoa objects (see
+// This class maintains a map of command_ids to Accelerator objects (see
// chrome/app/chrome_command_ids.h). Currently, this only lists the commands
// that are used in the Wrench menu.
//
@@ -25,10 +25,10 @@ template <typename T> struct DefaultSingletonTraits;
//
class AcceleratorsCocoa {
public:
- typedef std::map<int, ui::AcceleratorCocoa> AcceleratorCocoaMap;
+ typedef std::map<int, ui::Accelerator> AcceleratorMap;
// Returns NULL if there is no accelerator for the command.
- const ui::AcceleratorCocoa* GetAcceleratorForCommand(int command_id);
+ const ui::Accelerator* GetAcceleratorForCommand(int command_id);
// Returns the singleton instance.
static AcceleratorsCocoa* GetInstance();
@@ -39,7 +39,7 @@ class AcceleratorsCocoa {
AcceleratorsCocoa();
~AcceleratorsCocoa();
- AcceleratorCocoaMap accelerators_;
+ AcceleratorMap accelerators_;
DISALLOW_COPY_AND_ASSIGN(AcceleratorsCocoa);
};
diff --git a/chrome/browser/ui/cocoa/accelerators_cocoa.mm b/chrome/browser/ui/cocoa/accelerators_cocoa.mm
index 3ec2ed5..ff2e264 100644
--- a/chrome/browser/ui/cocoa/accelerators_cocoa.mm
+++ b/chrome/browser/ui/cocoa/accelerators_cocoa.mm
@@ -8,6 +8,7 @@
#include "base/memory/singleton.h"
#include "chrome/app/chrome_command_ids.h"
+#import "ui/base/accelerators/platform_accelerator_cocoa.h"
namespace {
@@ -44,7 +45,10 @@ const struct AcceleratorMapping {
AcceleratorsCocoa::AcceleratorsCocoa() {
for (size_t i = 0; i < arraysize(kAcceleratorMap); ++i) {
const AcceleratorMapping& entry = kAcceleratorMap[i];
- ui::AcceleratorCocoa accelerator(entry.key, entry.modifiers);
+ ui::Accelerator accelerator(ui::VKEY_UNKNOWN, 0);
+ scoped_ptr<ui::PlatformAccelerator> platform_accelerator(
+ new ui::PlatformAcceleratorCocoa(entry.key, entry.modifiers));
+ accelerator.set_platform_accelerator(platform_accelerator.Pass());
accelerators_.insert(std::make_pair(entry.command_id, accelerator));
}
}
@@ -56,9 +60,9 @@ AcceleratorsCocoa* AcceleratorsCocoa::GetInstance() {
return Singleton<AcceleratorsCocoa>::get();
}
-const ui::AcceleratorCocoa* AcceleratorsCocoa::GetAcceleratorForCommand(
+const ui::Accelerator* AcceleratorsCocoa::GetAcceleratorForCommand(
int command_id) {
- AcceleratorCocoaMap::iterator it = accelerators_.find(command_id);
+ AcceleratorMap::iterator it = accelerators_.find(command_id);
if (it == accelerators_.end())
return NULL;
return &it->second;
diff --git a/chrome/browser/ui/cocoa/accelerators_cocoa_unittest.mm b/chrome/browser/ui/cocoa/accelerators_cocoa_unittest.mm
index 836fece..a773ac5 100644
--- a/chrome/browser/ui/cocoa/accelerators_cocoa_unittest.mm
+++ b/chrome/browser/ui/cocoa/accelerators_cocoa_unittest.mm
@@ -9,20 +9,24 @@
#import "chrome/browser/ui/cocoa/accelerators_cocoa.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/gtest_mac.h"
-#include "ui/base/accelerators/accelerator_cocoa.h"
+#include "ui/base/accelerators/platform_accelerator_cocoa.h"
TEST(AcceleratorsCocoaTest, GetAccelerator) {
AcceleratorsCocoa* keymap = AcceleratorsCocoa::GetInstance();
- const ui::AcceleratorCocoa* accelerator =
+ const ui::Accelerator* accelerator =
keymap->GetAcceleratorForCommand(IDC_COPY);
ASSERT_TRUE(accelerator);
- EXPECT_NSEQ(@"c", accelerator->characters());
- EXPECT_EQ(static_cast<int>(NSCommandKeyMask), accelerator->modifiers());
+ ASSERT_TRUE(accelerator->platform_accelerator());
+ const ui::PlatformAcceleratorCocoa* platform_accelerator =
+ static_cast<const ui::PlatformAcceleratorCocoa*>(
+ accelerator->platform_accelerator());
+ EXPECT_NSEQ(@"c", platform_accelerator->characters());
+ EXPECT_EQ(NSCommandKeyMask, platform_accelerator->modifier_mask());
}
TEST(AcceleratorsCocoaTest, GetNullAccelerator) {
AcceleratorsCocoa* keymap = AcceleratorsCocoa::GetInstance();
- const ui::AcceleratorCocoa* accelerator =
+ const ui::Accelerator* accelerator =
keymap->GetAcceleratorForCommand(314159265);
EXPECT_FALSE(accelerator);
}
diff --git a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.h b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.h
index dbce017..2961f25 100644
--- a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.h
+++ b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.h
@@ -7,10 +7,12 @@
#import <Cocoa/Cocoa.h>
-#include "ui/base/accelerators/accelerator_cocoa.h"
-
@class ConfirmQuitFrameView;
+namespace ui {
+class PlatformAcceleratorCocoa;
+}
+
// The ConfirmQuitPanelController manages the black HUD window that tells users
// to "Hold Cmd+Q to Quit".
@interface ConfirmQuitPanelController : NSWindowController<NSWindowDelegate> {
@@ -38,16 +40,14 @@
// instructions on how to quit.
- (void)dismissPanel;
-// Returns the Accelerator for the Quit menu item.
-+ (ui::AcceleratorCocoa)quitAccelerator;
-
// Returns a string representation fit for display of |+quitAccelerator|.
+ (NSString*)keyCommandString;
@end
@interface ConfirmQuitPanelController (UnitTesting)
-+ (NSString*)keyCombinationForAccelerator:(const ui::AcceleratorCocoa&)item;
++ (NSString*)keyCombinationForAccelerator:
+ (const ui::PlatformAcceleratorCocoa&)item;
@end
#endif // CHROME_BROWSER_UI_COCOA_CONFIRM_QUIT_PANEL_CONTROLLER_H_
diff --git a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm
index eb58c2a..86f8ca5 100644
--- a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm
+++ b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm
@@ -18,6 +18,7 @@
#include "chrome/browser/ui/cocoa/confirm_quit.h"
#include "chrome/common/pref_names.h"
#include "grit/generated_resources.h"
+#import "ui/base/accelerators/platform_accelerator_cocoa.h"
#include "ui/base/l10n/l10n_util_mac.h"
// Constants ///////////////////////////////////////////////////////////////////
@@ -171,6 +172,8 @@ void RegisterLocalState(PrefService* local_state) {
- (NSEvent*)pumpEventQueueForKeyUp:(NSApplication*)app untilDate:(NSDate*)date;
- (void)hideAllWindowsForApplication:(NSApplication*)app
withDuration:(NSTimeInterval)duration;
+// Returns the Accelerator for the Quit menu item.
++ (scoped_ptr<ui::PlatformAcceleratorCocoa>)quitAccelerator;
@end
ConfirmQuitPanelController* g_confirmQuitPanelController = nil;
@@ -218,9 +221,12 @@ ConfirmQuitPanelController* g_confirmQuitPanelController = nil;
+ (BOOL)eventTriggersFeature:(NSEvent*)event {
if ([event type] != NSKeyDown)
return NO;
- ui::AcceleratorCocoa eventAccelerator([event charactersIgnoringModifiers],
+ ui::PlatformAcceleratorCocoa eventAccelerator(
+ [event charactersIgnoringModifiers],
[event modifierFlags] & NSDeviceIndependentModifierFlagsMask);
- return [self quitAccelerator] == eventAccelerator;
+ scoped_ptr<ui::PlatformAcceleratorCocoa> quitAccelerator(
+ [self quitAccelerator]);
+ return quitAccelerator->Equals(eventAccelerator);
}
- (NSApplicationTerminateReply)runModalLoopForApplication:(NSApplication*)app {
@@ -352,29 +358,11 @@ ConfirmQuitPanelController* g_confirmQuitPanelController = nil;
}
// This looks at the Main Menu and determines what the user has set as the
-// key combination for quit. It then gets the modifiers and builds an object
-// to hold the data.
-+ (ui::AcceleratorCocoa)quitAccelerator {
- NSMenu* mainMenu = [NSApp mainMenu];
- // Get the application menu (i.e. Chromium).
- NSMenu* appMenu = [[mainMenu itemAtIndex:0] submenu];
- for (NSMenuItem* item in [appMenu itemArray]) {
- // Find the Quit item.
- if ([item action] == @selector(terminate:)) {
- return ui::AcceleratorCocoa([item keyEquivalent],
- [item keyEquivalentModifierMask]);
- }
- }
- // Default to Cmd+Q.
- return ui::AcceleratorCocoa(@"q", NSCommandKeyMask);
-}
-
-// This looks at the Main Menu and determines what the user has set as the
// key combination for quit. It then gets the modifiers and builds a string
// to display them.
+ (NSString*)keyCommandString {
- ui::AcceleratorCocoa accelerator = [[self class] quitAccelerator];
- return [[self class] keyCombinationForAccelerator:accelerator];
+ scoped_ptr<ui::PlatformAcceleratorCocoa> accelerator([self quitAccelerator]);
+ return [[self class] keyCombinationForAccelerator:*accelerator];
}
// Runs a nested loop that pumps the event queue until the next KeyUp event.
@@ -395,9 +383,30 @@ ConfirmQuitPanelController* g_confirmQuitPanelController = nil;
[animation startAnimation];
}
-+ (NSString*)keyCombinationForAccelerator:(const ui::AcceleratorCocoa&)item {
+// This looks at the Main Menu and determines what the user has set as the
+// key combination for quit. It then gets the modifiers and builds an object
+// to hold the data.
++ (scoped_ptr<ui::PlatformAcceleratorCocoa>)quitAccelerator {
+ NSMenu* mainMenu = [NSApp mainMenu];
+ // Get the application menu (i.e. Chromium).
+ NSMenu* appMenu = [[mainMenu itemAtIndex:0] submenu];
+ for (NSMenuItem* item in [appMenu itemArray]) {
+ // Find the Quit item.
+ if ([item action] == @selector(terminate:)) {
+ return scoped_ptr<ui::PlatformAcceleratorCocoa>(
+ new ui::PlatformAcceleratorCocoa([item keyEquivalent],
+ [item keyEquivalentModifierMask]));
+ }
+ }
+ // Default to Cmd+Q.
+ return scoped_ptr<ui::PlatformAcceleratorCocoa>(
+ new ui::PlatformAcceleratorCocoa(@"q", NSCommandKeyMask));
+}
+
++ (NSString*)keyCombinationForAccelerator:
+ (const ui::PlatformAcceleratorCocoa&)item {
NSMutableString* string = [NSMutableString string];
- NSUInteger modifiers = item.modifiers();
+ NSUInteger modifiers = item.modifier_mask();
if (modifiers & NSCommandKeyMask)
[string appendString:@"\u2318"];
diff --git a/chrome/browser/ui/cocoa/confirm_quit_panel_controller_unittest.mm b/chrome/browser/ui/cocoa/confirm_quit_panel_controller_unittest.mm
index 150f92c..0348801 100644
--- a/chrome/browser/ui/cocoa/confirm_quit_panel_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/confirm_quit_panel_controller_unittest.mm
@@ -8,7 +8,7 @@
#import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
#include "chrome/browser/ui/cocoa/confirm_quit.h"
#include "testing/gtest_mac.h"
-#include "ui/base/accelerators/accelerator_cocoa.h"
+#include "ui/base/accelerators/platform_accelerator_cocoa.h"
namespace {
@@ -44,36 +44,37 @@ TEST_F(ConfirmQuitPanelControllerTest, ShowAndDismiss) {
TEST_F(ConfirmQuitPanelControllerTest, KeyCombinationForAccelerator) {
Class controller = [ConfirmQuitPanelController class];
- ui::AcceleratorCocoa item = ui::AcceleratorCocoa(@"q", NSCommandKeyMask);
+ ui::PlatformAcceleratorCocoa item(@"q", NSCommandKeyMask);
EXPECT_NSEQ(TestString(@"{Cmd}Q"),
[controller keyCombinationForAccelerator:item]);
- item = ui::AcceleratorCocoa(@"c", NSCommandKeyMask | NSShiftKeyMask);
+ ui::PlatformAcceleratorCocoa item2(@"c", NSCommandKeyMask | NSShiftKeyMask);
EXPECT_NSEQ(TestString(@"{Cmd}{Shift}C"),
- [controller keyCombinationForAccelerator:item]);
+ [controller keyCombinationForAccelerator:item2]);
- item = ui::AcceleratorCocoa(@"h",
+ ui::PlatformAcceleratorCocoa item3(@"h",
NSCommandKeyMask | NSShiftKeyMask | NSAlternateKeyMask);
EXPECT_NSEQ(TestString(@"{Cmd}{Opt}{Shift}H"),
- [controller keyCombinationForAccelerator:item]);
+ [controller keyCombinationForAccelerator:item3]);
- item = ui::AcceleratorCocoa(@"r",
+ ui::PlatformAcceleratorCocoa item4(@"r",
NSCommandKeyMask | NSShiftKeyMask | NSAlternateKeyMask |
NSControlKeyMask);
EXPECT_NSEQ(TestString(@"{Cmd}{Ctrl}{Opt}{Shift}R"),
- [controller keyCombinationForAccelerator:item]);
+ [controller keyCombinationForAccelerator:item4]);
- item = ui::AcceleratorCocoa(@"o", NSControlKeyMask);
+ ui::PlatformAcceleratorCocoa item5(@"o", NSControlKeyMask);
EXPECT_NSEQ(TestString(@"{Ctrl}O"),
- [controller keyCombinationForAccelerator:item]);
+ [controller keyCombinationForAccelerator:item5]);
- item = ui::AcceleratorCocoa(@"m", NSShiftKeyMask | NSControlKeyMask);
+ ui::PlatformAcceleratorCocoa item6(@"m", NSShiftKeyMask | NSControlKeyMask);
EXPECT_NSEQ(TestString(@"{Ctrl}{Shift}M"),
- [controller keyCombinationForAccelerator:item]);
+ [controller keyCombinationForAccelerator:item6]);
- item = ui::AcceleratorCocoa(@"e", NSCommandKeyMask | NSAlternateKeyMask);
+ ui::PlatformAcceleratorCocoa item7(
+ @"e", NSCommandKeyMask | NSAlternateKeyMask);
EXPECT_NSEQ(TestString(@"{Cmd}{Opt}E"),
- [controller keyCombinationForAccelerator:item]);
+ [controller keyCombinationForAccelerator:item7]);
}
} // namespace
diff --git a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.mm b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.mm
index 0d9f40e..f7f78fe 100644
--- a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.mm
+++ b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.mm
@@ -27,7 +27,7 @@
#import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
#include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
#import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
-#include "ui/base/accelerators/accelerator_cocoa.h"
+#include "ui/base/accelerators/platform_accelerator_cocoa.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_mac.h"
@@ -55,13 +55,14 @@ const float kHideDuration = 0.7;
- (void)hideSoon;
// Returns the Accelerator for the Toggle Fullscreen menu item.
-+ (ui::AcceleratorCocoa)acceleratorForToggleFullscreen;
++ (scoped_ptr<ui::PlatformAcceleratorCocoa>)acceleratorForToggleFullscreen;
// Returns a string representation fit for display of
// +acceleratorForToggleFullscreen.
+ (NSString*)keyCommandString;
-+ (NSString*)keyCombinationForAccelerator:(const ui::AcceleratorCocoa&)item;
++ (NSString*)keyCombinationForAccelerator:
+ (const ui::PlatformAcceleratorCocoa&)item;
@end
@implementation FullscreenExitBubbleController
@@ -265,34 +266,37 @@ const float kHideDuration = 0.7;
// This looks at the Main Menu and determines what the user has set as the
// key combination for quit. It then gets the modifiers and builds an object
// to hold the data.
-+ (ui::AcceleratorCocoa)acceleratorForToggleFullscreen {
++ (scoped_ptr<ui::PlatformAcceleratorCocoa>)acceleratorForToggleFullscreen {
NSMenu* mainMenu = [NSApp mainMenu];
// Get the application menu (i.e. Chromium).
for (NSMenuItem* menu in [mainMenu itemArray]) {
for (NSMenuItem* item in [[menu submenu] itemArray]) {
// Find the toggle presentation mode item.
if ([item tag] == IDC_PRESENTATION_MODE) {
- return ui::AcceleratorCocoa([item keyEquivalent],
- [item keyEquivalentModifierMask]);
+ return scoped_ptr<ui::PlatformAcceleratorCocoa>(
+ new ui::PlatformAcceleratorCocoa([item keyEquivalent],
+ [item keyEquivalentModifierMask]));
}
}
}
// Default to Cmd+Shift+F.
- return ui::AcceleratorCocoa(@"f", NSCommandKeyMask|NSShiftKeyMask);
+ return scoped_ptr<ui::PlatformAcceleratorCocoa>(
+ new ui::PlatformAcceleratorCocoa(@"f", NSCommandKeyMask|NSShiftKeyMask));
}
// This looks at the Main Menu and determines what the user has set as the
// key combination for quit. It then gets the modifiers and builds a string
// to display them.
+ (NSString*)keyCommandString {
- ui::AcceleratorCocoa accelerator =
- [[self class] acceleratorForToggleFullscreen];
- return [[self class] keyCombinationForAccelerator:accelerator];
+ scoped_ptr<ui::PlatformAcceleratorCocoa> accelerator(
+ [[self class] acceleratorForToggleFullscreen]);
+ return [[self class] keyCombinationForAccelerator:*accelerator];
}
-+ (NSString*)keyCombinationForAccelerator:(const ui::AcceleratorCocoa&)item {
++ (NSString*)keyCombinationForAccelerator:
+ (const ui::PlatformAcceleratorCocoa&)item {
NSMutableString* string = [NSMutableString string];
- NSUInteger modifiers = item.modifiers();
+ NSUInteger modifiers = item.modifier_mask();
if (modifiers & NSCommandKeyMask)
[string appendString:@"\u2318"];
diff --git a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm
index f9c0e85..26db023d 100644
--- a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm
@@ -18,7 +18,7 @@
#include "content/public/test/test_utils.h"
#include "ipc/ipc_message.h"
#include "testing/gtest_mac.h"
-#include "ui/base/accelerators/accelerator_cocoa.h"
+#include "ui/base/accelerators/platform_accelerator_cocoa.h"
using content::SiteInstance;
using content::WebContents;
@@ -26,7 +26,8 @@ using content::WebContents;
@interface FullscreenExitBubbleController(JustForTesting)
// Already defined.
+ (NSString*)keyCommandString;
-+ (NSString*)keyCombinationForAccelerator:(const ui::AcceleratorCocoa&)item;
++ (NSString*)keyCombinationForAccelerator:
+ (const ui::PlatformAcceleratorCocoa&)item;
@end
@interface FullscreenExitBubbleController(ExposedForTesting)
@@ -116,8 +117,9 @@ TEST_F(FullscreenExitBubbleControllerTest, LabelWasReplaced) {
}
TEST_F(FullscreenExitBubbleControllerTest, ShortcutText) {
- ui::AcceleratorCocoa cmd_F(@"F", NSCommandKeyMask);
- ui::AcceleratorCocoa cmd_shift_f(@"f", NSCommandKeyMask|NSShiftKeyMask);
+ ui::PlatformAcceleratorCocoa cmd_F(@"F", NSCommandKeyMask);
+ ui::PlatformAcceleratorCocoa cmd_shift_f(
+ @"f", NSCommandKeyMask | NSShiftKeyMask);
NSString* cmd_F_text = [FullscreenExitBubbleController
keyCombinationForAccelerator:cmd_F];
NSString* cmd_shift_f_text = [FullscreenExitBubbleController
diff --git a/chrome/browser/ui/cocoa/menu_controller.mm b/chrome/browser/ui/cocoa/menu_controller.mm
index aae1dcb..9563ee2 100644
--- a/chrome/browser/ui/cocoa/menu_controller.mm
+++ b/chrome/browser/ui/cocoa/menu_controller.mm
@@ -7,7 +7,8 @@
#include "base/logging.h"
#include "base/sys_string_conversions.h"
#import "chrome/browser/ui/cocoa/event_utils.h"
-#include "ui/base/accelerators/accelerator_cocoa.h"
+#include "ui/base/accelerators/accelerator.h"
+#include "ui/base/accelerators/platform_accelerator_cocoa.h"
#include "ui/base/l10n/l10n_util_mac.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/gfx/image/image.h"
@@ -128,10 +129,16 @@
[item setTarget:self];
NSValue* modelObject = [NSValue valueWithPointer:model];
[item setRepresentedObject:modelObject]; // Retains |modelObject|.
- ui::AcceleratorCocoa accelerator;
+ ui::Accelerator accelerator;
if (model->GetAcceleratorAt(modelIndex, &accelerator)) {
- [item setKeyEquivalent:accelerator.characters()];
- [item setKeyEquivalentModifierMask:accelerator.modifiers()];
+ const ui::PlatformAcceleratorCocoa* platformAccelerator =
+ static_cast<const ui::PlatformAcceleratorCocoa*>(
+ accelerator.platform_accelerator());
+ if (platformAccelerator) {
+ [item setKeyEquivalent:platformAccelerator->characters()];
+ [item setKeyEquivalentModifierMask:
+ platformAccelerator->modifier_mask()];
+ }
}
}
[menu insertItem:item atIndex:index];
diff --git a/chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.mm b/chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.mm
index 0223e4b..9e823f4 100644
--- a/chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.mm
+++ b/chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.mm
@@ -30,7 +30,6 @@
#include "content/public/browser/user_metrics.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
-#include "ui/base/accelerators/accelerator_cocoa.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/menu_model.h"
@@ -52,19 +51,14 @@ namespace WrenchMenuControllerInternal {
class AcceleratorDelegate : public ui::AcceleratorProvider {
public:
virtual bool GetAcceleratorForCommandId(int command_id,
- ui::Accelerator* accelerator_generic) {
- // Downcast so that when the copy constructor is invoked below, the key
- // string gets copied, too.
- ui::AcceleratorCocoa* out_accelerator =
- static_cast<ui::AcceleratorCocoa*>(accelerator_generic);
+ ui::Accelerator* out_accelerator) {
AcceleratorsCocoa* keymap = AcceleratorsCocoa::GetInstance();
- const ui::AcceleratorCocoa* accelerator =
+ const ui::Accelerator* accelerator =
keymap->GetAcceleratorForCommand(command_id);
- if (accelerator) {
- *out_accelerator = *accelerator;
- return true;
- }
- return false;
+ if (!accelerator)
+ return false;
+ *out_accelerator = *accelerator;
+ return true;
}
};
diff --git a/chrome/browser/ui/gtk/accelerators_gtk.cc b/chrome/browser/ui/gtk/accelerators_gtk.cc
index d1116b3..9f9ffa9 100644
--- a/chrome/browser/ui/gtk/accelerators_gtk.cc
+++ b/chrome/browser/ui/gtk/accelerators_gtk.cc
@@ -10,6 +10,9 @@
#include "base/memory/singleton.h"
#include "chrome/app/chrome_command_ids.h"
+#include "ui/base/accelerators/platform_accelerator_gtk.h"
+#include "ui/base/events/event_conversion_gtk.h"
+#include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
namespace {
@@ -186,18 +189,20 @@ AcceleratorsGtk* AcceleratorsGtk::GetInstance() {
return Singleton<AcceleratorsGtk>::get();
}
-const ui::AcceleratorGtk* AcceleratorsGtk::GetPrimaryAcceleratorForCommand(
+const ui::Accelerator* AcceleratorsGtk::GetPrimaryAcceleratorForCommand(
int command_id) {
- AcceleratorGtkMap::const_iterator i(primary_accelerators_.find(command_id));
+ AcceleratorMap::const_iterator i(primary_accelerators_.find(command_id));
return i != primary_accelerators_.end() ? &i->second : NULL;
}
AcceleratorsGtk::AcceleratorsGtk() {
for (size_t i = 0; i < arraysize(kAcceleratorMap); ++i) {
const AcceleratorMapping& entry = kAcceleratorMap[i];
- ui::AcceleratorGtk accelerator(entry.keyval, entry.modifier_type);
- all_accelerators_.push_back(std::make_pair(entry.command_id, accelerator));
+ ui::Accelerator accelerator = ui::AcceleratorForGdkKeyCodeAndModifier(
+ entry.keyval, entry.modifier_type);
+
+ all_accelerators_.push_back(std::make_pair(entry.command_id, accelerator));
if (primary_accelerators_.find(entry.command_id) ==
primary_accelerators_.end()) {
primary_accelerators_[entry.command_id] = accelerator;
diff --git a/chrome/browser/ui/gtk/accelerators_gtk.h b/chrome/browser/ui/gtk/accelerators_gtk.h
index 52b0f0b..3a57dbf 100644
--- a/chrome/browser/ui/gtk/accelerators_gtk.h
+++ b/chrome/browser/ui/gtk/accelerators_gtk.h
@@ -6,14 +6,14 @@
#define CHROME_BROWSER_UI_GTK_ACCELERATORS_GTK_H_
#include "base/hash_tables.h"
-#include "ui/base/accelerators/accelerator_gtk.h"
+#include "ui/base/accelerators/accelerator.h"
template <typename T> struct DefaultSingletonTraits;
class AcceleratorsGtk {
public:
- typedef std::vector<std::pair<int, ui::AcceleratorGtk> > AcceleratorGtkList;
- typedef AcceleratorGtkList::const_iterator const_iterator;
+ typedef std::vector<std::pair<int, ui::Accelerator> > AcceleratorList;
+ typedef AcceleratorList::const_iterator const_iterator;
// Returns the singleton instance.
static AcceleratorsGtk* GetInstance();
@@ -22,7 +22,7 @@ class AcceleratorsGtk {
const_iterator const end() { return all_accelerators_.end(); }
// Returns NULL if there is no accelerator for the command.
- const ui::AcceleratorGtk* GetPrimaryAcceleratorForCommand(int command_id);
+ const ui::Accelerator* GetPrimaryAcceleratorForCommand(int command_id);
private:
friend struct DefaultSingletonTraits<AcceleratorsGtk>;
@@ -30,10 +30,10 @@ class AcceleratorsGtk {
AcceleratorsGtk();
~AcceleratorsGtk();
- typedef base::hash_map<int, ui::AcceleratorGtk> AcceleratorGtkMap;
- AcceleratorGtkMap primary_accelerators_;
+ typedef base::hash_map<int, ui::Accelerator> AcceleratorMap;
+ AcceleratorMap primary_accelerators_;
- AcceleratorGtkList all_accelerators_;
+ AcceleratorList all_accelerators_;
};
#endif // CHROME_BROWSER_UI_GTK_ACCELERATORS_GTK_H_
diff --git a/chrome/browser/ui/gtk/accelerators_gtk_unittest.cc b/chrome/browser/ui/gtk/accelerators_gtk_unittest.cc
index 4ef4a2f..00083c7 100644
--- a/chrome/browser/ui/gtk/accelerators_gtk_unittest.cc
+++ b/chrome/browser/ui/gtk/accelerators_gtk_unittest.cc
@@ -8,20 +8,21 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/gtk/accelerators_gtk.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/base/accelerators/accelerator_gtk.h"
+#include "ui/base/accelerators/platform_accelerator_gtk.h"
TEST(AcceleratorsGtkTest, GetAccelerator) {
AcceleratorsGtk* keymap = AcceleratorsGtk::GetInstance();
- const ui::AcceleratorGtk* accelerator =
+ const ui::Accelerator* accelerator =
keymap->GetPrimaryAcceleratorForCommand(IDC_COPY);
ASSERT_TRUE(accelerator);
- EXPECT_EQ(static_cast<guint>(GDK_c), accelerator->GetGdkKeyCode());
- EXPECT_EQ(GDK_CONTROL_MASK, accelerator->modifiers());
+ EXPECT_EQ(static_cast<guint>(GDK_c),
+ GetGdkKeyCodeForAccelerator(*accelerator));
+ EXPECT_EQ(GDK_CONTROL_MASK, GetGdkModifierForAccelerator(*accelerator));
}
TEST(AcceleratorsGtkTest, GetNullAccelerator) {
AcceleratorsGtk* keymap = AcceleratorsGtk::GetInstance();
- const ui::AcceleratorGtk* accelerator =
+ const ui::Accelerator* accelerator =
keymap->GetPrimaryAcceleratorForCommand(IDC_MinimumLabelValue - 1);
EXPECT_FALSE(accelerator);
}
diff --git a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
index bcdb515..eb2fa88 100644
--- a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
@@ -43,7 +43,7 @@
#include "content/public/browser/notification_source.h"
#include "grit/theme_resources.h"
#include "grit/ui_resources.h"
-#include "ui/base/accelerators/accelerator_gtk.h"
+#include "ui/base/accelerators/platform_accelerator_gtk.h"
#include "ui/base/gtk/gtk_compat.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas_skia_paint.h"
@@ -391,11 +391,7 @@ class BrowserActionButton : public content::NotificationObserver,
&command,
NULL)) {
// Found the browser action shortcut command, register it.
- keybinding_.reset(new ui::AcceleratorGtk(
- command.accelerator().key_code(),
- command.accelerator().IsShiftDown(),
- command.accelerator().IsCtrlDown(),
- command.accelerator().IsAltDown()));
+ keybinding_ = command.accelerator();
gfx::NativeWindow window =
toolbar_->browser()->window()->GetNativeWindow();
@@ -404,8 +400,8 @@ class BrowserActionButton : public content::NotificationObserver,
gtk_accel_group_connect(
accel_group_,
- keybinding_.get()->GetGdkKeyCode(),
- keybinding_.get()->gdk_modifier_type(),
+ ui::GetGdkKeyCodeForAccelerator(keybinding_),
+ ui::GetGdkModifierForAccelerator(keybinding_),
GtkAccelFlags(0),
g_cclosure_new(G_CALLBACK(OnGtkAccelerator), this, NULL));
@@ -425,12 +421,12 @@ class BrowserActionButton : public content::NotificationObserver,
toolbar_->browser()->window()->GetNativeWindow();
gtk_accel_group_disconnect_key(
accel_group_,
- keybinding_.get()->GetGdkKeyCode(),
- static_cast<GdkModifierType>(keybinding_.get()->modifiers()));
+ ui::GetGdkKeyCodeForAccelerator(keybinding_),
+ GetGdkModifierForAccelerator(keybinding_));
gtk_window_remove_accel_group(window, accel_group_);
g_object_unref(accel_group_);
accel_group_ = NULL;
- keybinding_.reset(NULL);
+ keybinding_ = ui::Accelerator();
// We've removed the accelerator, so no need to listen to this anymore.
registrar_.Remove(this,
@@ -482,7 +478,7 @@ class BrowserActionButton : public content::NotificationObserver,
GtkAccelGroup* accel_group_;
// The keybinding accelerator registered to show the browser action popup.
- scoped_ptr<ui::AcceleratorGtk> keybinding_;
+ ui::Accelerator keybinding_;
// The context menu view and model for this extension action.
scoped_ptr<MenuGtk> context_menu_;
diff --git a/chrome/browser/ui/gtk/browser_titlebar.cc b/chrome/browser/ui/gtk/browser_titlebar.cc
index 536c367..a3a49a1 100644
--- a/chrome/browser/ui/gtk/browser_titlebar.cc
+++ b/chrome/browser/ui/gtk/browser_titlebar.cc
@@ -969,13 +969,15 @@ void BrowserTitlebar::ExecuteCommand(int command_id) {
}
bool BrowserTitlebar::GetAcceleratorForCommandId(
- int command_id, ui::Accelerator* accelerator) {
- const ui::AcceleratorGtk* accelerator_gtk =
+ int command_id,
+ ui::Accelerator* out_accelerator) {
+ const ui::Accelerator* accelerator =
AcceleratorsGtk::GetInstance()->GetPrimaryAcceleratorForCommand(
command_id);
- if (accelerator_gtk)
- *accelerator = *accelerator_gtk;
- return accelerator_gtk;
+ if (!accelerator)
+ return false;
+ *out_accelerator = *accelerator;
+ return true;
}
void BrowserTitlebar::Observe(int type,
diff --git a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc
index edd0ee0..11e1b2b 100644
--- a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc
@@ -52,7 +52,6 @@
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
-#include "ui/base/accelerators/accelerator_gtk.h"
#include "ui/base/dragdrop/gtk_dnd_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -364,12 +363,13 @@ bool BrowserToolbarGtk::AlwaysShowIconForCmd(int command_id) const {
bool BrowserToolbarGtk::GetAcceleratorForCommandId(
int id,
- ui::Accelerator* accelerator) {
- const ui::AcceleratorGtk* accelerator_gtk =
+ ui::Accelerator* out_accelerator) {
+ const ui::Accelerator* accelerator =
AcceleratorsGtk::GetInstance()->GetPrimaryAcceleratorForCommand(id);
- if (accelerator_gtk)
- *accelerator = *accelerator_gtk;
- return !!accelerator_gtk;
+ if (!accelerator)
+ return false;
+ *out_accelerator = *accelerator;
+ return true;
}
// content::NotificationObserver -----------------------------------------------
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index 422112f..976e415 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -96,6 +96,7 @@
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "grit/ui_resources.h"
+#include "ui/base/accelerators/platform_accelerator_gtk.h"
#include "ui/base/gtk/gtk_floating_container.h"
#include "ui/base/gtk/gtk_hig_constants.h"
#include "ui/base/gtk/gtk_screen_util.h"
@@ -662,8 +663,8 @@ void BrowserWindowGtk::Close() {
for (AcceleratorsGtk::const_iterator iter = accelerators->begin();
iter != accelerators->end(); ++iter) {
gtk_accel_group_disconnect_key(accel_group_,
- iter->second.GetGdkKeyCode(),
- static_cast<GdkModifierType>(iter->second.modifiers()));
+ ui::GetGdkKeyCodeForAccelerator(iter->second),
+ ui::GetGdkModifierForAccelerator(iter->second));
}
gtk_window_remove_accel_group(window_, accel_group_);
g_object_unref(accel_group_);
@@ -1822,8 +1823,8 @@ void BrowserWindowGtk::ConnectAccelerators() {
iter != accelerators->end(); ++iter) {
gtk_accel_group_connect(
accel_group_,
- iter->second.GetGdkKeyCode(),
- static_cast<GdkModifierType>(iter->second.modifiers()),
+ ui::GetGdkKeyCodeForAccelerator(iter->second),
+ ui::GetGdkModifierForAccelerator(iter->second),
GtkAccelFlags(0),
g_cclosure_new(G_CALLBACK(OnGtkAccelerator),
GINT_TO_POINTER(iter->first), NULL));
diff --git a/chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.cc b/chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.cc
index a251c9d..1c46a4f 100644
--- a/chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.cc
+++ b/chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.cc
@@ -11,7 +11,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/extension.h"
-#include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
+#include "ui/base/accelerators/platform_accelerator_gtk.h"
// static
void extensions::ExtensionKeybindingRegistry::SetShortcutHandlingSuspended(
@@ -50,10 +50,9 @@ gboolean ExtensionKeybindingRegistryGtk::HasPriorityHandler(
if (shortcut_handling_suspended_)
return FALSE;
- ui::AcceleratorGtk accelerator(ui::WindowsKeyCodeForGdkKeyCode(event->keyval),
- event->state & GDK_SHIFT_MASK,
- event->state & GDK_CONTROL_MASK,
- event->state & GDK_MOD1_MASK);
+ ui::Accelerator accelerator = ui::AcceleratorForGdkKeyCodeAndModifier(
+ event->keyval, static_cast<GdkModifierType>(event->state));
+
return event_targets_.find(accelerator) != event_targets_.end();
}
@@ -73,10 +72,7 @@ void ExtensionKeybindingRegistryGtk::AddExtensionKeybinding(
if (!command_name.empty() && (iter->second.command_name() != command_name))
continue;
- ui::AcceleratorGtk accelerator(iter->second.accelerator().key_code(),
- iter->second.accelerator().IsShiftDown(),
- iter->second.accelerator().IsCtrlDown(),
- iter->second.accelerator().IsAltDown());
+ ui::Accelerator accelerator(iter->second.accelerator());
event_targets_[accelerator] =
std::make_pair(extension->id(), iter->second.command_name());
@@ -87,8 +83,8 @@ void ExtensionKeybindingRegistryGtk::AddExtensionKeybinding(
gtk_accel_group_connect(
accel_group_,
- accelerator.GetGdkKeyCode(),
- accelerator.gdk_modifier_type(),
+ ui::GetGdkKeyCodeForAccelerator(accelerator),
+ ui::GetGdkModifierForAccelerator(accelerator),
GtkAccelFlags(0),
g_cclosure_new(G_CALLBACK(OnGtkAcceleratorThunk), this, NULL));
}
@@ -102,10 +98,7 @@ void ExtensionKeybindingRegistryGtk::AddExtensionKeybinding(
extensions::CommandService::ACTIVE_ONLY,
&browser_action,
NULL)) {
- ui::AcceleratorGtk accelerator(browser_action.accelerator().key_code(),
- browser_action.accelerator().IsShiftDown(),
- browser_action.accelerator().IsCtrlDown(),
- browser_action.accelerator().IsAltDown());
+ ui::Accelerator accelerator(browser_action.accelerator());
event_targets_[accelerator] =
std::make_pair(extension->id(), browser_action.command_name());
}
@@ -117,10 +110,7 @@ void ExtensionKeybindingRegistryGtk::AddExtensionKeybinding(
extensions::CommandService::ACTIVE_ONLY,
&page_action,
NULL)) {
- ui::AcceleratorGtk accelerator(page_action.accelerator().key_code(),
- page_action.accelerator().IsShiftDown(),
- page_action.accelerator().IsCtrlDown(),
- page_action.accelerator().IsAltDown());
+ ui::Accelerator accelerator(page_action.accelerator());
event_targets_[accelerator] =
std::make_pair(extension->id(), page_action.command_name());
}
@@ -132,10 +122,7 @@ void ExtensionKeybindingRegistryGtk::AddExtensionKeybinding(
extensions::CommandService::ACTIVE_ONLY,
&script_badge,
NULL)) {
- ui::AcceleratorGtk accelerator(script_badge.accelerator().key_code(),
- script_badge.accelerator().IsShiftDown(),
- script_badge.accelerator().IsCtrlDown(),
- script_badge.accelerator().IsAltDown());
+ ui::Accelerator accelerator(script_badge.accelerator());
event_targets_[accelerator] =
std::make_pair(extension->id(), script_badge.command_name());
}
@@ -155,9 +142,10 @@ void ExtensionKeybindingRegistryGtk::RemoveExtensionKeybinding(
// On GTK, unlike Windows, the Event Targets contain all events but we must
// only unregister the ones we registered targets for.
if (!ShouldIgnoreCommand(iter->second.second)) {
- gtk_accel_group_disconnect_key(accel_group_,
- iter->first.GetGdkKeyCode(),
- iter->first.gdk_modifier_type());
+ gtk_accel_group_disconnect_key(
+ accel_group_,
+ ui::GetGdkKeyCodeForAccelerator(iter->first),
+ ui::GetGdkModifierForAccelerator(iter->first));
}
EventTargets::iterator old = iter++;
@@ -170,7 +158,8 @@ gboolean ExtensionKeybindingRegistryGtk::OnGtkAccelerator(
GObject* acceleratable,
guint keyval,
GdkModifierType modifier) {
- ui::AcceleratorGtk accelerator(keyval, modifier);
+ ui::Accelerator accelerator = ui::AcceleratorForGdkKeyCodeAndModifier(
+ keyval, modifier);
EventTargets::iterator it = event_targets_.find(accelerator);
if (it == event_targets_.end()) {
diff --git a/chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h b/chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h
index 1228c2e..8b3ac20 100644
--- a/chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h
+++ b/chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h
@@ -5,12 +5,13 @@
#ifndef CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_GTK_H_
#define CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_GTK_H_
+#include <gdk/gdk.h>
#include <map>
#include <string>
#include "base/compiler_specific.h"
#include "chrome/browser/extensions/extension_keybinding_registry.h"
-#include "ui/base/accelerators/accelerator_gtk.h"
+#include "ui/base/accelerators/accelerator.h"
#include "ui/base/gtk/gtk_signal.h"
#include "ui/gfx/native_widget_types.h"
@@ -84,11 +85,11 @@ class ExtensionKeybindingRegistryGtk
// The accelerator group used to handle accelerators, owned by this object.
GtkAccelGroup* accel_group_;
- // Maps a GTK accelerator to a string pair (extension id, command name) for
+ // Maps an accelerator to a string pair (extension id, command name) for
// commands that have been registered. Unlike its Views counterpart, this map
// contains browserAction and pageAction commands (but does not route those
// events), so that we can query priority handlers in HasPriorityHandler(...).
- typedef std::map< ui::AcceleratorGtk,
+ typedef std::map< ui::Accelerator,
std::pair<std::string, std::string> > EventTargets;
EventTargets event_targets_;
diff --git a/chrome/browser/ui/gtk/global_menu_bar.cc b/chrome/browser/ui/gtk/global_menu_bar.cc
index 8476253..1e3add7 100644
--- a/chrome/browser/ui/gtk/global_menu_bar.cc
+++ b/chrome/browser/ui/gtk/global_menu_bar.cc
@@ -21,6 +21,7 @@
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
#include "grit/generated_resources.h"
+#include "ui/base/accelerators/platform_accelerator_gtk.h"
#include "ui/base/gtk/menu_label_accelerator_util.h"
#include "ui/base/l10n/l10n_util.h"
@@ -175,14 +176,14 @@ GlobalMenuBar::GlobalMenuBar(Browser* browser)
// Set the accelerator for each menu item.
AcceleratorsGtk* accelerators = AcceleratorsGtk::GetInstance();
- const ui::AcceleratorGtk* accelerator =
+ const ui::Accelerator* accelerator =
accelerators->GetPrimaryAcceleratorForCommand(it->first);
if (accelerator) {
gtk_widget_add_accelerator(it->second,
"activate",
dummy_accel_group_,
- accelerator->GetGdkKeyCode(),
- accelerator->gdk_modifier_type(),
+ ui::GetGdkKeyCodeForAccelerator(*accelerator),
+ ui::GetGdkModifierForAccelerator(*accelerator),
GTK_ACCEL_VISIBLE);
}
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
index 2e286a9..52f93cb 100644
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
@@ -80,7 +80,7 @@
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "net/base/net_util.h"
-#include "ui/base/accelerators/accelerator_gtk.h"
+#include "ui/base/accelerators/platform_accelerator_gtk.h"
#include "ui/base/dragdrop/gtk_dnd_util.h"
#include "ui/base/gtk/gtk_hig_constants.h"
#include "ui/base/gtk/gtk_signal_registrar.h"
@@ -1940,11 +1940,8 @@ void LocationBarViewGtk::PageActionViewGtk::ConnectPageActionAccelerator() {
&command_page_action,
NULL)) {
// Found the page action shortcut command, register it.
- page_action_keybinding_.reset(new ui::AcceleratorGtk(
- command_page_action.accelerator().key_code(),
- command_page_action.accelerator().IsShiftDown(),
- command_page_action.accelerator().IsCtrlDown(),
- command_page_action.accelerator().IsAltDown()));
+ page_action_keybinding_.reset(
+ new ui::Accelerator(command_page_action.accelerator()));
}
extensions::Command command_script_badge;
@@ -1954,11 +1951,8 @@ void LocationBarViewGtk::PageActionViewGtk::ConnectPageActionAccelerator() {
&command_script_badge,
NULL)) {
// Found the script badge shortcut command, register it.
- script_badge_keybinding_.reset(new ui::AcceleratorGtk(
- command_script_badge.accelerator().key_code(),
- command_script_badge.accelerator().IsShiftDown(),
- command_script_badge.accelerator().IsCtrlDown(),
- command_script_badge.accelerator().IsAltDown()));
+ script_badge_keybinding_.reset(
+ new ui::Accelerator(command_script_badge.accelerator()));
}
if (page_action_keybinding_.get() || script_badge_keybinding_.get()) {
@@ -1968,16 +1962,16 @@ void LocationBarViewGtk::PageActionViewGtk::ConnectPageActionAccelerator() {
if (page_action_keybinding_.get()) {
gtk_accel_group_connect(
accel_group_,
- page_action_keybinding_->GetGdkKeyCode(),
- page_action_keybinding_->gdk_modifier_type(),
+ ui::GetGdkKeyCodeForAccelerator(*page_action_keybinding_),
+ ui::GetGdkModifierForAccelerator(*page_action_keybinding_),
GtkAccelFlags(0),
g_cclosure_new(G_CALLBACK(OnGtkAccelerator), this, NULL));
}
if (script_badge_keybinding_.get()) {
gtk_accel_group_connect(
accel_group_,
- script_badge_keybinding_->GetGdkKeyCode(),
- script_badge_keybinding_->gdk_modifier_type(),
+ ui::GetGdkKeyCodeForAccelerator(*script_badge_keybinding_),
+ ui::GetGdkModifierForAccelerator(*script_badge_keybinding_),
GtkAccelFlags(0),
g_cclosure_new(G_CALLBACK(OnGtkAccelerator), this, NULL));
}
@@ -1999,16 +1993,14 @@ void LocationBarViewGtk::PageActionViewGtk::DisconnectPageActionAccelerator() {
if (page_action_keybinding_.get()) {
gtk_accel_group_disconnect_key(
accel_group_,
- page_action_keybinding_->GetGdkKeyCode(),
- static_cast<GdkModifierType>(
- page_action_keybinding_->modifiers()));
+ ui::GetGdkKeyCodeForAccelerator(*page_action_keybinding_),
+ ui::GetGdkModifierForAccelerator(*page_action_keybinding_));
}
if (script_badge_keybinding_.get()) {
gtk_accel_group_disconnect_key(
accel_group_,
- script_badge_keybinding_->GetGdkKeyCode(),
- static_cast<GdkModifierType>(
- script_badge_keybinding_->modifiers()));
+ ui::GetGdkKeyCodeForAccelerator(*script_badge_keybinding_),
+ ui::GetGdkModifierForAccelerator(*script_badge_keybinding_));
}
gtk_window_remove_accel_group(window_, accel_group_);
g_object_unref(accel_group_);
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.h b/chrome/browser/ui/gtk/location_bar_view_gtk.h
index 1c0d329..03fbd82 100644
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.h
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.h
@@ -55,7 +55,7 @@ class Image;
}
namespace ui {
-class AcceleratorGtk;
+class Accelerator;
}
class LocationBarViewGtk : public OmniboxEditController,
@@ -320,9 +320,9 @@ class LocationBarViewGtk : public OmniboxEditController,
GtkAccelGroup* accel_group_;
// The keybinding accelerator registered to show the page action popup.
- scoped_ptr<ui::AcceleratorGtk> page_action_keybinding_;
+ scoped_ptr<ui::Accelerator> page_action_keybinding_;
// The keybinding accelerator registered to show the script badge popup.
- scoped_ptr<ui::AcceleratorGtk> script_badge_keybinding_;
+ scoped_ptr<ui::Accelerator> script_badge_keybinding_;
// This is used for post-install visual feedback. The page_action icon
// is briefly shown even if it hasn't been enabled by its extension.
diff --git a/chrome/browser/ui/gtk/menu_gtk.cc b/chrome/browser/ui/gtk/menu_gtk.cc
index 3e8a57d..db21f63 100644
--- a/chrome/browser/ui/gtk/menu_gtk.cc
+++ b/chrome/browser/ui/gtk/menu_gtk.cc
@@ -18,7 +18,7 @@
#include "chrome/browser/ui/gtk/gtk_custom_menu_item.h"
#include "chrome/browser/ui/gtk/gtk_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/base/accelerators/accelerator_gtk.h"
+#include "ui/base/accelerators/platform_accelerator_gtk.h"
#include "ui/base/gtk/menu_label_accelerator_util.h"
#include "ui/base/models/button_menu_item_model.h"
#include "ui/base/models/menu_model.h"
@@ -515,13 +515,13 @@ void MenuGtk::BuildSubmenuFromModel(ui::MenuModel* model, GtkWidget* menu) {
connect_to_activate = false;
}
- ui::AcceleratorGtk accelerator;
+ ui::Accelerator accelerator;
if (model->GetAcceleratorAt(i, &accelerator)) {
gtk_widget_add_accelerator(menu_item,
"activate",
dummy_accel_group_,
- accelerator.GetGdkKeyCode(),
- accelerator.gdk_modifier_type(),
+ ui::GetGdkKeyCodeForAccelerator(accelerator),
+ ui::GetGdkModifierForAccelerator(accelerator),
GTK_ACCEL_VISIBLE);
}
diff --git a/chrome/browser/ui/gtk/panels/panel_gtk.cc b/chrome/browser/ui/gtk/panels/panel_gtk.cc
index 4b8f6ae..3de12de 100644
--- a/chrome/browser/ui/gtk/panels/panel_gtk.cc
+++ b/chrome/browser/ui/gtk/panels/panel_gtk.cc
@@ -31,7 +31,7 @@
#include "content/public/browser/web_contents.h"
#include "grit/theme_resources.h"
#include "grit/ui_resources.h"
-#include "ui/base/accelerators/accelerator_gtk.h"
+#include "ui/base/accelerators/platform_accelerator_gtk.h"
#include "ui/base/gtk/gtk_compat.h"
#include "ui/base/gtk/gtk_expanded_container.h"
#include "ui/base/gtk/gtk_hig_constants.h"
@@ -129,14 +129,15 @@ const struct AcceleratorMapping {
};
// Table of accelerator mappings to command ids.
-typedef std::map<ui::AcceleratorGtk, int> AcceleratorGtkMap;
+typedef std::map<ui::Accelerator, int> AcceleratorMap;
-const AcceleratorGtkMap& GetAcceleratorTable() {
- CR_DEFINE_STATIC_LOCAL(AcceleratorGtkMap, accelerator_table, ());
+const AcceleratorMap& GetAcceleratorTable() {
+ CR_DEFINE_STATIC_LOCAL(AcceleratorMap, accelerator_table, ());
if (accelerator_table.empty()) {
for (size_t i = 0; i < arraysize(kAcceleratorMap); ++i) {
const AcceleratorMapping& entry = kAcceleratorMap[i];
- ui::AcceleratorGtk accelerator(entry.keyval, entry.modifier_type);
+ ui::Accelerator accelerator = ui::AcceleratorForGdkKeyCodeAndModifier(
+ entry.keyval, entry.modifier_type);
accelerator_table[accelerator] = entry.command_id;
}
}
@@ -362,13 +363,13 @@ void PanelGtk::ConnectAccelerators() {
accel_group_ = gtk_accel_group_new();
gtk_window_add_accel_group(window_, accel_group_);
- const AcceleratorGtkMap& accelerator_table = GetAcceleratorTable();
- for (AcceleratorGtkMap::const_iterator iter = accelerator_table.begin();
+ const AcceleratorMap& accelerator_table = GetAcceleratorTable();
+ for (AcceleratorMap::const_iterator iter = accelerator_table.begin();
iter != accelerator_table.end(); ++iter) {
gtk_accel_group_connect(
accel_group_,
- iter->first.GetGdkKeyCode(),
- static_cast<GdkModifierType>(iter->first.modifiers()),
+ ui::GetGdkKeyCodeForAccelerator(iter->first),
+ ui::GetGdkModifierForAccelerator(iter->first),
GtkAccelFlags(0),
g_cclosure_new(G_CALLBACK(OnGtkAccelerator),
GINT_TO_POINTER(iter->second), NULL));
@@ -378,12 +379,13 @@ void PanelGtk::ConnectAccelerators() {
void PanelGtk::DisconnectAccelerators() {
// Disconnecting the keys we connected to our accelerator group frees the
// closures allocated in ConnectAccelerators.
- const AcceleratorGtkMap& accelerator_table = GetAcceleratorTable();
- for (AcceleratorGtkMap::const_iterator iter = accelerator_table.begin();
+ const AcceleratorMap& accelerator_table = GetAcceleratorTable();
+ for (AcceleratorMap::const_iterator iter = accelerator_table.begin();
iter != accelerator_table.end(); ++iter) {
- gtk_accel_group_disconnect_key(accel_group_,
- iter->first.GetGdkKeyCode(),
- static_cast<GdkModifierType>(iter->first.modifiers()));
+ gtk_accel_group_disconnect_key(
+ accel_group_,
+ ui::GetGdkKeyCodeForAccelerator(iter->first),
+ ui::GetGdkModifierForAccelerator(iter->first));
}
gtk_window_remove_accel_group(window_, accel_group_);
g_object_unref(accel_group_);
diff --git a/chrome/browser/ui/gtk/reload_button_gtk.cc b/chrome/browser/ui/gtk/reload_button_gtk.cc
index f3b6195..cb86d83 100644
--- a/chrome/browser/ui/gtk/reload_button_gtk.cc
+++ b/chrome/browser/ui/gtk/reload_button_gtk.cc
@@ -22,7 +22,6 @@
#include "content/public/browser/notification_source.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
-#include "ui/base/accelerators/accelerator_gtk.h"
#include "ui/base/l10n/l10n_util.h"
// The width of this button in GTK+ theme mode. The Stop and Refresh stock icons
@@ -199,8 +198,9 @@ bool ReloadButtonGtk::IsCommandIdVisible(int command_id) const {
return true;
}
-bool ReloadButtonGtk::GetAcceleratorForCommandId(int command_id,
- ui::Accelerator* accelerator) {
+bool ReloadButtonGtk::GetAcceleratorForCommandId(
+ int command_id,
+ ui::Accelerator* out_accelerator) {
int command = 0;
switch (command_id) {
case IDS_RELOAD_MENU_NORMAL_RELOAD_ITEM:
@@ -216,17 +216,16 @@ bool ReloadButtonGtk::GetAcceleratorForCommandId(int command_id,
LOG(ERROR) << "Unknown reload menu command";
}
- bool accelerator_set = false;
if (command) {
- const ui::AcceleratorGtk* accelerator_gtk =
+ const ui::Accelerator* accelerator =
AcceleratorsGtk::GetInstance()->
GetPrimaryAcceleratorForCommand(command);
- if (accelerator_gtk) {
- *accelerator = *accelerator_gtk;
- accelerator_set = true;
+ if (accelerator) {
+ *out_accelerator = *accelerator;
+ return true;
}
}
- return accelerator_set;
+ return false;
}
void ReloadButtonGtk::ExecuteCommand(int command_id) {
diff --git a/chrome/browser/ui/gtk/tabs/tab_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_gtk.cc
index 31e7ddc..cd13c74 100644
--- a/chrome/browser/ui/gtk/tabs/tab_gtk.cc
+++ b/chrome/browser/ui/gtk/tabs/tab_gtk.cc
@@ -19,7 +19,6 @@
#include "chrome/browser/ui/tabs/tab_resources.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
-#include "ui/base/accelerators/accelerator_gtk.h"
#include "ui/base/dragdrop/gtk_dnd_util.h"
#include "ui/base/gtk/scoped_region.h"
#include "ui/gfx/path.h"
diff --git a/chrome/browser/ui/gtk/tabs/tab_strip_menu_controller.cc b/chrome/browser/ui/gtk/tabs/tab_strip_menu_controller.cc
index 6788465..7de90e5 100644
--- a/chrome/browser/ui/gtk/tabs/tab_strip_menu_controller.cc
+++ b/chrome/browser/ui/gtk/tabs/tab_strip_menu_controller.cc
@@ -41,17 +41,18 @@ bool TabStripMenuController::IsCommandIdEnabled(int command_id) const {
bool TabStripMenuController::GetAcceleratorForCommandId(
int command_id,
- ui::Accelerator* accelerator) {
+ ui::Accelerator* out_accelerator) {
int browser_command;
if (!TabStripModel::ContextMenuCommandToBrowserCommand(command_id,
&browser_command))
return false;
- const ui::AcceleratorGtk* accelerator_gtk =
+ const ui::Accelerator* accelerator =
AcceleratorsGtk::GetInstance()->GetPrimaryAcceleratorForCommand(
browser_command);
- if (accelerator_gtk)
- *accelerator = *accelerator_gtk;
- return !!accelerator_gtk;
+ if (!accelerator)
+ return false;
+ *out_accelerator = *accelerator;
+ return true;
}
void TabStripMenuController::ExecuteCommand(int command_id) {