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

Side by Side Diff: chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegate.mm

Issue 1411203010: Separate RenderViewHost from RenderWidgetHost, part 4: delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oops 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 unified diff | Download patch
OLDNEW
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"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 }; 67 };
68 68
69 } // namespace ChromeRenderWidgetHostViewMacDelegateInternal 69 } // namespace ChromeRenderWidgetHostViewMacDelegateInternal
70 70
71 @implementation ChromeRenderWidgetHostViewMacDelegate 71 @implementation ChromeRenderWidgetHostViewMacDelegate
72 72
73 - (id)initWithRenderWidgetHost:(content::RenderWidgetHost*)renderWidgetHost { 73 - (id)initWithRenderWidgetHost:(content::RenderWidgetHost*)renderWidgetHost {
74 self = [super init]; 74 self = [super init];
75 if (self) { 75 if (self) {
76 renderWidgetHost_ = renderWidgetHost; 76 renderWidgetHost_ = renderWidgetHost;
77 if (renderWidgetHost_->IsRenderView()) { 77 RenderViewHost* rvh = RenderViewHost::From(renderWidgetHost_);
78 if (rvh) {
78 spellingObserver_.reset( 79 spellingObserver_.reset(
79 new ChromeRenderWidgetHostViewMacDelegateInternal::SpellCheckObserver( 80 new ChromeRenderWidgetHostViewMacDelegateInternal::SpellCheckObserver(
80 RenderViewHost::From(renderWidgetHost_), self)); 81 rvh, self));
81 } 82 }
82 83
83 historySwiper_.reset([[HistorySwiper alloc] initWithDelegate:self]); 84 historySwiper_.reset([[HistorySwiper alloc] initWithDelegate:self]);
84 } 85 }
85 return self; 86 return self;
86 } 87 }
87 88
88 - (void)dealloc { 89 - (void)dealloc {
89 [historySwiper_ setDelegate:nil]; 90 [historySwiper_ setDelegate:nil];
90 [super dealloc]; 91 [super dealloc];
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return [historySwiper_ canRubberbandLeft:view]; 131 return [historySwiper_ canRubberbandLeft:view];
131 } 132 }
132 133
133 - (BOOL)canRubberbandRight:(NSView*)view { 134 - (BOOL)canRubberbandRight:(NSView*)view {
134 return [historySwiper_ canRubberbandRight:view]; 135 return [historySwiper_ canRubberbandRight:view];
135 } 136 }
136 137
137 // HistorySwiperDelegate methods 138 // HistorySwiperDelegate methods
138 139
139 - (BOOL)shouldAllowHistorySwiping { 140 - (BOOL)shouldAllowHistorySwiping {
140 if (!renderWidgetHost_ || !renderWidgetHost_->IsRenderView()) 141 if (!renderWidgetHost_)
141 return NO; 142 return NO;
142 content::WebContents* webContents = content::WebContents::FromRenderViewHost( 143 RenderViewHost* renderViewHost = RenderViewHost::From(renderWidgetHost_);
143 RenderViewHost::From(renderWidgetHost_)); 144 if (!renderViewHost)
145 return NO;
146 content::WebContents* webContents =
147 content::WebContents::FromRenderViewHost(renderViewHost);
144 if (webContents && DevToolsWindow::IsDevToolsWindow(webContents)) { 148 if (webContents && DevToolsWindow::IsDevToolsWindow(webContents)) {
145 return NO; 149 return NO;
146 } 150 }
147 151
148 return YES; 152 return YES;
149 } 153 }
150 154
151 - (NSView*)viewThatWantsHistoryOverlay { 155 - (NSView*)viewThatWantsHistoryOverlay {
152 return renderWidgetHost_->GetView()->GetNativeView(); 156 return renderWidgetHost_->GetView()->GetNativeView();
153 } 157 }
154 158
155 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item 159 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item
156 isValidItem:(BOOL*)valid { 160 isValidItem:(BOOL*)valid {
157 SEL action = [item action]; 161 SEL action = [item action];
158 162
159 // For now, this action is always enabled for render view; 163 // For now, this action is always enabled for render view;
160 // this is sub-optimal. 164 // this is sub-optimal.
161 // TODO(suzhe): Plumb the "can*" methods up from WebCore. 165 // TODO(suzhe): Plumb the "can*" methods up from WebCore.
162 if (action == @selector(checkSpelling:)) { 166 if (action == @selector(checkSpelling:)) {
163 *valid = renderWidgetHost_->IsRenderView(); 167 *valid = RenderViewHost::From(renderWidgetHost_) != nullptr;
164 return YES; 168 return YES;
165 } 169 }
166 170
167 // TODO(groby): Clarify who sends this and if toggleContinuousSpellChecking: 171 // TODO(groby): Clarify who sends this and if toggleContinuousSpellChecking:
168 // is still necessary. 172 // is still necessary.
169 if (action == @selector(toggleContinuousSpellChecking:)) { 173 if (action == @selector(toggleContinuousSpellChecking:)) {
170 if ([(id)item respondsToSelector:@selector(setState:)]) { 174 if ([(id)item respondsToSelector:@selector(setState:)]) {
171 content::RenderProcessHost* host = renderWidgetHost_->GetProcess(); 175 content::RenderProcessHost* host = renderWidgetHost_->GetProcess();
172 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); 176 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
173 DCHECK(profile); 177 DCHECK(profile);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 250 }
247 251
248 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { 252 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked {
249 spellcheckEnabled_ = enabled; 253 spellcheckEnabled_ = enabled;
250 spellcheckChecked_ = checked; 254 spellcheckChecked_ = checked;
251 } 255 }
252 256
253 // END Spellchecking methods 257 // END Spellchecking methods
254 258
255 @end 259 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698