OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegat
e.h" | 5 #import "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegat
e.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
| 9 #import "base/mac/sdk_forward_declarations.h" |
9 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
10 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
11 #include "chrome/browser/devtools/devtools_window.h" | 12 #include "chrome/browser/devtools/devtools_window.h" |
12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" | 14 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" |
14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
16 #include "chrome/browser/ui/browser_finder.h" | 17 #include "chrome/browser/ui/browser_finder.h" |
17 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 18 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
18 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" | 19 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" |
19 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" | 20 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" |
20 #import "chrome/browser/ui/cocoa/view_id_util.h" | 21 #import "chrome/browser/ui/cocoa/view_id_util.h" |
21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
22 #include "chrome/common/spellcheck_messages.h" | 23 #include "chrome/common/spellcheck_messages.h" |
23 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
24 #include "content/public/browser/render_process_host.h" | 25 #include "content/public/browser/render_process_host.h" |
25 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
26 #include "content/public/browser/render_view_host_observer.h" | 27 #include "content/public/browser/render_view_host_observer.h" |
27 #include "content/public/browser/render_widget_host.h" | 28 #include "content/public/browser/render_widget_host.h" |
28 #include "content/public/browser/render_widget_host_view.h" | 29 #include "content/public/browser/render_widget_host_view.h" |
29 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
30 | 31 |
31 using content::RenderViewHost; | 32 using content::RenderViewHost; |
32 | 33 |
33 // Declare things that are part of the 10.7 SDK. | |
34 #if !defined(MAC_OS_X_VERSION_10_7) || \ | |
35 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 | |
36 enum { | |
37 NSEventPhaseNone = 0, // event not associated with a phase. | |
38 NSEventPhaseBegan = 0x1 << 0, | |
39 NSEventPhaseStationary = 0x1 << 1, | |
40 NSEventPhaseChanged = 0x1 << 2, | |
41 NSEventPhaseEnded = 0x1 << 3, | |
42 NSEventPhaseCancelled = 0x1 << 4, | |
43 }; | |
44 typedef NSUInteger NSEventPhase; | |
45 | |
46 enum { | |
47 NSEventSwipeTrackingLockDirection = 0x1 << 0, | |
48 NSEventSwipeTrackingClampGestureAmount = 0x1 << 1 | |
49 }; | |
50 typedef NSUInteger NSEventSwipeTrackingOptions; | |
51 | |
52 @interface NSEvent (LionAPI) | |
53 + (BOOL)isSwipeTrackingFromScrollEventsEnabled; | |
54 | |
55 - (NSEventPhase)phase; | |
56 - (CGFloat)scrollingDeltaX; | |
57 - (CGFloat)scrollingDeltaY; | |
58 - (void)trackSwipeEventWithOptions:(NSEventSwipeTrackingOptions)options | |
59 dampenAmountThresholdMin:(CGFloat)minDampenThreshold | |
60 max:(CGFloat)maxDampenThreshold | |
61 usingHandler:(void (^)(CGFloat gestureAmount, | |
62 NSEventPhase phase, | |
63 BOOL isComplete, | |
64 BOOL *stop))trackingHandler; | |
65 @end | |
66 #endif // 10.7 | |
67 | |
68 @interface ChromeRenderWidgetHostViewMacDelegate () | 34 @interface ChromeRenderWidgetHostViewMacDelegate () |
69 - (BOOL)maybeHandleHistorySwiping:(NSEvent*)theEvent; | 35 - (BOOL)maybeHandleHistorySwiping:(NSEvent*)theEvent; |
70 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked; | 36 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked; |
71 @end | 37 @end |
72 | 38 |
73 namespace ChromeRenderWidgetHostViewMacDelegateInternal { | 39 namespace ChromeRenderWidgetHostViewMacDelegateInternal { |
74 | 40 |
75 // Filters the message sent to RenderViewHost to know if spellchecking is | 41 // Filters the message sent to RenderViewHost to know if spellchecking is |
76 // enabled or not for the currently focused element. | 42 // enabled or not for the currently focused element. |
77 class SpellCheckRenderViewObserver : public content::RenderViewHostObserver { | 43 class SpellCheckRenderViewObserver : public content::RenderViewHostObserver { |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 } | 342 } |
377 | 343 |
378 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { | 344 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { |
379 spellcheckEnabled_ = enabled; | 345 spellcheckEnabled_ = enabled; |
380 spellcheckChecked_ = checked; | 346 spellcheckChecked_ = checked; |
381 } | 347 } |
382 | 348 |
383 // END Spellchecking methods | 349 // END Spellchecking methods |
384 | 350 |
385 @end | 351 @end |
OLD | NEW |