OLD | NEW |
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 alignment:NSLeftTextAlignment]; | 190 alignment:NSLeftTextAlignment]; |
191 NSSize headingSize = [heading frame].size; | 191 NSSize headingSize = [heading frame].size; |
192 | 192 |
193 NSSize extraViewIconSize = NSZeroSize; | 193 NSSize extraViewIconSize = NSZeroSize; |
194 NSSize extraViewTextSize = NSZeroSize; | 194 NSSize extraViewTextSize = NSZeroSize; |
195 | 195 |
196 std::unique_ptr<ToolbarActionsBarBubbleDelegate::ExtraViewInfo> | 196 std::unique_ptr<ToolbarActionsBarBubbleDelegate::ExtraViewInfo> |
197 extra_view_info = delegate_->GetExtraViewInfo(); | 197 extra_view_info = delegate_->GetExtraViewInfo(); |
198 | 198 |
199 if (extra_view_info) { | 199 if (extra_view_info) { |
200 gfx::VectorIconId resource_id = extra_view_info->resource_id; | |
201 // The extra view icon is optional. | 200 // The extra view icon is optional. |
202 if (resource_id != gfx::VectorIconId::VECTOR_ICON_NONE) { | 201 if (extra_view_info->resource) { |
203 NSImage* image = gfx::Image(gfx::CreateVectorIcon(resource_id, 16, | 202 NSImage* image = |
204 gfx::kChromeIconGrey)) | 203 gfx::Image(gfx::CreateVectorIcon(*extra_view_info->resource, 16, |
205 .ToNSImage(); | 204 gfx::kChromeIconGrey)) |
| 205 .ToNSImage(); |
206 NSRect frame = NSMakeRect(0, 0, image.size.width, image.size.height); | 206 NSRect frame = NSMakeRect(0, 0, image.size.width, image.size.height); |
207 iconView_ = [[[NSImageView alloc] initWithFrame:frame] autorelease]; | 207 iconView_ = [[[NSImageView alloc] initWithFrame:frame] autorelease]; |
208 [iconView_ setImage:image]; | 208 [iconView_ setImage:image]; |
209 extraViewIconSize = frame.size; | 209 extraViewIconSize = frame.size; |
210 | 210 |
211 [[[self window] contentView] addSubview:iconView_]; | 211 [[[self window] contentView] addSubview:iconView_]; |
212 } | 212 } |
213 | 213 |
214 const base::string16& text = extra_view_info->text; | 214 const base::string16& text = extra_view_info->text; |
215 if (!text.empty()) { // The extra view text is optional. | 215 if (!text.empty()) { // The extra view text is optional. |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 } else { | 389 } else { |
390 DCHECK_EQ(sender, actionButton_); | 390 DCHECK_EQ(sender, actionButton_); |
391 action = ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE; | 391 action = ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE; |
392 } | 392 } |
393 acknowledged_ = YES; | 393 acknowledged_ = YES; |
394 delegate_->OnBubbleClosed(action); | 394 delegate_->OnBubbleClosed(action); |
395 [self close]; | 395 [self close]; |
396 } | 396 } |
397 | 397 |
398 @end | 398 @end |
OLD | NEW |