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

Unified Diff: base/mac/mac_util.mm

Issue 1458203003: MacKeyboard: Don't generate keypress for non-printable char (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
Index: base/mac/mac_util.mm
diff --git a/base/mac/mac_util.mm b/base/mac/mac_util.mm
index 647faf3866f0d52d982e532e8cd2568ef12efce5..ccb694878ba8693a0abaf853899f72f55531d8e4 100644
--- a/base/mac/mac_util.mm
+++ b/base/mac/mac_util.mm
@@ -402,6 +402,24 @@ bool RemoveQuarantineAttribute(const FilePath& file_path) {
return status == 0 || errno == ENOATTR;
}
+bool CharacterIsPrintable(unichar c) {
+ switch (c) {
+ case 0xf728: // Delete
+ return false;
+ }
+ return true;
+}
+
+bool StringIsPrintable(NSString* s) {
+ if (s.length == 0)
+ return true;
+ for (NSUInteger i = 0; i < s.length; ++i) {
+ if (CharacterIsPrintable([s characterAtIndex:i]))
+ return true;
+ }
+ return false;
+}
+
namespace {
// Returns the running system's Darwin major version. Don't call this, it's

Powered by Google App Engine
This is Rietveld 408576698