| OLD | NEW |
| 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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 prompt:(scoped_refptr<ExtensionInstallPrompt::Prompt>)prompt { | 184 prompt:(scoped_refptr<ExtensionInstallPrompt::Prompt>)prompt { |
| 185 // We use a different XIB in the case of bundle installs, installs with | 185 // We use a different XIB in the case of bundle installs, installs with |
| 186 // webstore data, or no permission warnings. These are laid out nicely for | 186 // webstore data, or no permission warnings. These are laid out nicely for |
| 187 // the data they display. | 187 // the data they display. |
| 188 NSString* nibName = nil; | 188 NSString* nibName = nil; |
| 189 if (prompt->type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT) { | 189 if (prompt->type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT) { |
| 190 nibName = @"ExtensionInstallPromptBundle"; | 190 nibName = @"ExtensionInstallPromptBundle"; |
| 191 } else if (prompt->has_webstore_data()) { | 191 } else if (prompt->has_webstore_data()) { |
| 192 nibName = @"ExtensionInstallPromptWebstoreData"; | 192 nibName = @"ExtensionInstallPromptWebstoreData"; |
| 193 } else if (!prompt->ShouldShowPermissions() && | 193 } else if (!prompt->ShouldShowPermissions() && |
| 194 prompt->GetRetainedFileCount() == 0) { | 194 prompt->GetRetainedFileCount() == 0 && |
| 195 prompt->GetRetainedDeviceCount() == 0) { |
| 195 nibName = @"ExtensionInstallPromptNoWarnings"; | 196 nibName = @"ExtensionInstallPromptNoWarnings"; |
| 196 } else { | 197 } else { |
| 197 nibName = @"ExtensionInstallPrompt"; | 198 nibName = @"ExtensionInstallPrompt"; |
| 198 } | 199 } |
| 199 | 200 |
| 200 if ((self = [super initWithNibName:nibName | 201 if ((self = [super initWithNibName:nibName |
| 201 bundle:base::mac::FrameworkBundle()])) { | 202 bundle:base::mac::FrameworkBundle()])) { |
| 202 navigator_ = navigator; | 203 navigator_ = navigator; |
| 203 delegate_ = delegate; | 204 delegate_ = delegate; |
| 204 prompt_ = prompt; | 205 prompt_ = prompt; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 [joinedItems appendString:@"\n"]; | 302 [joinedItems appendString:@"\n"]; |
| 302 [joinedItems appendString:base::SysUTF16ToNSString( | 303 [joinedItems appendString:base::SysUTF16ToNSString( |
| 303 items[i].GetNameForDisplay())]; | 304 items[i].GetNameForDisplay())]; |
| 304 } | 305 } |
| 305 [itemsField_ setStringValue:joinedItems]; | 306 [itemsField_ setStringValue:joinedItems]; |
| 306 | 307 |
| 307 // Adjust the controls to fit the list of extensions. | 308 // Adjust the controls to fit the list of extensions. |
| 308 OffsetControlVerticallyToFitContent(itemsField_, &totalOffset); | 309 OffsetControlVerticallyToFitContent(itemsField_, &totalOffset); |
| 309 } | 310 } |
| 310 | 311 |
| 311 // If there are any warnings or retained files, then we have to do | 312 // If there are any warnings, retained devices or retained files, then we |
| 312 // some special layout. | 313 // have to do some special layout. |
| 313 if (prompt_->ShouldShowPermissions() || prompt_->GetRetainedFileCount() > 0) { | 314 if (prompt_->ShouldShowPermissions() || prompt_->GetRetainedFileCount() > 0) { |
| 314 NSSize spacing = [outlineView_ intercellSpacing]; | 315 NSSize spacing = [outlineView_ intercellSpacing]; |
| 315 spacing.width += 2; | 316 spacing.width += 2; |
| 316 spacing.height += 2; | 317 spacing.height += 2; |
| 317 [outlineView_ setIntercellSpacing:spacing]; | 318 [outlineView_ setIntercellSpacing:spacing]; |
| 318 [[[[outlineView_ tableColumns] objectAtIndex:0] dataCell] setWraps:YES]; | 319 [[[[outlineView_ tableColumns] objectAtIndex:0] dataCell] setWraps:YES]; |
| 319 for (id item in warnings_.get()) | 320 for (id item in warnings_.get()) |
| 320 [self expandItemAndChildren:item]; | 321 [self expandItemAndChildren:item]; |
| 321 | 322 |
| 322 // Adjust the outline view to fit the warnings. | 323 // Adjust the outline view to fit the warnings. |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 children:children]]; | 639 children:children]]; |
| 639 } | 640 } |
| 640 | 641 |
| 641 if (prompt.GetRetainedFileCount() > 0) { | 642 if (prompt.GetRetainedFileCount() > 0) { |
| 642 type = ExtensionInstallPrompt::RETAINED_FILES_DETAILS; | 643 type = ExtensionInstallPrompt::RETAINED_FILES_DETAILS; |
| 643 | 644 |
| 644 NSMutableArray* children = [NSMutableArray array]; | 645 NSMutableArray* children = [NSMutableArray array]; |
| 645 | 646 |
| 646 if (prompt.GetIsShowingDetails(type, 0)) { | 647 if (prompt.GetIsShowingDetails(type, 0)) { |
| 647 for (size_t i = 0; i < prompt.GetRetainedFileCount(); ++i) { | 648 for (size_t i = 0; i < prompt.GetRetainedFileCount(); ++i) { |
| 648 [children addObject: | 649 NSString* title = SysUTF16ToNSString(prompt.GetRetainedFile(i)); |
| 649 [self buildItemWithTitle:SysUTF16ToNSString( | 650 [children addObject:[self buildItemWithTitle:title |
| 650 prompt.GetRetainedFile(i)) | 651 cellAttributes:kUseBullet |
| 651 cellAttributes:kUseBullet | 652 children:nil]]; |
| 652 children:nil]]; | |
| 653 } | 653 } |
| 654 } | 654 } |
| 655 | 655 |
| 656 [warnings addObject: | 656 NSString* title = SysUTF16ToNSString(prompt.GetRetainedFilesHeading()); |
| 657 [self buildItemWithTitle:SysUTF16ToNSString( | 657 [warnings addObject:[self buildItemWithTitle:title |
| 658 prompt.GetRetainedFilesHeading()) | 658 cellAttributes:kBoldText | kAutoExpandCell | |
| 659 cellAttributes:kBoldText | kAutoExpandCell | kNoExpandMarker | 659 kNoExpandMarker |
| 660 children:children]]; | 660 children:children]]; |
| 661 | 661 |
| 662 // Add a row for the link. | 662 // Add a row for the link. |
| 663 [warnings addObject: | 663 [warnings addObject: |
| 664 [self buildDetailToggleItem:type permissionsDetailIndex:0]]; | 664 [self buildDetailToggleItem:type permissionsDetailIndex:0]]; |
| 665 } | 665 } |
| 666 | 666 |
| 667 if (prompt.GetRetainedDeviceCount() > 0) { |
| 668 type = ExtensionInstallPrompt::RETAINED_DEVICES_DETAILS; |
| 669 |
| 670 NSMutableArray* children = [NSMutableArray array]; |
| 671 |
| 672 if (prompt.GetIsShowingDetails(type, 0)) { |
| 673 for (size_t i = 0; i < prompt.GetRetainedDeviceCount(); ++i) { |
| 674 NSString* title = |
| 675 SysUTF16ToNSString(prompt.GetRetainedDeviceMessageString(i)); |
| 676 [children addObject:[self buildItemWithTitle:title |
| 677 cellAttributes:kUseBullet |
| 678 children:nil]]; |
| 679 } |
| 680 } |
| 681 |
| 682 NSString* title = SysUTF16ToNSString(prompt.GetRetainedDevicesHeading()); |
| 683 [warnings addObject:[self buildItemWithTitle:title |
| 684 cellAttributes:kBoldText | kAutoExpandCell | |
| 685 kNoExpandMarker |
| 686 children:children]]; |
| 687 |
| 688 // Add a row for the link. |
| 689 [warnings |
| 690 addObject:[self buildDetailToggleItem:type permissionsDetailIndex:0]]; |
| 691 } |
| 692 |
| 667 return warnings; | 693 return warnings; |
| 668 } | 694 } |
| 669 | 695 |
| 670 - (void)updateViewFrame:(NSRect)frame { | 696 - (void)updateViewFrame:(NSRect)frame { |
| 671 NSWindow* window = [[self view] window]; | 697 NSWindow* window = [[self view] window]; |
| 672 [window setFrame:[window frameRectForContentRect:frame] display:YES]; | 698 [window setFrame:[window frameRectForContentRect:frame] display:YES]; |
| 673 [[self view] setFrame:frame]; | 699 [[self view] setFrame:frame]; |
| 674 } | 700 } |
| 675 | 701 |
| 676 @end | 702 @end |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 } | 761 } |
| 736 | 762 |
| 737 - (void)accessibilityPerformAction:(NSString*)action { | 763 - (void)accessibilityPerformAction:(NSString*)action { |
| 738 if ([action isEqualToString:NSAccessibilityPressAction]) | 764 if ([action isEqualToString:NSAccessibilityPressAction]) |
| 739 [self handleLinkClicked]; | 765 [self handleLinkClicked]; |
| 740 else | 766 else |
| 741 [super accessibilityPerformAction:action]; | 767 [super accessibilityPerformAction:action]; |
| 742 } | 768 } |
| 743 | 769 |
| 744 @end | 770 @end |
| OLD | NEW |