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

Side by Side Diff: content/browser/web_contents/web_contents_view_mac.mm

Issue 659233002: STASH: Epic Experimental patch for toolkit-views App List on Mac Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Fix a few things. Works@master Created 6 years, 2 months 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 <Carbon/Carbon.h> 5 #import <Carbon/Carbon.h>
6 6
7 #import "content/browser/web_contents/web_contents_view_mac.h" 7 #import "content/browser/web_contents/web_contents_view_mac.h"
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 152 }
153 153
154 void WebContentsViewMac::SizeContents(const gfx::Size& size) { 154 void WebContentsViewMac::SizeContents(const gfx::Size& size) {
155 // TODO(brettw | japhet) This is a hack and should be removed. 155 // TODO(brettw | japhet) This is a hack and should be removed.
156 // See web_contents_view.h. 156 // See web_contents_view.h.
157 // Note(erikchen): This method has /never/ worked correctly. I've removed the 157 // Note(erikchen): This method has /never/ worked correctly. I've removed the
158 // previous implementation. 158 // previous implementation.
159 } 159 }
160 160
161 void WebContentsViewMac::Focus() { 161 void WebContentsViewMac::Focus() {
162 if (delegate_ && delegate_->Focus())
163 return;
164
162 NSWindow* window = [cocoa_view_.get() window]; 165 NSWindow* window = [cocoa_view_.get() window];
163 [window makeFirstResponder:GetContentNativeView()]; 166 [window makeFirstResponder:GetContentNativeView()];
164 if (![window isVisible]) 167 if (![window isVisible])
165 return; 168 return;
166 [window makeKeyAndOrderFront:nil]; 169 [window makeKeyAndOrderFront:nil];
167 } 170 }
168 171
169 void WebContentsViewMac::SetInitialFocus() { 172 void WebContentsViewMac::SetInitialFocus() {
170 if (web_contents_->FocusLocationBarByDefault()) 173 if (web_contents_->FocusLocationBarByDefault())
171 web_contents_->SetFocusToLocationBar(false); 174 web_contents_->SetFocusToLocationBar(false);
172 else 175 else
173 [[cocoa_view_.get() window] makeFirstResponder:GetContentNativeView()]; 176 [[cocoa_view_.get() window] makeFirstResponder:GetContentNativeView()];
174 } 177 }
175 178
176 void WebContentsViewMac::StoreFocus() { 179 void WebContentsViewMac::StoreFocus() {
177 // We're explicitly being asked to store focus, so don't worry if there's 180 // We're explicitly being asked to store focus, so don't worry if there's
178 // already a view saved. 181 // already a view saved.
182 focus_tracker_.reset();
183 if (delegate_ && delegate_->StoreFocus())
184 return;
185
179 focus_tracker_.reset( 186 focus_tracker_.reset(
180 [[FocusTracker alloc] initWithWindow:[cocoa_view_ window]]); 187 [[FocusTracker alloc] initWithWindow:[cocoa_view_ window]]);
181 } 188 }
182 189
183 void WebContentsViewMac::RestoreFocus() { 190 void WebContentsViewMac::RestoreFocus() {
184 // TODO(avi): Could we be restoring a view that's no longer in the key view 191 // TODO(avi): Could we be restoring a view that's no longer in the key view
185 // chain? 192 // chain?
193 if (delegate_ && delegate_->RestoreFocus())
194 return;
195
186 if (!(focus_tracker_.get() && 196 if (!(focus_tracker_.get() &&
187 [focus_tracker_ restoreFocusInWindow:[cocoa_view_ window]])) { 197 [focus_tracker_ restoreFocusInWindow:[cocoa_view_ window]])) {
188 // Fall back to the default focus behavior if we could not restore focus. 198 // Fall back to the default focus behavior if we could not restore focus.
189 // TODO(shess): If location-bar gets focus by default, this will 199 // TODO(shess): If location-bar gets focus by default, this will
190 // select-all in the field. If there was a specific selection in 200 // select-all in the field. If there was a specific selection in
191 // the field when we navigated away from it, we should restore 201 // the field when we navigated away from it, we should restore
192 // that selection. 202 // that selection.
193 SetInitialFocus(); 203 SetInitialFocus();
194 } 204 }
195 205
196 focus_tracker_.reset(nil); 206 focus_tracker_.reset(nil);
197 } 207 }
198 208
199 DropData* WebContentsViewMac::GetDropData() const { 209 DropData* WebContentsViewMac::GetDropData() const {
200 return [cocoa_view_ dropData]; 210 return [cocoa_view_ dropData];
201 } 211 }
202 212
203 void WebContentsViewMac::UpdateDragCursor(WebDragOperation operation) { 213 void WebContentsViewMac::UpdateDragCursor(WebDragOperation operation) {
204 [cocoa_view_ setCurrentDragOperation: operation]; 214 [cocoa_view_ setCurrentDragOperation: operation];
205 } 215 }
206 216
207 void WebContentsViewMac::GotFocus() { 217 void WebContentsViewMac::GotFocus() {
208 // This is only used in the views FocusManager stuff but it bleeds through 218 // This is only used in the views FocusManager stuff but it bleeds through
209 // all subclasses. http://crbug.com/21875 219 // all subclasses. http://crbug.com/21875
210 } 220 }
211 221
212 // This is called when the renderer asks us to take focus back (i.e., it has 222 // This is called when the renderer asks us to take focus back (i.e., it has
213 // iterated past the last focusable element on the page). 223 // iterated past the last focusable element on the page).
214 void WebContentsViewMac::TakeFocus(bool reverse) { 224 void WebContentsViewMac::TakeFocus(bool reverse) {
225 if (delegate_ && delegate_->TakeFocus(reverse))
226 return;
227
215 if (reverse) { 228 if (reverse) {
216 [[cocoa_view_ window] selectPreviousKeyView:cocoa_view_.get()]; 229 [[cocoa_view_ window] selectPreviousKeyView:cocoa_view_.get()];
217 } else { 230 } else {
218 [[cocoa_view_ window] selectNextKeyView:cocoa_view_.get()]; 231 [[cocoa_view_ window] selectNextKeyView:cocoa_view_.get()];
219 } 232 }
220 } 233 }
221 234
222 void WebContentsViewMac::ShowContextMenu( 235 void WebContentsViewMac::ShowContextMenu(
223 RenderFrameHost* render_frame_host, 236 RenderFrameHost* render_frame_host,
224 const ContextMenuParams& params) { 237 const ContextMenuParams& params) {
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 // When the subviews require a layout, their size should be reset to the size 590 // When the subviews require a layout, their size should be reset to the size
578 // of this view. (It is possible for the size to get out of sync as an 591 // of this view. (It is possible for the size to get out of sync as an
579 // optimization in preparation for an upcoming WebContentsView resize. 592 // optimization in preparation for an upcoming WebContentsView resize.
580 // http://crbug.com/264207) 593 // http://crbug.com/264207)
581 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { 594 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize {
582 for (NSView* subview in self.subviews) 595 for (NSView* subview in self.subviews)
583 [subview setFrame:self.bounds]; 596 [subview setFrame:self.bounds];
584 } 597 }
585 598
586 @end 599 @end
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/public/browser/content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698