| 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_installed_bubble_controlle
r.h" | 5 #import "chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controlle
r.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 extension, | 125 extension, |
| 126 browser, | 126 browser, |
| 127 icon)); | 127 icon)); |
| 128 installedBubble_->IgnoreBrowserClosing(); | 128 installedBubble_->IgnoreBrowserClosing(); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 return self; | 131 return self; |
| 132 } | 132 } |
| 133 | 133 |
| 134 - (const Extension*)extension { | 134 - (const Extension*)extension { |
| 135 if (type_ == extension_installed_bubble::kBundle) |
| 136 return nullptr; |
| 135 return installedBubble_->extension(); | 137 return installedBubble_->extension(); |
| 136 } | 138 } |
| 137 | 139 |
| 138 // Sets |promo_| based on |promoPlaceholder_|, sets |promoPlaceholder_| to nil. | 140 // Sets |promo_| based on |promoPlaceholder_|, sets |promoPlaceholder_| to nil. |
| 139 - (void)initializeLabel { | 141 - (void)initializeLabel { |
| 140 // Replace the promo placeholder NSTextField with the real label NSTextView. | 142 // Replace the promo placeholder NSTextField with the real label NSTextView. |
| 141 // The former doesn't show links in a nice way, but the latter can't be added | 143 // The former doesn't show links in a nice way, but the latter can't be added |
| 142 // in IB without a containing scroll view, so create the NSTextView | 144 // in IB without a containing scroll view, so create the NSTextView |
| 143 // programmatically. | 145 // programmatically. |
| 144 promo_.reset([[HyperlinkTextView alloc] | 146 promo_.reset([[HyperlinkTextView alloc] |
| 145 initWithFrame:[promoPlaceholder_ frame]]); | 147 initWithFrame:[promoPlaceholder_ frame]]); |
| 146 [promo_.get() setAutoresizingMask:[promoPlaceholder_ autoresizingMask]]; | 148 [promo_.get() setAutoresizingMask:[promoPlaceholder_ autoresizingMask]]; |
| 147 [[promoPlaceholder_ superview] | 149 [[promoPlaceholder_ superview] |
| 148 replaceSubview:promoPlaceholder_ with:promo_.get()]; | 150 replaceSubview:promoPlaceholder_ with:promo_.get()]; |
| 149 promoPlaceholder_ = nil; // Now released. | 151 promoPlaceholder_ = nil; // Now released. |
| 150 [promo_.get() setDelegate:self]; | 152 [promo_.get() setDelegate:self]; |
| 151 } | 153 } |
| 152 | 154 |
| 153 // Returns YES if the sync promo should be shown in the bubble. | 155 // Returns YES if the sync promo should be shown in the bubble. |
| 154 - (BOOL)showSyncPromo { | 156 - (BOOL)showSyncPromo { |
| 157 if (type_ == extension_installed_bubble::kBundle) |
| 158 return false; |
| 155 return extensions::sync_helper::IsSyncableExtension([self extension]) && | 159 return extensions::sync_helper::IsSyncableExtension([self extension]) && |
| 156 SyncPromoUI::ShouldShowSyncPromo(browser_->profile()); | 160 SyncPromoUI::ShouldShowSyncPromo(browser_->profile()); |
| 157 } | 161 } |
| 158 | 162 |
| 159 - (void)windowWillClose:(NSNotification*)notification { | 163 - (void)windowWillClose:(NSNotification*)notification { |
| 160 // Turn off page action icon preview when the window closes, unless we | 164 // Turn off page action icon preview when the window closes, unless we |
| 161 // already removed it when the window resigned key status. | 165 // already removed it when the window resigned key status. |
| 162 [self removePageActionPreviewIfNecessary]; | 166 [self removePageActionPreviewIfNecessary]; |
| 163 browser_ = NULL; | 167 browser_ = NULL; |
| 164 [closeButton_ setTrackingEnabled:NO]; | 168 [closeButton_ setTrackingEnabled:NO]; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 | 438 |
| 435 // Sync sign-in promo, if any. | 439 // Sync sign-in promo, if any. |
| 436 if (sync_promo_height > 0) { | 440 if (sync_promo_height > 0) { |
| 437 NSRect promo_frame = [promo_.get() frame]; | 441 NSRect promo_frame = [promo_.get() frame]; |
| 438 promo_frame.size.height = sync_promo_height; | 442 promo_frame.size.height = sync_promo_height; |
| 439 [promo_.get() setFrame:promo_frame]; | 443 [promo_.get() setFrame:promo_frame]; |
| 440 newWindowHeight += extension_installed_bubble::kInnerVerticalMargin; | 444 newWindowHeight += extension_installed_bubble::kInnerVerticalMargin; |
| 441 newWindowHeight += sync_promo_height; | 445 newWindowHeight += sync_promo_height; |
| 442 } | 446 } |
| 443 | 447 |
| 444 if (installedBubble_->has_command_keybinding()) { | 448 if (type_ != extension_installed_bubble::kBundle && |
| 449 installedBubble_->has_command_keybinding()) { |
| 445 [manageShortcutLink_ setHidden:NO]; | 450 [manageShortcutLink_ setHidden:NO]; |
| 446 [[manageShortcutLink_ cell] | 451 [[manageShortcutLink_ cell] |
| 447 setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; | 452 setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; |
| 448 [[manageShortcutLink_ cell] | 453 [[manageShortcutLink_ cell] |
| 449 setTextColor:gfx::SkColorToCalibratedNSColor( | 454 setTextColor:gfx::SkColorToCalibratedNSColor( |
| 450 chrome_style::GetLinkColor())]; | 455 chrome_style::GetLinkColor())]; |
| 451 [GTMUILocalizerAndLayoutTweaker sizeToFitView:manageShortcutLink_]; | 456 [GTMUILocalizerAndLayoutTweaker sizeToFitView:manageShortcutLink_]; |
| 452 newWindowHeight += extension_installed_bubble::kInnerVerticalMargin; | 457 newWindowHeight += extension_installed_bubble::kInnerVerticalMargin; |
| 453 newWindowHeight += NSHeight([manageShortcutLink_ frame]); | 458 newWindowHeight += NSHeight([manageShortcutLink_ frame]); |
| 454 } | 459 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 install_ui->OpenAppInstalledUI([self extension]->id()); | 609 install_ui->OpenAppInstalledUI([self extension]->id()); |
| 605 } | 610 } |
| 606 | 611 |
| 607 - (void)awakeFromNib { | 612 - (void)awakeFromNib { |
| 608 if (bundle_) | 613 if (bundle_) |
| 609 return; | 614 return; |
| 610 [self initializeLabel]; | 615 [self initializeLabel]; |
| 611 } | 616 } |
| 612 | 617 |
| 613 @end | 618 @end |
| OLD | NEW |