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 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
11 #include "chrome/browser/devtools/devtools_window.h" | 11 #include "chrome/browser/devtools/devtools_window.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #import "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history
_swiper.h" | 13 #import "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history
_swiper.h" |
14 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" | 14 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" |
15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
17 #include "chrome/browser/ui/browser_finder.h" | 17 #include "chrome/browser/ui/browser_finder.h" |
18 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 18 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
19 #import "chrome/browser/ui/cocoa/view_id_util.h" | |
20 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
21 #include "chrome/common/spellcheck_messages.h" | 20 #include "chrome/common/spellcheck_messages.h" |
22 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
23 #include "content/public/browser/render_process_host.h" | 22 #include "content/public/browser/render_process_host.h" |
24 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
25 #include "content/public/browser/render_widget_host.h" | 24 #include "content/public/browser/render_widget_host.h" |
26 #include "content/public/browser/render_widget_host_view.h" | 25 #include "content/public/browser/render_widget_host_view.h" |
27 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
28 #include "content/public/browser/web_contents_observer.h" | 27 #include "content/public/browser/web_contents_observer.h" |
29 | 28 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 }; | 68 }; |
70 | 69 |
71 } // namespace ChromeRenderWidgetHostViewMacDelegateInternal | 70 } // namespace ChromeRenderWidgetHostViewMacDelegateInternal |
72 | 71 |
73 @implementation ChromeRenderWidgetHostViewMacDelegate | 72 @implementation ChromeRenderWidgetHostViewMacDelegate |
74 | 73 |
75 - (id)initWithRenderWidgetHost:(content::RenderWidgetHost*)renderWidgetHost { | 74 - (id)initWithRenderWidgetHost:(content::RenderWidgetHost*)renderWidgetHost { |
76 self = [super init]; | 75 self = [super init]; |
77 if (self) { | 76 if (self) { |
78 renderWidgetHost_ = renderWidgetHost; | 77 renderWidgetHost_ = renderWidgetHost; |
79 // if |renderWidgetHost_| belongs to a BrowserPluginGuest, then it won't | |
80 // have a view yet. | |
81 if (renderWidgetHost_->GetView()) { | |
82 NSView* nativeView = renderWidgetHost_->GetView()->GetNativeView(); | |
83 view_id_util::SetID(nativeView, VIEW_ID_TAB_CONTAINER); | |
84 } | |
85 | |
86 if (renderWidgetHost_->IsRenderView()) { | 78 if (renderWidgetHost_->IsRenderView()) { |
87 spellingObserver_.reset( | 79 spellingObserver_.reset( |
88 new ChromeRenderWidgetHostViewMacDelegateInternal::SpellCheckObserver( | 80 new ChromeRenderWidgetHostViewMacDelegateInternal::SpellCheckObserver( |
89 RenderViewHost::From(renderWidgetHost_), self)); | 81 RenderViewHost::From(renderWidgetHost_), self)); |
90 } | 82 } |
91 | 83 |
92 historySwiper_.reset([[HistorySwiper alloc] initWithDelegate:self]); | 84 historySwiper_.reset([[HistorySwiper alloc] initWithDelegate:self]); |
93 } | 85 } |
94 return self; | 86 return self; |
95 } | 87 } |
96 | 88 |
97 - (void)dealloc { | 89 - (void)dealloc { |
98 [historySwiper_ setDelegate:nil]; | 90 [historySwiper_ setDelegate:nil]; |
99 [super dealloc]; | 91 [super dealloc]; |
100 } | 92 } |
101 | 93 |
102 - (void)viewGone:(NSView*)view { | |
103 view_id_util::UnsetID(view); | |
104 } | |
105 | |
106 // Handle an event. All incoming key and mouse events flow through this | 94 // Handle an event. All incoming key and mouse events flow through this |
107 // delegate method if implemented. Return YES if the event is fully handled, or | 95 // delegate method if implemented. Return YES if the event is fully handled, or |
108 // NO if normal processing should take place. | 96 // NO if normal processing should take place. |
109 - (BOOL)handleEvent:(NSEvent*)event { | 97 - (BOOL)handleEvent:(NSEvent*)event { |
110 return [historySwiper_ handleEvent:event]; | 98 return [historySwiper_ handleEvent:event]; |
111 } | 99 } |
112 | 100 |
113 // NSWindow events. | 101 // NSWindow events. |
114 | 102 |
115 - (void)beginGestureWithEvent:(NSEvent*)event { | 103 - (void)beginGestureWithEvent:(NSEvent*)event { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 } | 247 } |
260 | 248 |
261 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { | 249 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { |
262 spellcheckEnabled_ = enabled; | 250 spellcheckEnabled_ = enabled; |
263 spellcheckChecked_ = checked; | 251 spellcheckChecked_ = checked; |
264 } | 252 } |
265 | 253 |
266 // END Spellchecking methods | 254 // END Spellchecking methods |
267 | 255 |
268 @end | 256 @end |
OLD | NEW |