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

Side by Side Diff: chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm

Issue 120253002: Set parent for window picker dialog on Mac (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/cocoa/media_picker/desktop_media_picker_controller.h" 5 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #import "base/mac/bundle_locations.h" 8 #import "base/mac/bundle_locations.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_item.h" 10 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_item.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 // Action handlers. 49 // Action handlers.
50 - (void)okPressed:(id)sender; 50 - (void)okPressed:(id)sender;
51 - (void)cancelPressed:(id)sender; 51 - (void)cancelPressed:(id)sender;
52 52
53 @end 53 @end
54 54
55 @implementation DesktopMediaPickerController 55 @implementation DesktopMediaPickerController
56 56
57 - (id)initWithMediaList:(scoped_ptr<DesktopMediaList>)media_list 57 - (id)initWithMediaList:(scoped_ptr<DesktopMediaList>)media_list
58 parent:(NSWindow*)parent
58 callback:(const DesktopMediaPicker::DoneCallback&)callback 59 callback:(const DesktopMediaPicker::DoneCallback&)callback
59 appName:(const string16&)appName { 60 appName:(const string16&)appName {
60 const NSUInteger kStyleMask = 61 const NSUInteger kStyleMask =
61 NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask; 62 NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask;
Mark Mentovai 2013/12/20 21:26:00 Is this correct now that you might be creating a c
Sergey Ulanov 2013/12/20 21:40:07 I think it's still correct.
62 base::scoped_nsobject<NSWindow> window( 63 base::scoped_nsobject<NSWindow> window(
63 [[NSWindow alloc] initWithContentRect:ui::kWindowSizeDeterminedLater 64 [[NSWindow alloc] initWithContentRect:ui::kWindowSizeDeterminedLater
64 styleMask:kStyleMask 65 styleMask:kStyleMask
65 backing:NSBackingStoreBuffered 66 backing:NSBackingStoreBuffered
66 defer:NO]); 67 defer:NO]);
67 68
69 [parent addChildWindow:window ordered:NSWindowAbove];
Mark Mentovai 2013/12/20 21:26:00 This should be inside the [super initWithWindow:]
Mark Mentovai 2013/12/20 21:26:00 Do you ever want to remove this window from its pa
Sergey Ulanov 2013/12/20 21:40:07 Done.
Sergey Ulanov 2013/12/20 21:40:07 No, I don't think we need to remove it from parent
70
68 if ((self = [super initWithWindow:window])) { 71 if ((self = [super initWithWindow:window])) {
69 [window setDelegate:self]; 72 [window setDelegate:self];
70 [self initializeContentsWithAppName:appName]; 73 [self initializeContentsWithAppName:appName];
71 media_list_ = media_list.Pass(); 74 media_list_ = media_list.Pass();
72 media_list_->SetViewDialogWindowId([window windowNumber]); 75 media_list_->SetViewDialogWindowId([window windowNumber]);
73 doneCallback_ = callback; 76 doneCallback_ = callback;
74 items_.reset([[NSMutableArray alloc] init]); 77 items_.reset([[NSMutableArray alloc] init]);
75 bridge_.reset(new DesktopMediaPickerBridge(self)); 78 bridge_.reset(new DesktopMediaPickerBridge(self));
76 } 79 }
77 return self; 80 return self;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 - (void)sourceThumbnailChangedAtIndex:(int)index { 290 - (void)sourceThumbnailChangedAtIndex:(int)index {
288 const DesktopMediaList::Source& source = media_list_->GetSource(index); 291 const DesktopMediaList::Source& source = media_list_->GetSource(index);
289 NSImage* image = gfx::NSImageFromImageSkia(source.thumbnail); 292 NSImage* image = gfx::NSImageFromImageSkia(source.thumbnail);
290 293
291 DesktopMediaPickerItem* item = [items_ objectAtIndex:index]; 294 DesktopMediaPickerItem* item = [items_ objectAtIndex:index];
292 [item setImageRepresentation:image]; 295 [item setImageRepresentation:image];
293 [sourceBrowser_ reloadData]; 296 [sourceBrowser_ reloadData];
294 } 297 }
295 298
296 @end // @interface DesktopMediaPickerController 299 @end // @interface DesktopMediaPickerController
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698