summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshrike <shrike@chromium.org>2015-10-26 11:53:08 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-26 18:54:08 +0000
commit20c59e0632ec7a6e1c688e184226a7dbe0ca4e59 (patch)
tree010d3bcb3106b9c510002e8c4fcf228a3e6bbef9
parent1abe59c0d39d5966c2d008177fdb4ad8282af4df (diff)
downloadchromium_src-20c59e0632ec7a6e1c688e184226a7dbe0ca4e59.zip
chromium_src-20c59e0632ec7a6e1c688e184226a7dbe0ca4e59.tar.gz
chromium_src-20c59e0632ec7a6e1c688e184226a7dbe0ca4e59.tar.bz2
Disable Force Touch lookup in the Omnibox.
Force Touch in the Omnibox can, under the right conditions, crash the browser. Force Touch isn't desirable anyway in the Omnibox, so this change disables it. BUG=544250 Review URL: https://codereview.chromium.org/1426463002 Cr-Commit-Position: refs/heads/master@{#356086}
-rw-r--r--base/mac/sdk_forward_declarations.h21
-rw-r--r--chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm16
2 files changed, 37 insertions, 0 deletions
diff --git a/base/mac/sdk_forward_declarations.h b/base/mac/sdk_forward_declarations.h
index bee324a..a6bf588 100644
--- a/base/mac/sdk_forward_declarations.h
+++ b/base/mac/sdk_forward_declarations.h
@@ -496,6 +496,27 @@ BASE_EXPORT extern NSString* const NSAppearanceNameVibrantDark;
- (void)viewDidLoad;
@end
+enum {
+ NSPressureBehaviorUnknown = -1,
+ NSPressureBehaviorPrimaryDefault = 0,
+ NSPressureBehaviorPrimaryClick = 1,
+ NSPressureBehaviorPrimaryGeneric = 2,
+ NSPressureBehaviorPrimaryAccelerator = 3,
+ NSPressureBehaviorPrimaryDeepClick = 5,
+ NSPressureBehaviorPrimaryDeepDrag = 6
+};
+typedef NSInteger NSPressureBehavior;
+
+@interface NSPressureConfiguration : NSObject
+- (instancetype)initWithPressureBehavior:(NSPressureBehavior)pressureBehavior;
+@end
+
+@class NSPressureConfiguration;
+
+@interface NSView (YosemiteSDK)
+- (void)setPressureConfiguration:(NSPressureConfiguration*)aConfiguration;
+@end
+
#endif // MAC_OS_X_VERSION_10_10
// ----------------------------------------------------------------------------
diff --git a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm
index 56532c0..7f2938c 100644
--- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm
+++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm
@@ -5,6 +5,8 @@
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h"
#include "base/logging.h"
+#import "base/mac/mac_util.h"
+#import "base/mac/sdk_forward_declarations.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h"
@@ -39,6 +41,20 @@ const CGFloat kAnimationDuration = 0.2;
resizeAnimation_.reset([[NSViewAnimation alloc] init]);
[resizeAnimation_ setDuration:kAnimationDuration];
[resizeAnimation_ setAnimationBlockingMode:NSAnimationNonblocking];
+
+ // Disable Force Touch in the Omnibox. Note that this API is defined in
+ // 10.10.3 and higher so have to check more than just isYosmiteOrLater().
+ // Also, because NSPressureConfiguration is not in the original 10.10 SDK,
+ // use NSClassFromString() to instantiate it (otherwise there's a
+ // linker error).
+ if (base::mac::IsOSYosemiteOrLater() &&
+ [self respondsToSelector:@selector(setPressureConfiguration:)]) {
+ NSPressureConfiguration* pressureConfiguration =
+ [[[NSClassFromString(@"NSPressureConfiguration") alloc]
+ initWithPressureBehavior:NSPressureBehaviorPrimaryClick]
+ autorelease];
+ [self setPressureConfiguration:pressureConfiguration];
+ }
}
- (void)flagsChanged:(NSEvent*)theEvent {