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

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

Issue 1858773006: [Extensions UI] Use the ExtensionMessageBubbleBridge for Views platforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 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/extensions/toolbar_actions_bar_bubble_mac.h" 5 #import "chrome/browser/ui/cocoa/extensions/toolbar_actions_bar_bubble_mac.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 @implementation ToolbarActionsBarBubbleMac 57 @implementation ToolbarActionsBarBubbleMac
58 58
59 @synthesize actionButton = actionButton_; 59 @synthesize actionButton = actionButton_;
60 @synthesize itemList = itemList_; 60 @synthesize itemList = itemList_;
61 @synthesize dismissButton = dismissButton_; 61 @synthesize dismissButton = dismissButton_;
62 @synthesize learnMoreButton = learnMoreButton_; 62 @synthesize learnMoreButton = learnMoreButton_;
63 63
64 - (id)initWithParentWindow:(NSWindow*)parentWindow 64 - (id)initWithParentWindow:(NSWindow*)parentWindow
65 anchorPoint:(NSPoint)anchorPoint 65 anchorPoint:(NSPoint)anchorPoint
66 delegate:(std::unique_ptr<ToolbarActionsBarBubbleDelegate>) 66 anchoredToAction:(BOOL)anchoredToAction
67 delegate { 67 delegate:
68 (std::unique_ptr<ToolbarActionsBarBubbleDelegate>)
69 delegate {
68 base::scoped_nsobject<InfoBubbleWindow> window( 70 base::scoped_nsobject<InfoBubbleWindow> window(
69 [[InfoBubbleWindow alloc] 71 [[InfoBubbleWindow alloc]
70 initWithContentRect:ui::kWindowSizeDeterminedLater 72 initWithContentRect:ui::kWindowSizeDeterminedLater
71 styleMask:NSBorderlessWindowMask 73 styleMask:NSBorderlessWindowMask
72 backing:NSBackingStoreBuffered 74 backing:NSBackingStoreBuffered
73 defer:NO]); 75 defer:NO]);
74 if ((self = [super initWithWindow:window 76 if ((self = [super initWithWindow:window
75 parentWindow:parentWindow 77 parentWindow:parentWindow
76 anchoredAt:anchorPoint])) { 78 anchoredAt:anchorPoint])) {
77 acknowledged_ = NO; 79 acknowledged_ = NO;
80 anchoredToAction_ = anchoredToAction;
78 delegate_ = std::move(delegate); 81 delegate_ = std::move(delegate);
79 82
80 ui::NativeTheme* nativeTheme = ui::NativeThemeMac::instance(); 83 ui::NativeTheme* nativeTheme = ui::NativeThemeMac::instance();
81 [[self bubble] setAlignment:info_bubble::kAlignArrowToAnchor]; 84 [[self bubble] setAlignment:info_bubble::kAlignArrowToAnchor];
82 [[self bubble] setArrowLocation:info_bubble::kTopRight]; 85 [[self bubble] setArrowLocation:info_bubble::kTopRight];
83 [[self bubble] setBackgroundColor: 86 [[self bubble] setBackgroundColor:
84 skia::SkColorToCalibratedNSColor(nativeTheme->GetSystemColor( 87 skia::SkColorToCalibratedNSColor(nativeTheme->GetSystemColor(
85 ui::NativeTheme::kColorId_DialogBackground))]; 88 ui::NativeTheme::kColorId_DialogBackground))];
86 89
87 if (!g_animations_enabled) 90 if (!g_animations_enabled)
88 [window setAllowedAnimations:info_bubble::kAnimateNone]; 91 [window setAllowedAnimations:info_bubble::kAnimateNone];
89 92
93 [self setShouldCloseOnResignKey:delegate_->ShouldCloseOnDeactivate()];
94
90 [self layout]; 95 [self layout];
91 96
92 [[self window] makeFirstResponder: 97 [[self window] makeFirstResponder:
93 (actionButton_ ? actionButton_ : dismissButton_)]; 98 (actionButton_ ? actionButton_ : dismissButton_)];
94 } 99 }
95 return self; 100 return self;
96 } 101 }
97 102
98 + (void)setAnimationEnabledForTesting:(BOOL)enabled { 103 + (void)setAnimationEnabledForTesting:(BOOL)enabled {
99 g_animations_enabled = enabled; 104 g_animations_enabled = enabled;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 if (dismissButton_) 227 if (dismissButton_)
223 buttonStripWidth += dismissButtonSize.width + kButtonPadding; 228 buttonStripWidth += dismissButtonSize.width + kButtonPadding;
224 if (learnMoreButton_) 229 if (learnMoreButton_)
225 buttonStripWidth += learnMoreSize.width + kButtonPadding; 230 buttonStripWidth += learnMoreSize.width + kButtonPadding;
226 231
227 CGFloat headingWidth = headingSize.width; 232 CGFloat headingWidth = headingSize.width;
228 CGFloat windowWidth = 233 CGFloat windowWidth =
229 std::max(std::max(kMinWidth, buttonStripWidth), headingWidth); 234 std::max(std::max(kMinWidth, buttonStripWidth), headingWidth);
230 235
231 NSTextField* content = 236 NSTextField* content =
232 [self addTextFieldWithString:delegate_->GetBodyText() 237 [self addTextFieldWithString:delegate_->GetBodyText(anchoredToAction_)
233 fontSize:12.0 238 fontSize:12.0
234 alignment:NSLeftTextAlignment]; 239 alignment:NSLeftTextAlignment];
235 [content setFrame:NSMakeRect(0, 0, windowWidth, 0)]; 240 [content setFrame:NSMakeRect(0, 0, windowWidth, 0)];
236 // The content should have the same (max) width as the heading, which means 241 // The content should have the same (max) width as the heading, which means
237 // the text will most likely wrap. 242 // the text will most likely wrap.
238 NSSize contentSize = NSMakeSize(windowWidth, 243 NSSize contentSize = NSMakeSize(windowWidth,
239 [GTMUILocalizerAndLayoutTweaker 244 [GTMUILocalizerAndLayoutTweaker
240 sizeToFitFixedWidthTextField:content]); 245 sizeToFitFixedWidthTextField:content]);
241 246
242 const CGFloat kItemListIndentation = 10.0; 247 const CGFloat kItemListIndentation = 10.0;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } else { 339 } else {
335 DCHECK_EQ(sender, actionButton_); 340 DCHECK_EQ(sender, actionButton_);
336 action = ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE; 341 action = ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE;
337 } 342 }
338 acknowledged_ = YES; 343 acknowledged_ = YES;
339 delegate_->OnBubbleClosed(action); 344 delegate_->OnBubbleClosed(action);
340 [self close]; 345 [self close];
341 } 346 }
342 347
343 @end 348 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698