| OLD | NEW |
| 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/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 18 #import "chrome/browser/ui/chrome_style.h" | 18 #import "chrome/browser/ui/chrome_style.h" |
| 19 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" | 19 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
| 20 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 20 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 21 #import "chrome/browser/ui/cocoa/browser_window_utils.h" | 21 #import "chrome/browser/ui/cocoa/browser_window_utils.h" |
| 22 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" | 22 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" |
| 23 #import "chrome/browser/ui/cocoa/hover_close_button.h" | 23 #import "chrome/browser/ui/cocoa/hover_close_button.h" |
| 24 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 24 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| 25 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 25 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| 26 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 26 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 27 #include "chrome/browser/ui/website_settings/chooser_bubble_delegate.h" | |
| 28 #include "chrome/grit/generated_resources.h" | 27 #include "chrome/grit/generated_resources.h" |
| 29 #include "content/public/browser/native_web_keyboard_event.h" | 28 #include "content/public/browser/native_web_keyboard_event.h" |
| 30 #include "skia/ext/skia_utils_mac.h" | 29 #include "skia/ext/skia_utils_mac.h" |
| 31 #include "ui/base/cocoa/controls/hyperlink_text_view.h" | 30 #include "ui/base/cocoa/controls/hyperlink_text_view.h" |
| 32 #include "ui/base/cocoa/window_size_constants.h" | 31 #include "ui/base/cocoa/window_size_constants.h" |
| 33 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
| 34 #include "ui/base/l10n/l10n_util_mac.h" | 33 #include "ui/base/l10n/l10n_util_mac.h" |
| 35 #include "url/gurl.h" | 34 #include "url/gurl.h" |
| 36 | 35 |
| 37 namespace { | 36 namespace { |
| 38 | 37 |
| 39 // Chooser bubble width. | 38 // Chooser bubble width. |
| 40 const CGFloat kChooserBubbleWidth = 320.0f; | 39 const CGFloat kChooserBubbleWidth = 320.0f; |
| 41 | 40 |
| 42 // Chooser bubble height. | 41 // Chooser bubble height. |
| 43 const CGFloat kChooserBubbleHeight = 280.0f; | 42 const CGFloat kChooserBubbleHeight = 280.0f; |
| 44 | 43 |
| 45 // Distance between the bubble border and the view that is closest to the | 44 // Distance between the bubble border and the view that is closest to the |
| 46 // border. | 45 // border. |
| 47 const CGFloat kMarginX = 20.0f; | 46 const CGFloat kMarginX = 20.0f; |
| 48 const CGFloat kMarginY = 20.0f; | 47 const CGFloat kMarginY = 20.0f; |
| 49 | 48 |
| 50 // Distance between two views inside the bubble. | 49 // Distance between two views inside the bubble. |
| 51 const CGFloat kHorizontalPadding = 10.0f; | 50 const CGFloat kHorizontalPadding = 10.0f; |
| 52 const CGFloat kVerticalPadding = 10.0f; | 51 const CGFloat kVerticalPadding = 10.0f; |
| 53 | 52 |
| 54 } // namespace | 53 } // namespace |
| 55 | 54 |
| 56 scoped_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() { | 55 scoped_ptr<BubbleUi> ChooserBubbleController::BuildBubbleUi() { |
| 57 return make_scoped_ptr(new ChooserBubbleUiCocoa(browser_, this)); | 56 return make_scoped_ptr(new ChooserBubbleUiCocoa(browser_, this)); |
| 58 } | 57 } |
| 59 | 58 |
| 60 @interface ChooserBubbleUiController | 59 @interface ChooserBubbleUiController |
| 61 : BaseBubbleController<NSTableViewDataSource, NSTableViewDelegate> { | 60 : BaseBubbleController<NSTableViewDataSource, NSTableViewDelegate> { |
| 62 @private | 61 @private |
| 63 // Bridge to the C++ class that created this object. | 62 // Bridge to the C++ class that created this object. |
| 64 ChooserBubbleUiCocoa* bridge_; | 63 ChooserBubbleUiCocoa* bridge_; |
| 65 | 64 |
| 66 base::scoped_nsobject<NSTextField> titleView_; | 65 base::scoped_nsobject<NSTextField> titleView_; |
| 67 base::scoped_nsobject<NSScrollView> scrollView_; | 66 base::scoped_nsobject<NSScrollView> scrollView_; |
| 68 base::scoped_nsobject<NSTableColumn> tableColumn_; | 67 base::scoped_nsobject<NSTableColumn> tableColumn_; |
| 69 base::scoped_nsobject<NSTableView> tableView_; | 68 base::scoped_nsobject<NSTableView> tableView_; |
| 70 base::scoped_nsobject<NSButton> connectButton_; | 69 base::scoped_nsobject<NSButton> connectButton_; |
| 71 base::scoped_nsobject<NSButton> cancelButton_; | 70 base::scoped_nsobject<NSButton> cancelButton_; |
| 72 base::scoped_nsobject<HyperlinkTextView> message_; | 71 base::scoped_nsobject<HyperlinkTextView> message_; |
| 73 bool buttonPressed_; | 72 bool buttonPressed_; |
| 74 | 73 |
| 75 Browser* browser_; // Weak. | 74 Browser* browser_; // Weak. |
| 76 ChooserBubbleDelegate* chooserBubbleDelegate_; // Weak. | 75 ChooserBubbleController* chooserBubbleController_; // Weak. |
| 77 } | 76 } |
| 78 | 77 |
| 79 // Designated initializer. |browser| and |bridge| must both be non-nil. | 78 // Designated initializer. |browser| and |bridge| must both be non-nil. |
| 80 - (id)initWithBrowser:(Browser*)browser | 79 - (id)initWithBrowser:(Browser*)browser |
| 81 initWithChooserBubbleDelegate:(ChooserBubbleDelegate*)chooserBubbleDelegate | 80 initWithChooserBubbleController: |
| 82 bridge:(ChooserBubbleUiCocoa*)bridge; | 81 (ChooserBubbleController*)chooserBubbleController |
| 82 bridge:(ChooserBubbleUiCocoa*)bridge; |
| 83 | 83 |
| 84 // Makes the bubble visible. | 84 // Makes the bubble visible. |
| 85 - (void)show; | 85 - (void)show; |
| 86 | 86 |
| 87 // Will reposition the bubble based in case the anchor or parent should change. | 87 // Will reposition the bubble based in case the anchor or parent should change. |
| 88 - (void)updateAnchorPosition; | 88 - (void)updateAnchorPosition; |
| 89 | 89 |
| 90 // Will calculate the expected anchor point for this bubble. | 90 // Will calculate the expected anchor point for this bubble. |
| 91 // Should only be used outside this class for tests. | 91 // Should only be used outside this class for tests. |
| 92 - (NSPoint)getExpectedAnchorPoint; | 92 - (NSPoint)getExpectedAnchorPoint; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 - (void)onConnect:(id)sender; | 133 - (void)onConnect:(id)sender; |
| 134 | 134 |
| 135 // Called when the "Cancel" button is pressed. | 135 // Called when the "Cancel" button is pressed. |
| 136 - (void)onCancel:(id)sender; | 136 - (void)onCancel:(id)sender; |
| 137 | 137 |
| 138 @end | 138 @end |
| 139 | 139 |
| 140 @implementation ChooserBubbleUiController | 140 @implementation ChooserBubbleUiController |
| 141 | 141 |
| 142 - (id)initWithBrowser:(Browser*)browser | 142 - (id)initWithBrowser:(Browser*)browser |
| 143 initWithChooserBubbleDelegate:(ChooserBubbleDelegate*)chooserBubbleDelegate | 143 initWithChooserBubbleController: |
| 144 bridge:(ChooserBubbleUiCocoa*)bridge { | 144 (ChooserBubbleController*)chooserBubbleController |
| 145 bridge:(ChooserBubbleUiCocoa*)bridge { |
| 145 DCHECK(browser); | 146 DCHECK(browser); |
| 146 DCHECK(chooserBubbleDelegate); | 147 DCHECK(chooserBubbleController); |
| 147 DCHECK(bridge); | 148 DCHECK(bridge); |
| 148 | 149 |
| 149 browser_ = browser; | 150 browser_ = browser; |
| 150 chooserBubbleDelegate_ = chooserBubbleDelegate; | 151 chooserBubbleController_ = chooserBubbleController; |
| 151 | 152 |
| 152 base::scoped_nsobject<InfoBubbleWindow> window([[InfoBubbleWindow alloc] | 153 base::scoped_nsobject<InfoBubbleWindow> window([[InfoBubbleWindow alloc] |
| 153 initWithContentRect:ui::kWindowSizeDeterminedLater | 154 initWithContentRect:ui::kWindowSizeDeterminedLater |
| 154 styleMask:NSBorderlessWindowMask | 155 styleMask:NSBorderlessWindowMask |
| 155 backing:NSBackingStoreBuffered | 156 backing:NSBackingStoreBuffered |
| 156 defer:NO]); | 157 defer:NO]); |
| 157 [window setAllowedAnimations:info_bubble::kAnimateNone]; | 158 [window setAllowedAnimations:info_bubble::kAnimateNone]; |
| 158 [window setReleasedWhenClosed:NO]; | 159 [window setReleasedWhenClosed:NO]; |
| 159 if ((self = [super initWithWindow:window | 160 if ((self = [super initWithWindow:window |
| 160 parentWindow:[self getExpectedParentWindow] | 161 parentWindow:[self getExpectedParentWindow] |
| (...skipping 10 matching lines...) Expand all Loading... |
| 171 } | 172 } |
| 172 return self; | 173 return self; |
| 173 } | 174 } |
| 174 | 175 |
| 175 - (void)windowWillClose:(NSNotification*)notification { | 176 - (void)windowWillClose:(NSNotification*)notification { |
| 176 [[NSNotificationCenter defaultCenter] | 177 [[NSNotificationCenter defaultCenter] |
| 177 removeObserver:self | 178 removeObserver:self |
| 178 name:NSWindowDidMoveNotification | 179 name:NSWindowDidMoveNotification |
| 179 object:nil]; | 180 object:nil]; |
| 180 if (!buttonPressed_) | 181 if (!buttonPressed_) |
| 181 chooserBubbleDelegate_->Close(); | 182 chooserBubbleController_->Close(); |
| 182 bridge_->OnBubbleClosing(); | 183 bridge_->OnBubbleClosing(); |
| 183 [super windowWillClose:notification]; | 184 [super windowWillClose:notification]; |
| 184 } | 185 } |
| 185 | 186 |
| 186 - (void)parentWindowWillToggleFullScreen:(NSNotification*)notification { | 187 - (void)parentWindowWillToggleFullScreen:(NSNotification*)notification { |
| 187 // Override the base class implementation, which would have closed the bubble. | 188 // Override the base class implementation, which would have closed the bubble. |
| 188 } | 189 } |
| 189 | 190 |
| 190 - (void)parentWindowDidResize:(NSNotification*)notification { | 191 - (void)parentWindowDidResize:(NSNotification*)notification { |
| 191 [self setAnchorPoint:[self getExpectedAnchorPoint]]; | 192 [self setAnchorPoint:[self getExpectedAnchorPoint]]; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 [self setAnchorPoint:[self getExpectedAnchorPoint]]; | 329 [self setAnchorPoint:[self getExpectedAnchorPoint]]; |
| 329 [self showWindow:nil]; | 330 [self showWindow:nil]; |
| 330 [[self window] makeFirstResponder:nil]; | 331 [[self window] makeFirstResponder:nil]; |
| 331 [[self window] setInitialFirstResponder:connectButton_.get()]; | 332 [[self window] setInitialFirstResponder:connectButton_.get()]; |
| 332 } | 333 } |
| 333 } | 334 } |
| 334 | 335 |
| 335 - (NSInteger)numberOfRowsInTableView:(NSTableView*)tableView { | 336 - (NSInteger)numberOfRowsInTableView:(NSTableView*)tableView { |
| 336 // When there are no devices, the table contains a message saying there are | 337 // When there are no devices, the table contains a message saying there are |
| 337 // no devices, so the number of rows is always at least 1. | 338 // no devices, so the number of rows is always at least 1. |
| 338 return std::max(static_cast<NSInteger>(chooserBubbleDelegate_->NumOptions()), | 339 return std::max( |
| 339 static_cast<NSInteger>(1)); | 340 static_cast<NSInteger>(chooserBubbleController_->NumOptions()), |
| 341 static_cast<NSInteger>(1)); |
| 340 } | 342 } |
| 341 | 343 |
| 342 - (id)tableView:(NSTableView*)tableView | 344 - (id)tableView:(NSTableView*)tableView |
| 343 objectValueForTableColumn:(NSTableColumn*)tableColumn | 345 objectValueForTableColumn:(NSTableColumn*)tableColumn |
| 344 row:(NSInteger)rowIndex { | 346 row:(NSInteger)rowIndex { |
| 345 NSInteger num_options = | 347 NSInteger num_options = |
| 346 static_cast<NSInteger>(chooserBubbleDelegate_->NumOptions()); | 348 static_cast<NSInteger>(chooserBubbleController_->NumOptions()); |
| 347 if (num_options == 0) { | 349 if (num_options == 0) { |
| 348 DCHECK_EQ(0, rowIndex); | 350 DCHECK_EQ(0, rowIndex); |
| 349 return l10n_util::GetNSString(IDS_CHOOSER_BUBBLE_NO_DEVICES_FOUND_PROMPT); | 351 return l10n_util::GetNSString(IDS_CHOOSER_BUBBLE_NO_DEVICES_FOUND_PROMPT); |
| 350 } | 352 } |
| 351 | 353 |
| 352 DCHECK_GE(rowIndex, 0); | 354 DCHECK_GE(rowIndex, 0); |
| 353 DCHECK_LT(rowIndex, num_options); | 355 DCHECK_LT(rowIndex, num_options); |
| 354 return base::SysUTF16ToNSString( | 356 return base::SysUTF16ToNSString( |
| 355 chooserBubbleDelegate_->GetOption(static_cast<size_t>(rowIndex))); | 357 chooserBubbleController_->GetOption(static_cast<size_t>(rowIndex))); |
| 356 } | 358 } |
| 357 | 359 |
| 358 - (BOOL)tableView:(NSTableView*)aTableView | 360 - (BOOL)tableView:(NSTableView*)aTableView |
| 359 shouldEditTableColumn:(NSTableColumn*)aTableColumn | 361 shouldEditTableColumn:(NSTableColumn*)aTableColumn |
| 360 row:(NSInteger)rowIndex { | 362 row:(NSInteger)rowIndex { |
| 361 return NO; | 363 return NO; |
| 362 } | 364 } |
| 363 | 365 |
| 364 - (void)onOptionsInitialized { | 366 - (void)onOptionsInitialized { |
| 365 [self updateTableView]; | 367 [self updateTableView]; |
| 366 } | 368 } |
| 367 | 369 |
| 368 - (void)onOptionAdded:(NSInteger)index { | 370 - (void)onOptionAdded:(NSInteger)index { |
| 369 [self updateTableView]; | 371 [self updateTableView]; |
| 370 } | 372 } |
| 371 | 373 |
| 372 - (void)onOptionRemoved:(NSInteger)index { | 374 - (void)onOptionRemoved:(NSInteger)index { |
| 373 // |tableView_| will automatically selects the next item if the current | 375 // |tableView_| will automatically selects the next item if the current |
| 374 // item is removed, so here it tracks if the removed item is the item | 376 // item is removed, so here it tracks if the removed item is the item |
| 375 // that was previously selected, if so, deselect it. | 377 // that was previously selected, if so, deselect it. |
| 376 if ([tableView_ selectedRow] == index) | 378 if ([tableView_ selectedRow] == index) |
| 377 [tableView_ deselectRow:index]; | 379 [tableView_ deselectRow:index]; |
| 378 | 380 |
| 379 [self updateTableView]; | 381 [self updateTableView]; |
| 380 } | 382 } |
| 381 | 383 |
| 382 - (void)updateTableView { | 384 - (void)updateTableView { |
| 383 [tableView_ setEnabled:chooserBubbleDelegate_->NumOptions() > 0]; | 385 [tableView_ setEnabled:chooserBubbleController_->NumOptions() > 0]; |
| 384 [tableView_ reloadData]; | 386 [tableView_ reloadData]; |
| 385 } | 387 } |
| 386 | 388 |
| 387 - (void)tableViewSelectionDidChange:(NSNotification*)aNotification { | 389 - (void)tableViewSelectionDidChange:(NSNotification*)aNotification { |
| 388 [connectButton_ setEnabled:[tableView_ numberOfSelectedRows] > 0]; | 390 [connectButton_ setEnabled:[tableView_ numberOfSelectedRows] > 0]; |
| 389 } | 391 } |
| 390 | 392 |
| 391 - (void)updateAnchorPosition { | 393 - (void)updateAnchorPosition { |
| 392 [self setParentWindow:[self getExpectedParentWindow]]; | 394 [self setParentWindow:[self getExpectedParentWindow]]; |
| 393 [self setAnchorPoint:[self getExpectedAnchorPoint]]; | 395 [self setAnchorPoint:[self getExpectedAnchorPoint]]; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 l10n_util::GetStringUTF16(IDS_CHOOSER_BUBBLE_GET_HELP_LINK_TEXT); | 468 l10n_util::GetStringUTF16(IDS_CHOOSER_BUBBLE_GET_HELP_LINK_TEXT); |
| 467 | 469 |
| 468 NSString* text = | 470 NSString* text = |
| 469 l10n_util::GetNSStringF(IDS_CHOOSER_BUBBLE_FOOTNOTE_TEXT, linkString); | 471 l10n_util::GetNSStringF(IDS_CHOOSER_BUBBLE_FOOTNOTE_TEXT, linkString); |
| 470 [textView setMessage:text | 472 [textView setMessage:text |
| 471 withFont:[NSFont systemFontOfSize:[NSFont systemFontSize]] | 473 withFont:[NSFont systemFontOfSize:[NSFont systemFontSize]] |
| 472 messageColor:[NSColor blackColor]]; | 474 messageColor:[NSColor blackColor]]; |
| 473 | 475 |
| 474 NSColor* linkColor = | 476 NSColor* linkColor = |
| 475 skia::SkColorToCalibratedNSColor(chrome_style::GetLinkColor()); | 477 skia::SkColorToCalibratedNSColor(chrome_style::GetLinkColor()); |
| 476 [textView addLinkRange:NSMakeRange([text length] - linkString.size(), | 478 [textView |
| 477 linkString.size()) | 479 addLinkRange:NSMakeRange([text length] - linkString.size(), |
| 478 withURL:base::SysUTF8ToNSString( | 480 linkString.size()) |
| 479 chooserBubbleDelegate_->GetHelpCenterUrl().spec()) | 481 withURL:base::SysUTF8ToNSString( |
| 480 linkColor:linkColor]; | 482 chooserBubbleController_->GetHelpCenterUrl().spec()) |
| 483 linkColor:linkColor]; |
| 481 | 484 |
| 482 // Removes the underlining from the link. | 485 // Removes the underlining from the link. |
| 483 NSTextStorage* textStorage = [textView textStorage]; | 486 NSTextStorage* textStorage = [textView textStorage]; |
| 484 [textStorage addAttribute:NSUnderlineStyleAttributeName | 487 [textStorage addAttribute:NSUnderlineStyleAttributeName |
| 485 value:@(NSUnderlineStyleNone) | 488 value:@(NSUnderlineStyleNone) |
| 486 range:NSMakeRange(0, [text length])]; | 489 range:NSMakeRange(0, [text length])]; |
| 487 | 490 |
| 488 [textView setVerticallyResizable:YES]; | 491 [textView setVerticallyResizable:YES]; |
| 489 [textView | 492 [textView |
| 490 setFrameSize:NSMakeSize(kChooserBubbleWidth - 2 * kMarginX, MAXFLOAT)]; | 493 setFrameSize:NSMakeSize(kChooserBubbleWidth - 2 * kMarginX, MAXFLOAT)]; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 506 NSRect frameA = [viewA frame]; | 509 NSRect frameA = [viewA frame]; |
| 507 NSRect frameB = [viewB frame]; | 510 NSRect frameB = [viewB frame]; |
| 508 frameA.origin.y = | 511 frameA.origin.y = |
| 509 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); | 512 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); |
| 510 [viewA setFrameOrigin:frameA.origin]; | 513 [viewA setFrameOrigin:frameA.origin]; |
| 511 } | 514 } |
| 512 | 515 |
| 513 - (void)onConnect:(id)sender { | 516 - (void)onConnect:(id)sender { |
| 514 buttonPressed_ = true; | 517 buttonPressed_ = true; |
| 515 NSInteger row = [tableView_ selectedRow]; | 518 NSInteger row = [tableView_ selectedRow]; |
| 516 chooserBubbleDelegate_->Select(row); | 519 chooserBubbleController_->Select(row); |
| 517 [self close]; | 520 [self close]; |
| 518 } | 521 } |
| 519 | 522 |
| 520 - (void)onCancel:(id)sender { | 523 - (void)onCancel:(id)sender { |
| 521 buttonPressed_ = true; | 524 buttonPressed_ = true; |
| 522 chooserBubbleDelegate_->Cancel(); | 525 chooserBubbleController_->Cancel(); |
| 523 [self close]; | 526 [self close]; |
| 524 } | 527 } |
| 525 | 528 |
| 526 @end | 529 @end |
| 527 | 530 |
| 528 ChooserBubbleUiCocoa::ChooserBubbleUiCocoa( | 531 ChooserBubbleUiCocoa::ChooserBubbleUiCocoa( |
| 529 Browser* browser, | 532 Browser* browser, |
| 530 ChooserBubbleDelegate* chooser_bubble_delegate) | 533 ChooserBubbleController* chooser_bubble_controller) |
| 531 : browser_(browser), | 534 : browser_(browser), |
| 532 chooser_bubble_delegate_(chooser_bubble_delegate), | 535 chooser_bubble_controller_(chooser_bubble_controller), |
| 533 chooser_bubble_ui_controller_(nil) { | 536 chooser_bubble_ui_controller_(nil) { |
| 534 DCHECK(browser); | 537 DCHECK(browser); |
| 535 DCHECK(chooser_bubble_delegate); | 538 DCHECK(chooser_bubble_controller); |
| 536 chooser_bubble_delegate_->set_observer(this); | 539 chooser_bubble_controller_->set_observer(this); |
| 537 } | 540 } |
| 538 | 541 |
| 539 ChooserBubbleUiCocoa::~ChooserBubbleUiCocoa() { | 542 ChooserBubbleUiCocoa::~ChooserBubbleUiCocoa() { |
| 540 chooser_bubble_delegate_->set_observer(nullptr); | 543 chooser_bubble_controller_->set_observer(nullptr); |
| 541 [chooser_bubble_ui_controller_ close]; | 544 [chooser_bubble_ui_controller_ close]; |
| 542 chooser_bubble_ui_controller_ = nil; | 545 chooser_bubble_ui_controller_ = nil; |
| 543 } | 546 } |
| 544 | 547 |
| 545 void ChooserBubbleUiCocoa::Show(BubbleReference bubble_reference) { | 548 void ChooserBubbleUiCocoa::Show(BubbleReference bubble_reference) { |
| 546 if (!chooser_bubble_ui_controller_) { | 549 if (!chooser_bubble_ui_controller_) { |
| 547 chooser_bubble_ui_controller_ = [[ChooserBubbleUiController alloc] | 550 chooser_bubble_ui_controller_ = [[ChooserBubbleUiController alloc] |
| 548 initWithBrowser:browser_ | 551 initWithBrowser:browser_ |
| 549 initWithChooserBubbleDelegate:chooser_bubble_delegate_ | 552 initWithChooserBubbleController:chooser_bubble_controller_ |
| 550 bridge:this]; | 553 bridge:this]; |
| 551 } | 554 } |
| 552 | 555 |
| 553 [chooser_bubble_ui_controller_ show]; | 556 [chooser_bubble_ui_controller_ show]; |
| 554 [chooser_bubble_ui_controller_ updateTableView]; | 557 [chooser_bubble_ui_controller_ updateTableView]; |
| 555 } | 558 } |
| 556 | 559 |
| 557 void ChooserBubbleUiCocoa::Close() { | 560 void ChooserBubbleUiCocoa::Close() { |
| 558 [chooser_bubble_ui_controller_ close]; | 561 [chooser_bubble_ui_controller_ close]; |
| 559 chooser_bubble_ui_controller_ = nil; | 562 chooser_bubble_ui_controller_ = nil; |
| 560 } | 563 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 571 [chooser_bubble_ui_controller_ onOptionAdded:static_cast<NSInteger>(index)]; | 574 [chooser_bubble_ui_controller_ onOptionAdded:static_cast<NSInteger>(index)]; |
| 572 } | 575 } |
| 573 | 576 |
| 574 void ChooserBubbleUiCocoa::OnOptionRemoved(size_t index) { | 577 void ChooserBubbleUiCocoa::OnOptionRemoved(size_t index) { |
| 575 [chooser_bubble_ui_controller_ onOptionRemoved:static_cast<NSInteger>(index)]; | 578 [chooser_bubble_ui_controller_ onOptionRemoved:static_cast<NSInteger>(index)]; |
| 576 } | 579 } |
| 577 | 580 |
| 578 void ChooserBubbleUiCocoa::OnBubbleClosing() { | 581 void ChooserBubbleUiCocoa::OnBubbleClosing() { |
| 579 chooser_bubble_ui_controller_ = nil; | 582 chooser_bubble_ui_controller_ = nil; |
| 580 } | 583 } |
| OLD | NEW |