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

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

Issue 11275062: Move content\browser\web_contents to content namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 namespace content { 67 namespace content {
68 WebContentsView* CreateWebContentsView( 68 WebContentsView* CreateWebContentsView(
69 WebContentsImpl* web_contents, 69 WebContentsImpl* web_contents,
70 WebContentsViewDelegate* delegate, 70 WebContentsViewDelegate* delegate,
71 RenderViewHostDelegateView** render_view_host_delegate_view) { 71 RenderViewHostDelegateView** render_view_host_delegate_view) {
72 WebContentsViewMac* rv = new WebContentsViewMac(web_contents, delegate); 72 WebContentsViewMac* rv = new WebContentsViewMac(web_contents, delegate);
73 *render_view_host_delegate_view = rv; 73 *render_view_host_delegate_view = rv;
74 return rv; 74 return rv;
75 } 75 }
76 }
77 76
78 WebContentsViewMac::WebContentsViewMac( 77 WebContentsViewMac::WebContentsViewMac(
79 WebContentsImpl* web_contents, 78 WebContentsImpl* web_contents,
tfarina 2012/10/29 19:37:19 will fit above now.
jam 2012/10/29 20:01:51 Done.
80 content::WebContentsViewDelegate* delegate) 79 WebContentsViewDelegate* delegate)
81 : web_contents_(web_contents), 80 : web_contents_(web_contents),
82 delegate_(delegate) { 81 delegate_(delegate) {
83 } 82 }
84 83
85 WebContentsViewMac::~WebContentsViewMac() { 84 WebContentsViewMac::~WebContentsViewMac() {
86 // This handles the case where a renderer close call was deferred 85 // This handles the case where a renderer close call was deferred
87 // while the user was operating a UI control which resulted in a 86 // while the user was operating a UI control which resulted in a
88 // close. In that case, the Cocoa view outlives the 87 // close. In that case, the Cocoa view outlives the
89 // WebContentsViewMac instance due to Cocoa retain count. 88 // WebContentsViewMac instance due to Cocoa retain count.
90 [cocoa_view_ cancelDeferredClose]; 89 [cocoa_view_ cancelDeferredClose];
91 [cocoa_view_ clearWebContentsView]; 90 [cocoa_view_ clearWebContentsView];
92 } 91 }
93 92
94 void WebContentsViewMac::CreateView(const gfx::Size& initial_size) { 93 void WebContentsViewMac::CreateView(const gfx::Size& initial_size) {
95 WebContentsViewCocoa* view = 94 WebContentsViewCocoa* view =
96 [[WebContentsViewCocoa alloc] initWithWebContentsViewMac:this]; 95 [[WebContentsViewCocoa alloc] initWithWebContentsViewMac:this];
97 cocoa_view_.reset(view); 96 cocoa_view_.reset(view);
98 } 97 }
99 98
100 RenderWidgetHostView* WebContentsViewMac::CreateViewForWidget( 99 RenderWidgetHostView* WebContentsViewMac::CreateViewForWidget(
101 content::RenderWidgetHost* render_widget_host) { 100 RenderWidgetHost* render_widget_host) {
102 if (render_widget_host->GetView()) { 101 if (render_widget_host->GetView()) {
103 // During testing, the view will already be set up in most cases to the 102 // During testing, the view will already be set up in most cases to the
104 // test view, so we don't want to clobber it with a real one. To verify that 103 // test view, so we don't want to clobber it with a real one. To verify that
105 // this actually is happening (and somebody isn't accidentally creating the 104 // this actually is happening (and somebody isn't accidentally creating the
106 // view twice), we check for the RVH Factory, which will be set when we're 105 // view twice), we check for the RVH Factory, which will be set when we're
107 // making special ones (which go along with the special views). 106 // making special ones (which go along with the special views).
108 DCHECK(RenderViewHostFactory::has_factory()); 107 DCHECK(RenderViewHostFactory::has_factory());
109 return render_widget_host->GetView(); 108 return render_widget_host->GetView();
110 } 109 }
111 110
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // processing events. 185 // processing events.
187 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); 186 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
188 NSDragOperation mask = static_cast<NSDragOperation>(allowed_operations); 187 NSDragOperation mask = static_cast<NSDragOperation>(allowed_operations);
189 NSPoint offset = NSPointFromCGPoint(image_offset.ToCGPoint()); 188 NSPoint offset = NSPointFromCGPoint(image_offset.ToCGPoint());
190 [cocoa_view_ startDragWithDropData:drop_data 189 [cocoa_view_ startDragWithDropData:drop_data
191 dragOperationMask:mask 190 dragOperationMask:mask
192 image:gfx::NSImageFromImageSkia(image) 191 image:gfx::NSImageFromImageSkia(image)
193 offset:offset]; 192 offset:offset];
194 } 193 }
195 194
196 void WebContentsViewMac::RenderViewCreated(content::RenderViewHost* host) { 195 void WebContentsViewMac::RenderViewCreated(RenderViewHost* host) {
197 // We want updates whenever the intrinsic width of the webpage changes. 196 // We want updates whenever the intrinsic width of the webpage changes.
198 // Put the RenderView into that mode. The preferred width is used for example 197 // Put the RenderView into that mode. The preferred width is used for example
199 // when the "zoom" button in the browser window is clicked. 198 // when the "zoom" button in the browser window is clicked.
200 host->EnablePreferredSizeMode(); 199 host->EnablePreferredSizeMode();
201 } 200 }
202 201
203 void WebContentsViewMac::SetPageTitle(const string16& title) { 202 void WebContentsViewMac::SetPageTitle(const string16& title) {
204 // Meaningless on the Mac; widgets don't have a "title" attribute 203 // Meaningless on the Mac; widgets don't have a "title" attribute
205 } 204 }
206 205
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 // iterated past the last focusable element on the page). 272 // iterated past the last focusable element on the page).
274 void WebContentsViewMac::TakeFocus(bool reverse) { 273 void WebContentsViewMac::TakeFocus(bool reverse) {
275 if (reverse) { 274 if (reverse) {
276 [[cocoa_view_ window] selectPreviousKeyView:cocoa_view_.get()]; 275 [[cocoa_view_ window] selectPreviousKeyView:cocoa_view_.get()];
277 } else { 276 } else {
278 [[cocoa_view_ window] selectNextKeyView:cocoa_view_.get()]; 277 [[cocoa_view_ window] selectNextKeyView:cocoa_view_.get()];
279 } 278 }
280 } 279 }
281 280
282 void WebContentsViewMac::ShowContextMenu( 281 void WebContentsViewMac::ShowContextMenu(
283 const content::ContextMenuParams& params, 282 const ContextMenuParams& params,
tfarina 2012/10/29 19:37:19 can be moved above now.
jam 2012/10/29 20:01:51 Done.
284 content::ContextMenuSourceType type) { 283 ContextMenuSourceType type) {
285 // Allow delegates to handle the context menu operation first. 284 // Allow delegates to handle the context menu operation first.
286 if (web_contents_->GetDelegate() && 285 if (web_contents_->GetDelegate() &&
287 web_contents_->GetDelegate()->HandleContextMenu(params)) { 286 web_contents_->GetDelegate()->HandleContextMenu(params)) {
288 return; 287 return;
289 } 288 }
290 289
291 if (delegate()) 290 if (delegate())
292 delegate()->ShowContextMenu(params, type); 291 delegate()->ShowContextMenu(params, type);
293 else 292 else
294 DLOG(ERROR) << "Cannot show context menus without a delegate."; 293 DLOG(ERROR) << "Cannot show context menus without a delegate.";
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 gfx::Rect WebContentsViewMac::GetViewBounds() const { 326 gfx::Rect WebContentsViewMac::GetViewBounds() const {
328 // This method is not currently used on mac. 327 // This method is not currently used on mac.
329 NOTIMPLEMENTED(); 328 NOTIMPLEMENTED();
330 return gfx::Rect(); 329 return gfx::Rect();
331 } 330 }
332 331
333 void WebContentsViewMac::CloseTab() { 332 void WebContentsViewMac::CloseTab() {
334 web_contents_->Close(web_contents_->GetRenderViewHost()); 333 web_contents_->Close(web_contents_->GetRenderViewHost());
335 } 334 }
336 335
336 } // namespace content
337
337 @implementation WebContentsViewCocoa 338 @implementation WebContentsViewCocoa
338 339
339 - (id)initWithWebContentsViewMac:(WebContentsViewMac*)w { 340 - (id)initWithWebContentsViewMac:(WebContentsViewMac*)w {
340 self = [super initWithFrame:NSZeroRect]; 341 self = [super initWithFrame:NSZeroRect];
341 if (self != nil) { 342 if (self != nil) {
342 webContentsView_ = w; 343 webContentsView_ = w;
343 dragDest_.reset( 344 dragDest_.reset(
344 [[WebDragDest alloc] initWithWebContentsImpl:[self webContents]]); 345 [[WebDragDest alloc] initWithWebContentsImpl:[self webContents]]);
345 [self registerDragTypes]; 346 [self registerDragTypes];
346 347
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 [[[notification userInfo] objectForKey:kSelectionDirection] 531 [[[notification userInfo] objectForKey:kSelectionDirection]
531 unsignedIntegerValue]; 532 unsignedIntegerValue];
532 if (direction == NSDirectSelection) 533 if (direction == NSDirectSelection)
533 return; 534 return;
534 535
535 [self webContents]-> 536 [self webContents]->
536 FocusThroughTabTraversal(direction == NSSelectingPrevious); 537 FocusThroughTabTraversal(direction == NSSelectingPrevious);
537 } 538 }
538 539
539 @end 540 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698