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

Side by Side Diff: chrome/browser/ui/cocoa/chooser_content_view_cocoa.mm

Issue 2390823005: Update device permissions dialog ui for Chrome apps and extensions (Closed)
Patch Set: address more comments Created 4 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
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/chooser_content_view_cocoa.h" 5 #import "chrome/browser/ui/cocoa/chooser_content_view_cocoa.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 CGFloat connectButtonHeight = NSHeight([connectButton_ frame]); 445 CGFloat connectButtonHeight = NSHeight([connectButton_ frame]);
446 446
447 // Cancel button. 447 // Cancel button.
448 cancelButton_ = [self createCancelButton]; 448 cancelButton_ = [self createCancelButton];
449 CGFloat cancelButtonWidth = NSWidth([cancelButton_ frame]); 449 CGFloat cancelButtonWidth = NSWidth([cancelButton_ frame]);
450 450
451 // Separator. 451 // Separator.
452 separator_ = [self createSeparator]; 452 separator_ = [self createSeparator];
453 453
454 // Help button. 454 // Help button.
455 helpButton_ = 455 CGFloat helpButtonWidth = 0.0f;
456 [self createHyperlinkButtonWithText: 456 CGFloat helpButtonHeight = 0.0f;
457 l10n_util::GetNSStringF( 457 if (chooserController_->ShouldShowFootnoteView()) {
458 IDS_DEVICE_CHOOSER_GET_HELP_LINK_WITH_SCANNING_STATUS, 458 helpButton_ =
459 base::string16())]; 459 [self createHyperlinkButtonWithText:
460 CGFloat helpButtonWidth = NSWidth([helpButton_ frame]); 460 l10n_util::GetNSStringF(
461 CGFloat helpButtonHeight = NSHeight([helpButton_ frame]); 461 IDS_DEVICE_CHOOSER_GET_HELP_LINK_WITH_SCANNING_STATUS,
462 base::string16())];
463 helpButtonWidth = NSWidth([helpButton_ frame]);
464 helpButtonHeight = NSHeight([helpButton_ frame]);
465 }
462 466
463 // Scanning message. 467 // Scanning message.
464 scanningMessage_ = CreateLabel( 468 scanningMessage_ = CreateLabel(
465 l10n_util::GetNSString(IDS_BLUETOOTH_DEVICE_CHOOSER_SCANNING)); 469 l10n_util::GetNSString(IDS_BLUETOOTH_DEVICE_CHOOSER_SCANNING));
466 470
467 // Word connector. 471 // Word connector.
468 wordConnector_ = CreateLabel(l10n_util::GetNSStringF( 472 wordConnector_ = CreateLabel(l10n_util::GetNSStringF(
469 IDS_DEVICE_CHOOSER_GET_HELP_LINK_WITH_RE_SCAN_LINK, base::string16(), 473 IDS_DEVICE_CHOOSER_GET_HELP_LINK_WITH_RE_SCAN_LINK, base::string16(),
470 base::string16())); 474 base::string16()));
471 CGFloat wordConnectorWidth = NSWidth([wordConnector_ frame]); 475 CGFloat wordConnectorWidth = NSWidth([wordConnector_ frame]);
472 476
473 // Re-scan button. 477 // Re-scan button.
474 rescanButton_ = 478 rescanButton_ =
475 [self createHyperlinkButtonWithText: 479 [self createHyperlinkButtonWithText:
476 l10n_util::GetNSString(IDS_BLUETOOTH_DEVICE_CHOOSER_RE_SCAN)]; 480 l10n_util::GetNSString(IDS_BLUETOOTH_DEVICE_CHOOSER_RE_SCAN)];
477 481
478 // ScollView embedding with TableView. 482 // ScollView embedding with TableView.
479 CGFloat scrollViewWidth = kChooserWidth - 2 * kMarginX; 483 CGFloat scrollViewWidth = kChooserWidth - 2 * kMarginX;
480 CGFloat scrollViewHeight = kChooserHeight - 2 * kMarginY - 484 CGFloat scrollViewHeight =
481 4 * kVerticalPadding - titleHeight - 485 kChooserHeight - 2 * kMarginY -
482 connectButtonHeight - helpButtonHeight; 486 (chooserController_->ShouldShowFootnoteView() ? 4 * kVerticalPadding
487 : 2 * kVerticalPadding) -
488 titleHeight - connectButtonHeight - helpButtonHeight;
483 CGFloat scrollViewOriginX = kMarginX; 489 CGFloat scrollViewOriginX = kMarginX;
484 CGFloat scrollViewOriginY = kMarginY + helpButtonHeight + 490 CGFloat scrollViewOriginY =
485 3 * kVerticalPadding + connectButtonHeight; 491 kMarginY + helpButtonHeight +
492 (chooserController_->ShouldShowFootnoteView() ? 3 * kVerticalPadding
493 : kVerticalPadding) +
494 connectButtonHeight;
486 NSRect scrollFrame = NSMakeRect(scrollViewOriginX, scrollViewOriginY, 495 NSRect scrollFrame = NSMakeRect(scrollViewOriginX, scrollViewOriginY,
487 scrollViewWidth, scrollViewHeight); 496 scrollViewWidth, scrollViewHeight);
488 scrollView_.reset([[NSScrollView alloc] initWithFrame:scrollFrame]); 497 scrollView_.reset([[NSScrollView alloc] initWithFrame:scrollFrame]);
489 [scrollView_ setBorderType:NSBezelBorder]; 498 [scrollView_ setBorderType:NSBezelBorder];
490 [scrollView_ setHasVerticalScroller:YES]; 499 [scrollView_ setHasVerticalScroller:YES];
491 [scrollView_ setHasHorizontalScroller:YES]; 500 [scrollView_ setHasHorizontalScroller:YES];
492 [scrollView_ setAutohidesScrollers:YES]; 501 [scrollView_ setAutohidesScrollers:YES];
493 [scrollView_ setDrawsBackground:NO]; 502 [scrollView_ setDrawsBackground:NO];
494 503
495 // TableView. 504 // TableView.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 [scrollView_ setDocumentView:tableView_]; 558 [scrollView_ setDocumentView:tableView_];
550 [self addSubview:scrollView_]; 559 [self addSubview:scrollView_];
551 [spinner_ setHidden:YES]; 560 [spinner_ setHidden:YES];
552 [self addSubview:spinner_]; 561 [self addSubview:spinner_];
553 562
554 // Connect button. 563 // Connect button.
555 CGFloat connectButtonOriginX = kChooserWidth - kMarginX - 564 CGFloat connectButtonOriginX = kChooserWidth - kMarginX -
556 kHorizontalPadding - connectButtonWidth - 565 kHorizontalPadding - connectButtonWidth -
557 cancelButtonWidth; 566 cancelButtonWidth;
558 CGFloat connectButtonOriginY = 567 CGFloat connectButtonOriginY =
559 kMarginY + helpButtonHeight + 2 * kVerticalPadding; 568 kMarginY + helpButtonHeight +
569 (chooserController_->ShouldShowFootnoteView() ? 2 * kVerticalPadding
570 : 0.0f);
560 [connectButton_ 571 [connectButton_
561 setFrameOrigin:NSMakePoint(connectButtonOriginX, connectButtonOriginY)]; 572 setFrameOrigin:NSMakePoint(connectButtonOriginX, connectButtonOriginY)];
562 [connectButton_ setEnabled:NO]; 573 [connectButton_ setEnabled:NO];
563 [self addSubview:connectButton_]; 574 [self addSubview:connectButton_];
564 575
565 // Cancel button. 576 // Cancel button.
566 CGFloat cancelButtonOriginX = kChooserWidth - kMarginX - cancelButtonWidth; 577 CGFloat cancelButtonOriginX = kChooserWidth - kMarginX - cancelButtonWidth;
567 CGFloat cancelButtonOriginY = connectButtonOriginY; 578 CGFloat cancelButtonOriginY = connectButtonOriginY;
568 [cancelButton_ 579 [cancelButton_
569 setFrameOrigin:NSMakePoint(cancelButtonOriginX, cancelButtonOriginY)]; 580 setFrameOrigin:NSMakePoint(cancelButtonOriginX, cancelButtonOriginY)];
570 [self addSubview:cancelButton_]; 581 [self addSubview:cancelButton_];
571 582
572 // Separator. 583 if (chooserController_->ShouldShowFootnoteView()) {
573 CGFloat separatorOriginX = 0.0f; 584 // Separator.
574 separatorOriginY_ = kMarginY + helpButtonHeight + kVerticalPadding; 585 CGFloat separatorOriginX = 0.0f;
575 [separator_ 586 separatorOriginY_ = kMarginY + helpButtonHeight + kVerticalPadding;
576 setFrameOrigin:NSMakePoint(separatorOriginX, separatorOriginY_)]; 587 [separator_
577 [self addSubview:separator_]; 588 setFrameOrigin:NSMakePoint(separatorOriginX, separatorOriginY_)];
589 [self addSubview:separator_];
578 590
579 // Help button. 591 // Help button.
580 CGFloat helpButtonOriginX = kMarginX; 592 CGFloat helpButtonOriginX = kMarginX;
581 CGFloat helpButtonOriginY = (kVerticalPadding + kMarginY) / 2; 593 CGFloat helpButtonOriginY = (kVerticalPadding + kMarginY) / 2;
582 [helpButton_ 594 [helpButton_
583 setFrameOrigin:NSMakePoint(helpButtonOriginX, helpButtonOriginY)]; 595 setFrameOrigin:NSMakePoint(helpButtonOriginX, helpButtonOriginY)];
584 [helpButton_ setTarget:self]; 596 [helpButton_ setTarget:self];
585 [helpButton_ setAction:@selector(onHelpPressed:)]; 597 [helpButton_ setAction:@selector(onHelpPressed:)];
586 [self addSubview:helpButton_]; 598 [self addSubview:helpButton_];
587 599
588 // Scanning message. 600 // Scanning message.
589 CGFloat scanningMessageOriginX = 601 CGFloat scanningMessageOriginX =
590 kMarginX + helpButtonWidth - kHorizontalPadding / 2; 602 kMarginX + helpButtonWidth - kHorizontalPadding / 2;
591 CGFloat scanningMessageOriginY = helpButtonOriginY; 603 CGFloat scanningMessageOriginY = helpButtonOriginY;
592 [scanningMessage_ setFrameOrigin:NSMakePoint(scanningMessageOriginX, 604 [scanningMessage_ setFrameOrigin:NSMakePoint(scanningMessageOriginX,
593 scanningMessageOriginY)]; 605 scanningMessageOriginY)];
594 [self addSubview:scanningMessage_]; 606 [self addSubview:scanningMessage_];
595 [scanningMessage_ setHidden:YES]; 607 [scanningMessage_ setHidden:YES];
596 608
597 // Word connector. 609 // Word connector.
598 CGFloat wordConnectorOriginX = 610 CGFloat wordConnectorOriginX =
599 kMarginX + helpButtonWidth - kHorizontalPadding / 2; 611 kMarginX + helpButtonWidth - kHorizontalPadding / 2;
600 CGFloat wordConnectorOriginY = helpButtonOriginY; 612 CGFloat wordConnectorOriginY = helpButtonOriginY;
601 [wordConnector_ 613 [wordConnector_ setFrameOrigin:NSMakePoint(wordConnectorOriginX,
602 setFrameOrigin:NSMakePoint(wordConnectorOriginX, wordConnectorOriginY)]; 614 wordConnectorOriginY)];
603 [self addSubview:wordConnector_]; 615 [self addSubview:wordConnector_];
604 [wordConnector_ setHidden:YES]; 616 [wordConnector_ setHidden:YES];
605 617
606 // Re-scan button. 618 // Re-scan button.
607 CGFloat reScanButtonOriginX = 619 CGFloat reScanButtonOriginX =
608 kMarginX + helpButtonWidth + wordConnectorWidth - kHorizontalPadding; 620 kMarginX + helpButtonWidth + wordConnectorWidth - kHorizontalPadding;
609 CGFloat reScanButtonOriginY = helpButtonOriginY; 621 CGFloat reScanButtonOriginY = helpButtonOriginY;
610 [rescanButton_ 622 [rescanButton_
611 setFrameOrigin:NSMakePoint(reScanButtonOriginX, reScanButtonOriginY)]; 623 setFrameOrigin:NSMakePoint(reScanButtonOriginX, reScanButtonOriginY)];
612 [rescanButton_ setTarget:self]; 624 [rescanButton_ setTarget:self];
613 [rescanButton_ setAction:@selector(onRescan:)]; 625 [rescanButton_ setAction:@selector(onRescan:)];
614 [self addSubview:rescanButton_]; 626 [self addSubview:rescanButton_];
615 [rescanButton_ setHidden:YES]; 627 [rescanButton_ setHidden:YES];
628 }
616 629
617 chooserContentViewController_.reset(new ChooserContentViewController( 630 chooserContentViewController_.reset(new ChooserContentViewController(
618 chooserController_.get(), adapterOffHelpButton_.get(), 631 chooserController_.get(), adapterOffHelpButton_.get(),
619 adapterOffMessage_.get(), tableView_.get(), spinner_.get(), 632 adapterOffMessage_.get(), tableView_.get(), spinner_.get(),
620 scanningMessage_.get(), wordConnector_.get(), rescanButton_.get())); 633 scanningMessage_.get(), wordConnector_.get(), rescanButton_.get()));
621 } 634 }
622 635
623 return self; 636 return self;
624 } 637 }
625 638
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 904
892 - (void)drawRect:(NSRect)rect { 905 - (void)drawRect:(NSRect)rect {
893 [[NSColor colorWithCalibratedWhite:245.0f / 255.0f alpha:1.0f] setFill]; 906 [[NSColor colorWithCalibratedWhite:245.0f / 255.0f alpha:1.0f] setFill];
894 NSRect footnoteFrame = 907 NSRect footnoteFrame =
895 NSMakeRect(0.0f, 0.0f, kChooserWidth, separatorOriginY_); 908 NSMakeRect(0.0f, 0.0f, kChooserWidth, separatorOriginY_);
896 NSRectFill(footnoteFrame); 909 NSRectFill(footnoteFrame);
897 [super drawRect:footnoteFrame]; 910 [super drawRect:footnoteFrame];
898 } 911 }
899 912
900 @end 913 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698