| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "chrome/browser/debugger/devtools_window.h" | 10 #include "chrome/browser/debugger/devtools_window.h" |
| 11 #include "chrome/browser/spellchecker/spellchecker_platform_engine.h" | 11 #include "chrome/browser/spellchecker/spellchecker_platform_engine.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
| 14 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" | 14 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" |
| 15 #import "chrome/browser/ui/cocoa/view_id_util.h" | 15 #import "chrome/browser/ui/cocoa/view_id_util.h" |
| 16 #include "chrome/common/spellcheck_messages.h" | 16 #include "chrome/common/spellcheck_messages.h" |
| 17 #include "content/browser/mac/closure_blocks_leopard_compat.h" | 17 #include "content/browser/mac/closure_blocks_leopard_compat.h" |
| 18 #include "content/browser/renderer_host/render_view_host.h" | 18 #include "content/browser/renderer_host/render_view_host.h" |
| 19 #include "content/browser/renderer_host/render_view_host_observer.h" | |
| 20 #include "content/browser/renderer_host/render_widget_host.h" | 19 #include "content/browser/renderer_host/render_widget_host.h" |
| 21 #include "content/browser/renderer_host/render_widget_host_view.h" | 20 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 21 #include "content/public/browser/render_view_host_observer.h" |
| 22 | 22 |
| 23 // Declare things that are part of the 10.7 SDK. | 23 // Declare things that are part of the 10.7 SDK. |
| 24 #if !defined(MAC_OS_X_VERSION_10_7) || \ | 24 #if !defined(MAC_OS_X_VERSION_10_7) || \ |
| 25 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 | 25 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 |
| 26 enum { | 26 enum { |
| 27 NSEventPhaseNone = 0, // event not associated with a phase. | 27 NSEventPhaseNone = 0, // event not associated with a phase. |
| 28 NSEventPhaseBegan = 0x1 << 0, | 28 NSEventPhaseBegan = 0x1 << 0, |
| 29 NSEventPhaseStationary = 0x1 << 1, | 29 NSEventPhaseStationary = 0x1 << 1, |
| 30 NSEventPhaseChanged = 0x1 << 2, | 30 NSEventPhaseChanged = 0x1 << 2, |
| 31 NSEventPhaseEnded = 0x1 << 3, | 31 NSEventPhaseEnded = 0x1 << 3, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 57 | 57 |
| 58 @interface ChromeRenderWidgetHostViewMacDelegate () | 58 @interface ChromeRenderWidgetHostViewMacDelegate () |
| 59 - (BOOL)maybeHandleHistorySwiping:(NSEvent*)theEvent; | 59 - (BOOL)maybeHandleHistorySwiping:(NSEvent*)theEvent; |
| 60 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked; | 60 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked; |
| 61 @end | 61 @end |
| 62 | 62 |
| 63 namespace ChromeRenderWidgetHostViewMacDelegateInternal { | 63 namespace ChromeRenderWidgetHostViewMacDelegateInternal { |
| 64 | 64 |
| 65 // Filters the message sent to RenderViewHost to know if spellchecking is | 65 // Filters the message sent to RenderViewHost to know if spellchecking is |
| 66 // enabled or not for the currently focused element. | 66 // enabled or not for the currently focused element. |
| 67 class SpellCheckRenderViewObserver : public RenderViewHostObserver { | 67 class SpellCheckRenderViewObserver : public content::RenderViewHostObserver { |
| 68 public: | 68 public: |
| 69 SpellCheckRenderViewObserver( | 69 SpellCheckRenderViewObserver( |
| 70 RenderViewHost* host, | 70 RenderViewHost* host, |
| 71 ChromeRenderWidgetHostViewMacDelegate* view_delegate) | 71 ChromeRenderWidgetHostViewMacDelegate* view_delegate) |
| 72 : RenderViewHostObserver(host), | 72 : content::RenderViewHostObserver(host), |
| 73 view_delegate_(view_delegate) { | 73 view_delegate_(view_delegate) { |
| 74 } | 74 } |
| 75 | 75 |
| 76 virtual ~SpellCheckRenderViewObserver() { | 76 virtual ~SpellCheckRenderViewObserver() { |
| 77 } | 77 } |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 // RenderViewHostObserver implementation. | 80 // content::RenderViewHostObserver implementation. |
| 81 virtual void RenderViewHostDestroyed(RenderViewHost* rvh) OVERRIDE { | 81 virtual void RenderViewHostDestroyed(RenderViewHost* rvh) OVERRIDE { |
| 82 // The parent implementation destroys the observer, scoping the lifetime of | 82 // The parent implementation destroys the observer, scoping the lifetime of |
| 83 // the observer to the RenderViewHost. Since this class is acting as a | 83 // the observer to the RenderViewHost. Since this class is acting as a |
| 84 // bridge to the view for the delegate below, and is owned by that delegate, | 84 // bridge to the view for the delegate below, and is owned by that delegate, |
| 85 // undo the scoping by not calling through to the parent implementation. | 85 // undo the scoping by not calling through to the parent implementation. |
| 86 } | 86 } |
| 87 | 87 |
| 88 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { | 88 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { |
| 89 bool handled = true; | 89 bool handled = true; |
| 90 IPC_BEGIN_MESSAGE_MAP(SpellCheckRenderViewObserver, message) | 90 IPC_BEGIN_MESSAGE_MAP(SpellCheckRenderViewObserver, message) |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 328 } |
| 329 | 329 |
| 330 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { | 330 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { |
| 331 spellcheck_enabled_ = enabled; | 331 spellcheck_enabled_ = enabled; |
| 332 spellcheck_checked_ = checked; | 332 spellcheck_checked_ = checked; |
| 333 } | 333 } |
| 334 | 334 |
| 335 // END Spellchecking methods | 335 // END Spellchecking methods |
| 336 | 336 |
| 337 @end | 337 @end |
| OLD | NEW |