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

Unified Diff: chrome/browser/ui/cocoa/web_intent_bubble_controller.mm

Issue 9581041: Make web intents picker work as constrained dialog instead of InfoBubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/web_intent_bubble_controller.mm
diff --git a/chrome/browser/ui/cocoa/web_intent_bubble_controller.mm b/chrome/browser/ui/cocoa/web_intent_bubble_controller.mm
index a7626f1d3acdc21ebc90e066cfe484519b91bf53..c9971a78211c309534aa53ef1adda2372448bf6a 100644
--- a/chrome/browser/ui/cocoa/web_intent_bubble_controller.mm
+++ b/chrome/browser/ui/cocoa/web_intent_bubble_controller.mm
@@ -73,43 +73,36 @@ const CGFloat kTextWidth = kWindowWidth - (kImageSize + kImageSpacing +
@implementation WebIntentBubbleController;
-- (id)initWithPicker:(WebIntentPickerCocoa*)picker
- parentWindow:(NSWindow*)parent
- anchoredAt:(NSPoint)point {
+- (id)initWithPicker:(WebIntentPickerCocoa*)picker {
// Use an arbitrary height because it will reflect the size of the content.
NSRect contentRect = NSMakeRect(0, 0, kWindowWidth, kVerticalSpacing);
- // Create an empty window into which content is placed.
- scoped_nsobject<InfoBubbleWindow> window(
- [[InfoBubbleWindow alloc] initWithContentRect:contentRect
- styleMask:NSBorderlessWindowMask
- backing:NSBackingStoreBuffered
- defer:NO]);
- if ((self = [super initWithWindow:window.get()
- parentWindow:parent
- anchoredAt:point])) {
- picker_ = picker;
- [[self bubble] setArrowLocation:info_bubble::kTopLeft];
+ // |window| is retained by the ConstrainedWindowMacDelegateCustomSheet when
+ // the sheet is initialized.
+ scoped_nsobject<NSWindow> window;
+ window.reset(
Nico 2012/03/03 06:13:49 Use scoped_ptr's constructor to set the pointer in
groby-ooo-7-16 2012/03/03 23:41:49 Done.
+ [[NSWindow alloc] initWithContentRect:contentRect
+ styleMask:NSTitledWindowMask
+ backing:NSBackingStoreBuffered
+ defer:YES]);
+
+ if ((self = [super initWithWindow:window.get()])) {
+ picker_ = picker;
[self performLayoutWithModel:NULL];
- [self showWindow:nil];
- picker_->set_controller(self);
}
-
return self;
}
-- (void)setInlineDispositionTabContents:(TabContentsWrapper*)wrapper {
- contents_ = wrapper;
+- (void)sheetDidEnd:(NSWindow*)sheet
+ returnCode:(int)returnCode
+ contextInfo:(void *)contextInfo {
+ // Also called when user navigates to another page while the sheet is open.
Nico 2012/03/03 06:13:49 No space in front of *
groby-ooo-7-16 2012/03/03 23:41:49 Done.
+ if (picker_)
+ picker_->OnSheetDidEnd(sheet);
}
-// We need to watch for window closing so we can notify up via |picker_|.
-- (void)windowWillClose:(NSNotification*)notification {
- if (picker_) {
- WebIntentPickerCocoa* temp = picker_;
- picker_ = NULL; // Abandon picker, we are done with it.
- temp->OnCancelled();
- }
- [super windowWillClose:notification];
+- (void)setInlineDispositionTabContents:(TabContentsWrapper*)wrapper {
+ contents_ = wrapper;
}
// Pop up a new tab with the Chrome Web Store.
@@ -219,7 +212,7 @@ const CGFloat kTextWidth = kWindowWidth - (kImageSize + kImageSpacing +
}
// Add a single button for a specific service
--(CGFloat)addServiceButton:(NSString*)title
+- (CGFloat)addServiceButton:(NSString*)title
withImage:(NSImage*)image
index:(NSUInteger)index
toSubviews:(NSMutableArray*)subviews
@@ -253,7 +246,7 @@ const CGFloat kTextWidth = kWindowWidth - (kImageSize + kImageSpacing +
// Layout the contents of the picker bubble.
- (void)performLayoutWithModel:(WebIntentPickerModel*)model {
// |offset| is the Y position that should be drawn at next.
- CGFloat offset = kFramePadding + info_bubble::kBubbleArrowHeight;
+ CGFloat offset = kFramePadding;
// Keep the new subviews in an array that gets replaced at the end.
NSMutableArray* subviews = [NSMutableArray array];
@@ -290,11 +283,9 @@ const CGFloat kTextWidth = kWindowWidth - (kImageSize + kImageSpacing +
NSRect windowFrame = NSMakeRect(0, 0, kWindowWidth, offset);
windowFrame.size = [[[self window] contentView] convertSize:windowFrame.size
toView:nil];
- // Adjust the origin by the difference in height.
- windowFrame.origin = [[self window] frame].origin;
- windowFrame.origin.y -= NSHeight(windowFrame) -
- NSHeight([[self window] frame]);
+ // Adjust the window frame to accomodate the content.
+ windowFrame=[[self window] frameRectForContentRect:windowFrame];
Nico 2012/03/03 06:13:49 indent looks off
groby-ooo-7-16 2012/03/03 23:41:49 Done.
[[self window] setFrame:windowFrame display:YES animate:YES];
// Replace the window's content.
@@ -302,4 +293,7 @@ const CGFloat kTextWidth = kWindowWidth - (kImageSize + kImageSpacing +
[NSArray arrayWithObject:contentView]];
}
+- (void)closeSheet {
+ [NSApp endSheet:[self window]];
+}
@end // WebIntentBubbleController

Powered by Google App Engine
This is Rietveld 408576698