Index: ui/base/cocoa/defaults_utils.mm |
diff --git a/ui/base/cocoa/defaults_utils.mm b/ui/base/cocoa/defaults_utils.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..47486a404c0b97574619a661592847ffb8e7f703 |
--- /dev/null |
+++ b/ui/base/cocoa/defaults_utils.mm |
@@ -0,0 +1,32 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include <AppKit/AppKit.h> |
+ |
+#include "base/logging.h" |
+#include "ui/base/cocoa/defaults_utils.h" |
+ |
+namespace ui { |
+ |
+bool TextInsertionCaretBlinkPeriod(base::TimeDelta* delta) { |
+ const int kMaximumReasonableIntervalMs = 60 * 1000; |
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; |
+ double on_period_ms = [defaults |
+ floatForKey:@"NSTextInsertionPointBlinkPeriodOn"]; |
+ double off_period_ms = [defaults |
+ floatForKey:@"NSTextInsertionPointBlinkPeriodOff"]; |
Nico
2016/08/25 19:40:37
apparently it's NSTextInsertionPointBlinkPeriod in
Elly Fong-Jones
2016/08/25 19:57:33
Done.
|
+ if (on_period_ms == 0.0 && off_period_ms == 0.0) |
+ return false; |
+ // Neither Blink nor Views support having separate on and off intervals, so |
+ // this function takes the average. |
+ if (on_period_ms > kMaximumReasonableIntervalMs) { |
Nico
2016/08/25 19:40:37
why check this for on_period_ms but not off_period
Elly Fong-Jones
2016/08/25 19:57:33
Added explanation
|
+ *delta = base::TimeDelta(); |
+ } else { |
+ *delta = base::TimeDelta::FromMillisecondsD( |
+ (on_period_ms + off_period_ms) / 2); |
+ } |
+ return true; |
+} |
+ |
+} // namespace ui |