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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/extension_install_view_controller.mm

Issue 2716353003: [Extensions UI] Initially disabled OK button for extension install prompts. (Closed)
Patch Set: Fixing grammar in comments. Created 3 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/extension_install_view_controller.h" 5 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // it. 90 // it.
91 const CGFloat kWarningsSeparatorPadding = 14; 91 const CGFloat kWarningsSeparatorPadding = 14;
92 92
93 // The left padding for the link cell. 93 // The left padding for the link cell.
94 const CGFloat kLinkCellPaddingLeft = 3; 94 const CGFloat kLinkCellPaddingLeft = 3;
95 95
96 // Maximum height we will adjust controls to when trying to accomodate their 96 // Maximum height we will adjust controls to when trying to accomodate their
97 // contents. 97 // contents.
98 const CGFloat kMaxControlHeight = 250; 98 const CGFloat kMaxControlHeight = 250;
99 99
100 // Time delay before the install button is enabled after initial display.
101 NSTimeInterval g_install_delay_in_s = 0.5;
Avi (use Gerrit) 2017/03/23 02:32:33 camelcase. No "in s".
Ackerman 2017/03/31 22:03:21 Noted.
102
100 NSString* const kTitleKey = @"title"; 103 NSString* const kTitleKey = @"title";
101 NSString* const kChildrenKey = @"children"; 104 NSString* const kChildrenKey = @"children";
102 NSString* const kCellAttributesKey = @"cellAttributes"; 105 NSString* const kCellAttributesKey = @"cellAttributes";
103 NSString* const kPermissionsDetailIndex = @"permissionsDetailIndex"; 106 NSString* const kPermissionsDetailIndex = @"permissionsDetailIndex";
104 NSString* const kPermissionsDetailType = @"permissionsDetailType"; 107 NSString* const kPermissionsDetailType = @"permissionsDetailType";
105 108
106 // Computes the |control|'s desired height to fit its contents, constrained to 109 // Computes the |control|'s desired height to fit its contents, constrained to
107 // be kMaxControlHeight at most. 110 // be kMaxControlHeight at most.
108 CGFloat ComputeDesiredControlHeight(NSControl* control) { 111 CGFloat ComputeDesiredControlHeight(NSControl* control) {
109 NSRect rect = [control frame]; 112 NSRect rect = [control frame];
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 [[outlineView_ enclosingScrollView] setHidden:YES]; 380 [[outlineView_ enclosingScrollView] setHidden:YES];
378 totalOffset -= NSHeight(hiddenRect) + kWarningsSeparatorPadding; 381 totalOffset -= NSHeight(hiddenRect) + kWarningsSeparatorPadding;
379 } 382 }
380 383
381 // If necessary, adjust the window size. 384 // If necessary, adjust the window size.
382 if (totalOffset) { 385 if (totalOffset) {
383 NSRect currentRect = [[self view] bounds]; 386 NSRect currentRect = [[self view] bounds];
384 currentRect.size.height += totalOffset; 387 currentRect.size.height += totalOffset;
385 [self updateViewFrame:currentRect]; 388 [self updateViewFrame:currentRect];
386 } 389 }
390
391 // Default state of install button is disabled and then enabled after a short
392 // time delay.
393 [okButton_ setEnabled:NO];
394 [self startTimerToEnableInstall];
Devlin 2017/03/23 01:25:29 I'm a little worried that we start this at constru
Ackerman 2017/03/31 22:03:21 Noted. This will require a little work, so I'm goi
387 } 395 }
388 396
389 - (BOOL)hasWebstoreData { 397 - (BOOL)hasWebstoreData {
390 return prompt_->has_webstore_data(); 398 return prompt_->has_webstore_data();
391 } 399 }
392 400
393 - (void)appendRatingStar:(const gfx::ImageSkia*)skiaImage { 401 - (void)appendRatingStar:(const gfx::ImageSkia*)skiaImage {
394 NSImage* image = gfx::NSImageFromImageSkiaWithColorSpace( 402 NSImage* image = gfx::NSImageFromImageSkiaWithColorSpace(
395 *skiaImage, base::mac::GetSystemColorSpace()); 403 *skiaImage, base::mac::GetSystemColorSpace());
396 NSRect frame = NSMakeRect(0, 0, skiaImage->width(), skiaImage->height()); 404 NSRect frame = NSMakeRect(0, 0, skiaImage->width(), skiaImage->height());
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 777
770 return SysUTF16ToNSString(prompt.GetPermissionsHeading(type)); 778 return SysUTF16ToNSString(prompt.GetPermissionsHeading(type));
771 } 779 }
772 780
773 - (void)updateViewFrame:(NSRect)frame { 781 - (void)updateViewFrame:(NSRect)frame {
774 NSWindow* window = [[self view] window]; 782 NSWindow* window = [[self view] window];
775 [window setFrame:[window frameRectForContentRect:frame] display:YES]; 783 [window setFrame:[window frameRectForContentRect:frame] display:YES];
776 [[self view] setFrame:frame]; 784 [[self view] setFrame:frame];
777 } 785 }
778 786
787 - (void)startTimerToEnableInstall {
788 [NSTimer scheduledTimerWithTimeInterval:g_install_delay_in_s
Devlin 2017/03/23 01:25:29 nit: maybe just inline this method
Ackerman 2017/03/31 22:03:21 Noted.
789 target:self
790 selector:@selector(enableInstall:)
791 userInfo:nil
792 repeats:NO];
793 }
794
795 - (void)enableInstall:(NSTimer*)timer {
796 [okButton_ setEnabled:YES];
797 }
798
799 + (void)setInstallDelayForTesting:(NSTimeInterval)time_delay_in_s {
800 g_install_delay_in_s = time_delay_in_s;
801 }
802
779 @end 803 @end
780 804
781 805
782 @implementation DetailToggleHyperlinkButtonCell 806 @implementation DetailToggleHyperlinkButtonCell
783 807
784 @synthesize permissionsDetailIndex = permissionsDetailIndex_; 808 @synthesize permissionsDetailIndex = permissionsDetailIndex_;
785 @synthesize permissionsDetailType = permissionsDetailType_; 809 @synthesize permissionsDetailType = permissionsDetailType_;
786 @synthesize linkClickedAction = linkClickedAction_; 810 @synthesize linkClickedAction = linkClickedAction_;
787 811
788 + (BOOL)prefersTrackingUntilMouseUp { 812 + (BOOL)prefersTrackingUntilMouseUp {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 } 862 }
839 863
840 - (void)accessibilityPerformAction:(NSString*)action { 864 - (void)accessibilityPerformAction:(NSString*)action {
841 if ([action isEqualToString:NSAccessibilityPressAction]) 865 if ([action isEqualToString:NSAccessibilityPressAction])
842 [self handleLinkClicked]; 866 [self handleLinkClicked];
843 else 867 else
844 [super accessibilityPerformAction:action]; 868 [super accessibilityPerformAction:action];
845 } 869 }
846 870
847 @end 871 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698