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

Unified Diff: chrome/browser/cocoa/browser_window_controller.mm

Issue 2779011: Make the reload button respond to middle-clicks like back/forward/home alread... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/compact_location_bar_view.cc ('k') | chrome/browser/crash_recovery_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/browser_window_controller.mm
===================================================================
--- chrome/browser/cocoa/browser_window_controller.mm (revision 49315)
+++ chrome/browser/cocoa/browser_window_controller.mm (working copy)
@@ -918,25 +918,8 @@
if ([sender respondsToSelector:@selector(window)])
targetController = [[sender window] windowController];
DCHECK([targetController isKindOfClass:[BrowserWindowController class]]);
- NSInteger tag = [sender tag];
- switch (tag) {
- case IDC_RELOAD:
- if ([sender isKindOfClass:[NSButton class]]) {
- // We revert the bar when the reload button is pressed, but don't when
- // Command+r is pressed (Issue 15464). Unlike the event handler function
- // for Windows (ToolbarView::ButtonPressed()), this function handles
- // both reload button press event and Command+r press event. Thus the
- // 'isKindofClass' check is necessary.
- [targetController locationBarBridge]->Revert();
- }
- NSUInteger modifierFlags = [[NSApp currentEvent] modifierFlags];
- if (modifierFlags & NSShiftKeyMask) {
- tag = IDC_RELOAD_IGNORING_CACHE;
- }
- break;
- }
DCHECK(targetController->browser_.get());
- targetController->browser_->ExecuteCommand(tag);
+ targetController->browser_->ExecuteCommand([sender tag]);
}
// Same as |-commandDispatch:|, but executes commands using a disposition
@@ -949,17 +932,37 @@
if ([sender respondsToSelector:@selector(window)])
targetController = [[sender window] windowController];
DCHECK([targetController isKindOfClass:[BrowserWindowController class]]);
- NSInteger tag = [sender tag];
- DCHECK(targetController->browser_.get());
+ NSInteger command = [sender tag];
NSUInteger modifierFlags = [[NSApp currentEvent] modifierFlags];
+ if ((command == IDC_RELOAD) && (modifierFlags & NSShiftKeyMask)) {
+ command = IDC_RELOAD_IGNORING_CACHE;
+ // Mask off shift so it isn't interpreted as affecting the disposition
+ // below.
+ modifierFlags &= ~NSShiftKeyMask;
+ }
if (![[sender window] isMainWindow]) {
// Remove the command key from the flags, it means "keep the window in
// the background" in this case.
modifierFlags &= ~NSCommandKeyMask;
}
- targetController->browser_->ExecuteCommandWithDisposition(tag,
+ WindowOpenDisposition disposition =
event_utils::WindowOpenDispositionFromNSEventWithFlags(
- [NSApp currentEvent], modifierFlags));
+ [NSApp currentEvent], modifierFlags);
+ switch (command) {
+ case IDC_BACK:
+ case IDC_FORWARD:
+ case IDC_RELOAD:
+ case IDC_RELOAD_IGNORING_CACHE:
+ if (disposition == CURRENT_TAB) {
+ // Forcibly reset the location bar, since otherwise it won't discard any
+ // ongoing user edits, since it doesn't realize this is a user-initiated
+ // action.
+ [targetController locationBarBridge]->Revert();
+ }
+ }
+ DCHECK(targetController->browser_.get());
+ targetController->browser_->ExecuteCommandWithDisposition(command,
+ disposition);
}
// Called when another part of the internal codebase needs to execute a
« no previous file with comments | « chrome/browser/chromeos/compact_location_bar_view.cc ('k') | chrome/browser/crash_recovery_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698