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

Side by Side Diff: chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.mm

Issue 1995793002: Refactor ChooserBubbleUiController on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor_ChooserBubbleController
Patch Set: rebase Created 4 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/website_settings/chooser_bubble_ui_cocoa.h" 5 #import "chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
11 11
12 #include "base/mac/scoped_nsobject.h" 12 #include "base/mac/scoped_nsobject.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_window.h" 17 #include "chrome/browser/ui/browser_window.h"
18 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" 18 #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
19 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 19 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
20 #import "chrome/browser/ui/cocoa/browser_window_utils.h" 20 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
21 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" 21 #import "chrome/browser/ui/cocoa/chooser_content_view.h"
22 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 22 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
23 #import "chrome/browser/ui/cocoa/info_bubble_window.h" 23 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
24 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" 24 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
25 #include "chrome/browser/ui/website_settings/chooser_bubble_controller.h" 25 #include "chrome/browser/ui/website_settings/chooser_bubble_controller.h"
26 #include "chrome/grit/generated_resources.h" 26 #include "chrome/grit/generated_resources.h"
27 #include "components/url_formatter/elide_url.h" 27 #include "components/url_formatter/elide_url.h"
28 #include "content/public/browser/native_web_keyboard_event.h" 28 #include "content/public/browser/native_web_keyboard_event.h"
29 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h"
30 #include "ui/base/cocoa/cocoa_base_utils.h" 29 #include "ui/base/cocoa/cocoa_base_utils.h"
31 #import "ui/base/cocoa/controls/hyperlink_button_cell.h"
32 #include "ui/base/cocoa/window_size_constants.h" 30 #include "ui/base/cocoa/window_size_constants.h"
33 #include "ui/base/l10n/l10n_util.h" 31 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/base/l10n/l10n_util_mac.h" 32 #include "ui/base/l10n/l10n_util_mac.h"
35 #include "url/gurl.h" 33 #include "url/gurl.h"
36 #include "url/origin.h" 34 #include "url/origin.h"
37 35
38 namespace {
39
40 // Chooser bubble width.
41 const CGFloat kChooserBubbleWidth = 320.0f;
42
43 // Chooser bubble height.
44 const CGFloat kChooserBubbleHeight = 280.0f;
45
46 // Distance between the bubble border and the view that is closest to the
47 // border.
48 const CGFloat kMarginX = 20.0f;
49 const CGFloat kMarginY = 20.0f;
50
51 // Distance between two views inside the bubble.
52 const CGFloat kHorizontalPadding = 10.0f;
53 const CGFloat kVerticalPadding = 10.0f;
54
55 } // namespace
56
57 std::unique_ptr<BubbleUi> ChooserBubbleController::BuildBubbleUi() { 36 std::unique_ptr<BubbleUi> ChooserBubbleController::BuildBubbleUi() {
58 return base::WrapUnique(new ChooserBubbleUiCocoa(browser_, this)); 37 return base::WrapUnique(new ChooserBubbleUiCocoa(browser_, this));
59 } 38 }
60 39
61 @interface ChooserBubbleUiController 40 @interface ChooserBubbleUiController
62 : BaseBubbleController<NSTableViewDataSource, NSTableViewDelegate> { 41 : BaseBubbleController<NSTableViewDataSource, NSTableViewDelegate> {
63 @private 42 @private
64 // Bridge to the C++ class that created this object. 43 // Bridge to the C++ class that created this object.
65 ChooserBubbleUiCocoa* bridge_; 44 ChooserBubbleUiCocoa* bridge_; // Weak.
45 bool buttonPressed_;
66 46
67 base::scoped_nsobject<NSTextField> titleView_; 47 base::scoped_nsobject<ChooserContentView> chooserContentView_;
68 base::scoped_nsobject<NSScrollView> scrollView_; 48 NSTableView* tableView_; // Weak.
69 base::scoped_nsobject<NSTableColumn> tableColumn_; 49 NSButton* connectButton_; // Weak.
70 base::scoped_nsobject<NSTableView> tableView_; 50 NSButton* cancelButton_; // Weak.
71 base::scoped_nsobject<NSButton> connectButton_; 51 NSButton* helpButton_; // Weak.
72 base::scoped_nsobject<NSButton> cancelButton_;
73 base::scoped_nsobject<NSTextField> message_;
74 base::scoped_nsobject<NSButton> getHelpButton_;
75 bool buttonPressed_;
76 52
77 Browser* browser_; // Weak. 53 Browser* browser_; // Weak.
78 ChooserController* chooserController_; // Weak. 54 ChooserController* chooserController_; // Weak.
79 } 55 }
80 56
81 // Designated initializer. |browser| and |bridge| must both be non-nil. 57 // Designated initializer. |browser| and |bridge| must both be non-nil.
82 - (id)initWithBrowser:(Browser*)browser 58 - (id)initWithBrowser:(Browser*)browser
83 initWithChooserController:(ChooserController*)chooserController 59 initWithChooserController:(ChooserController*)chooserController
84 bridge:(ChooserBubbleUiCocoa*)bridge; 60 bridge:(ChooserBubbleUiCocoa*)bridge;
85 61
(...skipping 22 matching lines...) Expand all
108 84
109 // Update |tableView_| when chooser options changed. 85 // Update |tableView_| when chooser options changed.
110 - (void)updateTableView; 86 - (void)updateTableView;
111 87
112 // Determines if the bubble has an anchor in a corner or no anchor at all. 88 // Determines if the bubble has an anchor in a corner or no anchor at all.
113 - (info_bubble::BubbleArrowLocation)getExpectedArrowLocation; 89 - (info_bubble::BubbleArrowLocation)getExpectedArrowLocation;
114 90
115 // Returns the expected parent for this bubble. 91 // Returns the expected parent for this bubble.
116 - (NSWindow*)getExpectedParentWindow; 92 - (NSWindow*)getExpectedParentWindow;
117 93
118 // Creates the title for the bubble.
119 - (base::scoped_nsobject<NSTextField>)bubbleTitle;
120
121 // Creates a button with |title| and |action|.
122 - (base::scoped_nsobject<NSButton>)buttonWithTitle:(NSString*)title
123 action:(SEL)action;
124
125 // Creates the "Connect" button.
126 - (base::scoped_nsobject<NSButton>)connectButton;
127
128 // Creates the "Cancel" button.
129 - (base::scoped_nsobject<NSButton>)cancelButton;
130
131 // Creates the message.
132 - (base::scoped_nsobject<NSTextField>)message;
133
134 // Creates the "Get help" button.
135 - (base::scoped_nsobject<NSButton>)getHelpButton;
136
137 // Called when the "Connect" button is pressed. 94 // Called when the "Connect" button is pressed.
138 - (void)onConnect:(id)sender; 95 - (void)onConnect:(id)sender;
139 96
140 // Called when the "Cancel" button is pressed. 97 // Called when the "Cancel" button is pressed.
141 - (void)onCancel:(id)sender; 98 - (void)onCancel:(id)sender;
142 99
143 // Called when the "Get help" button is pressed. 100 // Called when the "Get help" button is pressed.
144 - (void)onGetHelpPressed:(id)sender; 101 - (void)onHelpPressed:(id)sender;
145 102
146 @end 103 @end
147 104
148 @implementation ChooserBubbleUiController 105 @implementation ChooserBubbleUiController
149 106
150 - (id)initWithBrowser:(Browser*)browser 107 - (id)initWithBrowser:(Browser*)browser
151 initWithChooserController:(ChooserController*)chooserController 108 initWithChooserController:(ChooserController*)chooserController
152 bridge:(ChooserBubbleUiCocoa*)bridge { 109 bridge:(ChooserBubbleUiCocoa*)bridge {
153 DCHECK(browser); 110 DCHECK(browser);
154 DCHECK(chooserController); 111 DCHECK(chooserController);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 - (void)parentWindowDidResize:(NSNotification*)notification { 155 - (void)parentWindowDidResize:(NSNotification*)notification {
199 [self setAnchorPoint:[self getExpectedAnchorPoint]]; 156 [self setAnchorPoint:[self getExpectedAnchorPoint]];
200 } 157 }
201 158
202 - (void)parentWindowDidMove:(NSNotification*)notification { 159 - (void)parentWindowDidMove:(NSNotification*)notification {
203 DCHECK(bridge_); 160 DCHECK(bridge_);
204 [self setAnchorPoint:[self getExpectedAnchorPoint]]; 161 [self setAnchorPoint:[self getExpectedAnchorPoint]];
205 } 162 }
206 163
207 - (void)show { 164 - (void)show {
208 NSView* view = [[self window] contentView]; 165 chooserContentView_.reset([[ChooserContentView alloc]
166 initWithChooserTitle:
167 l10n_util::GetNSStringF(
168 IDS_CHOOSER_BUBBLE_PROMPT,
169 url_formatter::FormatOriginForSecurityDisplay(
170 chooserController_->GetOrigin(),
171 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC))]);
209 172
210 // ------------------------------------ 173 tableView_ = [chooserContentView_ getTableView];
211 // | Chooser bubble title | 174 connectButton_ = [chooserContentView_ getConnectButton];
212 // | -------------------------------- | 175 cancelButton_ = [chooserContentView_ getCancelButton];
213 // | | option 0 | | 176 helpButton_ = [chooserContentView_ getHelpButton];
214 // | | option 1 | |
215 // | | option 2 | |
216 // | | | |
217 // | | | |
218 // | | | |
219 // | -------------------------------- |
220 // | [ Connect ] [ Cancel ] |
221 // |----------------------------------|
222 // | Not seeing your device? Get help |
223 // ------------------------------------
224 177
225 // Determine the dimensions of the bubble. 178 [connectButton_ setTarget:self];
226 // Once the height and width are set, the buttons and permission menus can 179 [connectButton_ setAction:@selector(onConnect:)];
227 // be laid out correctly. 180 [cancelButton_ setTarget:self];
228 NSRect bubbleFrame = 181 [cancelButton_ setAction:@selector(onCancel:)];
229 NSMakeRect(0, 0, kChooserBubbleWidth, kChooserBubbleHeight);
230
231 // Create the views.
232 // Title.
233 titleView_ = [self bubbleTitle];
234 CGFloat titleHeight = NSHeight([titleView_ frame]);
235
236 // Connect button.
237 connectButton_ = [self connectButton];
238 CGFloat connectButtonWidth = NSWidth([connectButton_ frame]);
239 CGFloat connectButtonHeight = NSHeight([connectButton_ frame]);
240
241 // Cancel button.
242 cancelButton_ = [self cancelButton];
243 CGFloat cancelButtonWidth = NSWidth([cancelButton_ frame]);
244
245 // Message.
246 message_ = [self message];
247 CGFloat messageWidth = NSWidth([message_ frame]);
248 CGFloat messageHeight = NSHeight([message_ frame]);
249
250 // Get help button.
251 getHelpButton_ = [self getHelpButton];
252
253 // Separator.
254 CGFloat separatorOriginX = 0.0f;
255 CGFloat separatorOriginY = kMarginY + messageHeight + kVerticalPadding;
256 NSBox* separator =
257 [self horizontalSeparatorWithFrame:NSMakeRect(separatorOriginX,
258 separatorOriginY,
259 kChooserBubbleWidth, 0.0f)];
260
261 // ScollView embedding with TableView.
262 CGFloat scrollViewWidth = kChooserBubbleWidth - 2 * kMarginX;
263 CGFloat scrollViewHeight = kChooserBubbleHeight - 2 * kMarginY -
264 4 * kVerticalPadding - titleHeight -
265 connectButtonHeight - messageHeight;
266 NSRect scrollFrame = NSMakeRect(
267 kMarginX,
268 kMarginY + messageHeight + 3 * kVerticalPadding + connectButtonHeight,
269 scrollViewWidth, scrollViewHeight);
270 scrollView_.reset([[NSScrollView alloc] initWithFrame:scrollFrame]);
271 [scrollView_ setBorderType:NSBezelBorder];
272 [scrollView_ setHasVerticalScroller:YES];
273 [scrollView_ setHasHorizontalScroller:YES];
274 [scrollView_ setAutohidesScrollers:YES];
275
276 // TableView.
277 tableView_.reset([[NSTableView alloc] initWithFrame:NSZeroRect]);
278 tableColumn_.reset([[NSTableColumn alloc] initWithIdentifier:@""]);
279 [tableColumn_ setWidth:(scrollViewWidth - kMarginX)];
280 [tableView_ addTableColumn:tableColumn_];
281 [tableView_ setDelegate:self]; 182 [tableView_ setDelegate:self];
282 [tableView_ setDataSource:self]; 183 [tableView_ setDataSource:self];
283 // Make the column title invisible. 184 [helpButton_ setTarget:self];
284 [tableView_ setHeaderView:nil]; 185 [helpButton_ setAction:@selector(onHelpPressed:)];
285 [tableView_ setFocusRingType:NSFocusRingTypeNone];
286 186
287 // Lay out the views. 187 [[[self window] contentView] addSubview:chooserContentView_.get()];
288 // Title.
289 CGFloat titleOriginX = kMarginX;
290 CGFloat titleOriginY = kChooserBubbleHeight - kMarginY - titleHeight;
291 [titleView_ setFrameOrigin:NSMakePoint(titleOriginX, titleOriginY)];
292 [view addSubview:titleView_];
293 188
294 // ScollView. 189 NSRect bubbleFrame =
295 [scrollView_ setDocumentView:tableView_]; 190 [[self window] frameRectForContentRect:[chooserContentView_ frame]];
296 [view addSubview:scrollView_];
297
298 // Connect button.
299 CGFloat connectButtonOriginX = kChooserBubbleWidth - kMarginX -
300 kHorizontalPadding - connectButtonWidth -
301 cancelButtonWidth;
302 CGFloat connectButtonOriginY =
303 kMarginY + messageHeight + 2 * kVerticalPadding;
304 [connectButton_
305 setFrameOrigin:NSMakePoint(connectButtonOriginX, connectButtonOriginY)];
306 [connectButton_ setEnabled:NO];
307 [view addSubview:connectButton_];
308
309 // Cancel button.
310 CGFloat cancelButtonOriginX =
311 kChooserBubbleWidth - kMarginX - cancelButtonWidth;
312 CGFloat cancelButtonOriginY = connectButtonOriginY;
313 [cancelButton_
314 setFrameOrigin:NSMakePoint(cancelButtonOriginX, cancelButtonOriginY)];
315 [view addSubview:cancelButton_];
316
317 // Separator.
318 [view addSubview:separator];
319
320 // Message.
321 CGFloat messageOriginX = kMarginX;
322 CGFloat messageOriginY = kMarginY;
323 [message_ setFrameOrigin:NSMakePoint(messageOriginX, messageOriginY)];
324 [view addSubview:message_];
325
326 // Get help button.
327 getHelpButton_ = [self getHelpButton];
328 CGFloat getHelpButtonOriginX =
329 kMarginX + messageWidth - kHorizontalPadding / 2;
330 CGFloat getHelpButtonOriginY = kMarginY;
331 [getHelpButton_
332 setFrameOrigin:NSMakePoint(getHelpButtonOriginX, getHelpButtonOriginY)];
333 [view addSubview:getHelpButton_];
334
335 bubbleFrame = [[self window] frameRectForContentRect:bubbleFrame];
336 if ([[self window] isVisible]) { 191 if ([[self window] isVisible]) {
337 // Unfortunately, calling -setFrame followed by -setFrameOrigin (called 192 // Unfortunately, calling -setFrame followed by -setFrameOrigin (called
338 // within -setAnchorPoint) causes flickering. Avoid the flickering by 193 // within -setAnchorPoint) causes flickering. Avoid the flickering by
339 // manually adjusting the new frame's origin so that the top left stays the 194 // manually adjusting the new frame's origin so that the top left stays the
340 // same, and only calling -setFrame. 195 // same, and only calling -setFrame.
341 NSRect currentWindowFrame = [[self window] frame]; 196 NSRect currentWindowFrame = [[self window] frame];
342 bubbleFrame.origin = currentWindowFrame.origin; 197 bubbleFrame.origin = currentWindowFrame.origin;
343 bubbleFrame.origin.y = bubbleFrame.origin.y + 198 bubbleFrame.origin.y = bubbleFrame.origin.y +
344 currentWindowFrame.size.height - 199 currentWindowFrame.size.height -
345 bubbleFrame.size.height; 200 bubbleFrame.size.height;
346 [[self window] setFrame:bubbleFrame display:YES]; 201 [[self window] setFrame:bubbleFrame display:YES];
347 } else { 202 } else {
348 [[self window] setFrame:bubbleFrame display:NO]; 203 [[self window] setFrame:bubbleFrame display:NO];
349 [self setAnchorPoint:[self getExpectedAnchorPoint]]; 204 [self setAnchorPoint:[self getExpectedAnchorPoint]];
350 [self showWindow:nil]; 205 [self showWindow:nil];
351 [[self window] makeFirstResponder:nil]; 206 [[self window] makeFirstResponder:nil];
352 [[self window] setInitialFirstResponder:tableView_.get()]; 207 [[self window] setInitialFirstResponder:tableView_];
353 } 208 }
354 } 209 }
355 210
356 - (NSInteger)numberOfRowsInTableView:(NSTableView*)tableView { 211 - (NSInteger)numberOfRowsInTableView:(NSTableView*)tableView {
357 // When there are no devices, the table contains a message saying there are 212 // When there are no devices, the table contains a message saying there are
358 // no devices, so the number of rows is always at least 1. 213 // no devices, so the number of rows is always at least 1.
359 return std::max(static_cast<NSInteger>(chooserController_->NumOptions()), 214 return std::max(static_cast<NSInteger>(chooserController_->NumOptions()),
360 static_cast<NSInteger>(1)); 215 static_cast<NSInteger>(1));
361 } 216 }
362 217
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 291
437 - (info_bubble::BubbleArrowLocation)getExpectedArrowLocation { 292 - (info_bubble::BubbleArrowLocation)getExpectedArrowLocation {
438 return [self hasLocationBar] ? info_bubble::kTopLeft : info_bubble::kNoArrow; 293 return [self hasLocationBar] ? info_bubble::kTopLeft : info_bubble::kNoArrow;
439 } 294 }
440 295
441 - (NSWindow*)getExpectedParentWindow { 296 - (NSWindow*)getExpectedParentWindow {
442 DCHECK(browser_->window()); 297 DCHECK(browser_->window());
443 return browser_->window()->GetNativeWindow(); 298 return browser_->window()->GetNativeWindow();
444 } 299 }
445 300
446 - (base::scoped_nsobject<NSTextField>)bubbleTitle {
447 base::scoped_nsobject<NSTextField> titleView(
448 [[NSTextField alloc] initWithFrame:NSZeroRect]);
449 [titleView setDrawsBackground:NO];
450 [titleView setBezeled:NO];
451 [titleView setEditable:NO];
452 [titleView setSelectable:NO];
453 [titleView setStringValue:
454 l10n_util::GetNSStringF(
455 IDS_CHOOSER_BUBBLE_PROMPT,
456 url_formatter::FormatOriginForSecurityDisplay(
457 chooserController_->GetOrigin(),
458 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC))];
459 [titleView setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
460 // The height is arbitrary as it will be adjusted later.
461 [titleView setFrameSize:NSMakeSize(kChooserBubbleWidth - 2 * kMarginX, 0.0f)];
462 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:titleView];
463 return titleView;
464 }
465
466 - (base::scoped_nsobject<NSButton>)buttonWithTitle:(NSString*)title
467 action:(SEL)action {
468 base::scoped_nsobject<NSButton> button(
469 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]);
470 [button setButtonType:NSMomentaryPushInButton];
471 [button setTitle:title];
472 [button setTarget:self];
473 [button setAction:action];
474 [button sizeToFit];
475 return button;
476 }
477
478 - (base::scoped_nsobject<NSButton>)connectButton {
479 NSString* connectTitle =
480 l10n_util::GetNSString(IDS_CHOOSER_BUBBLE_CONNECT_BUTTON_TEXT);
481 return [self buttonWithTitle:connectTitle action:@selector(onConnect:)];
482 }
483
484 - (base::scoped_nsobject<NSButton>)cancelButton {
485 NSString* cancelTitle =
486 l10n_util::GetNSString(IDS_CHOOSER_BUBBLE_CANCEL_BUTTON_TEXT);
487 return [self buttonWithTitle:cancelTitle action:@selector(onCancel:)];
488 }
489
490 - (base::scoped_nsobject<NSTextField>)message {
491 base::scoped_nsobject<NSTextField> messageView(
492 [[NSTextField alloc] initWithFrame:NSZeroRect]);
493 [messageView setDrawsBackground:NO];
494 [messageView setBezeled:NO];
495 [messageView setEditable:NO];
496 [messageView setSelectable:NO];
497 [messageView
498 setStringValue:l10n_util::GetNSStringF(IDS_CHOOSER_BUBBLE_FOOTNOTE_TEXT,
499 base::string16())];
500 [messageView setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
501 [messageView sizeToFit];
502 return messageView;
503 }
504
505 - (base::scoped_nsobject<NSButton>)getHelpButton {
506 base::scoped_nsobject<NSButton> button(
507 [[NSButton alloc] initWithFrame:NSZeroRect]);
508 base::scoped_nsobject<HyperlinkButtonCell> cell([[HyperlinkButtonCell alloc]
509 initTextCell:l10n_util::GetNSString(
510 IDS_CHOOSER_BUBBLE_GET_HELP_LINK_TEXT)]);
511 [button setCell:cell.get()];
512 [button sizeToFit];
513 [button setTarget:self];
514 [button setAction:@selector(onGetHelpPressed:)];
515 return button;
516 }
517
518 + (CGFloat)matchWidthsOf:(NSView*)viewA andOf:(NSView*)viewB { 301 + (CGFloat)matchWidthsOf:(NSView*)viewA andOf:(NSView*)viewB {
519 NSRect frameA = [viewA frame]; 302 NSRect frameA = [viewA frame];
520 NSRect frameB = [viewB frame]; 303 NSRect frameB = [viewB frame];
521 CGFloat width = std::max(NSWidth(frameA), NSWidth(frameB)); 304 CGFloat width = std::max(NSWidth(frameA), NSWidth(frameB));
522 [viewA setFrameSize:NSMakeSize(width, NSHeight(frameA))]; 305 [viewA setFrameSize:NSMakeSize(width, NSHeight(frameA))];
523 [viewB setFrameSize:NSMakeSize(width, NSHeight(frameB))]; 306 [viewB setFrameSize:NSMakeSize(width, NSHeight(frameB))];
524 return width; 307 return width;
525 } 308 }
526 309
527 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB { 310 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB {
(...skipping 10 matching lines...) Expand all
538 chooserController_->Select(row); 321 chooserController_->Select(row);
539 [self close]; 322 [self close];
540 } 323 }
541 324
542 - (void)onCancel:(id)sender { 325 - (void)onCancel:(id)sender {
543 buttonPressed_ = true; 326 buttonPressed_ = true;
544 chooserController_->Cancel(); 327 chooserController_->Cancel();
545 [self close]; 328 [self close];
546 } 329 }
547 330
548 - (void)onGetHelpPressed:(id)sender { 331 - (void)onHelpPressed:(id)sender {
549 chooserController_->OpenHelpCenterUrl(); 332 chooserController_->OpenHelpCenterUrl();
550 } 333 }
551 334
552 @end 335 @end
553 336
554 ChooserBubbleUiCocoa::ChooserBubbleUiCocoa( 337 ChooserBubbleUiCocoa::ChooserBubbleUiCocoa(
555 Browser* browser, 338 Browser* browser,
556 ChooserController* chooser_controller) 339 ChooserController* chooser_controller)
557 : browser_(browser), 340 : browser_(browser),
558 chooser_controller_(chooser_controller), 341 chooser_controller_(chooser_controller),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 [chooser_bubble_ui_controller_ onOptionAdded:static_cast<NSInteger>(index)]; 380 [chooser_bubble_ui_controller_ onOptionAdded:static_cast<NSInteger>(index)];
598 } 381 }
599 382
600 void ChooserBubbleUiCocoa::OnOptionRemoved(size_t index) { 383 void ChooserBubbleUiCocoa::OnOptionRemoved(size_t index) {
601 [chooser_bubble_ui_controller_ onOptionRemoved:static_cast<NSInteger>(index)]; 384 [chooser_bubble_ui_controller_ onOptionRemoved:static_cast<NSInteger>(index)];
602 } 385 }
603 386
604 void ChooserBubbleUiCocoa::OnBubbleClosing() { 387 void ChooserBubbleUiCocoa::OnBubbleClosing() {
605 chooser_bubble_ui_controller_ = nil; 388 chooser_bubble_ui_controller_ = nil;
606 } 389 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698