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/browser_actions_controller.h" | 5 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
| 10 #include <utility> |
10 | 11 |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
13 #include "chrome/browser/extensions/extension_message_bubble_controller.h" | 14 #include "chrome/browser/extensions/extension_message_bubble_controller.h" |
14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
16 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 17 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
17 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" | 18 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" |
18 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" | 19 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" |
19 #import "chrome/browser/ui/cocoa/extensions/extension_message_bubble_bridge.h" | 20 #import "chrome/browser/ui/cocoa/extensions/extension_message_bubble_bridge.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 void ToolbarActionsBarBridge::ShowExtensionMessageBubble( | 283 void ToolbarActionsBarBridge::ShowExtensionMessageBubble( |
283 scoped_ptr<extensions::ExtensionMessageBubbleController> bubble_controller, | 284 scoped_ptr<extensions::ExtensionMessageBubbleController> bubble_controller, |
284 ToolbarActionViewController* anchor_action) { | 285 ToolbarActionViewController* anchor_action) { |
285 // This goop is a by-product of needing to wire together abstract classes, | 286 // This goop is a by-product of needing to wire together abstract classes, |
286 // C++/Cocoa bridges, and ExtensionMessageBubbleController's somewhat strange | 287 // C++/Cocoa bridges, and ExtensionMessageBubbleController's somewhat strange |
287 // Show() interface. It's ugly, but it's pretty confined, so it's probably | 288 // Show() interface. It's ugly, but it's pretty confined, so it's probably |
288 // okay (but if we ever need to expand, it might need to be reconsidered). | 289 // okay (but if we ever need to expand, it might need to be reconsidered). |
289 extensions::ExtensionMessageBubbleController* weak_controller = | 290 extensions::ExtensionMessageBubbleController* weak_controller = |
290 bubble_controller.get(); | 291 bubble_controller.get(); |
291 scoped_ptr<ExtensionMessageBubbleBridge> bridge( | 292 scoped_ptr<ExtensionMessageBubbleBridge> bridge( |
292 new ExtensionMessageBubbleBridge(bubble_controller.Pass(), | 293 new ExtensionMessageBubbleBridge(std::move(bubble_controller), |
293 anchor_action != nullptr)); | 294 anchor_action != nullptr)); |
294 ToolbarActionsBarBubbleMac* bubble = | 295 ToolbarActionsBarBubbleMac* bubble = |
295 [controller_ createMessageBubble:bridge.Pass() | 296 [controller_ createMessageBubble:std::move(bridge) |
296 anchorToSelf:anchor_action != nil]; | 297 anchorToSelf:anchor_action != nil]; |
297 weak_controller->OnShown(); | 298 weak_controller->OnShown(); |
298 [bubble showWindow:nil]; | 299 [bubble showWindow:nil]; |
299 } | 300 } |
300 | 301 |
301 } // namespace | 302 } // namespace |
302 | 303 |
303 @implementation BrowserActionsController | 304 @implementation BrowserActionsController |
304 | 305 |
305 @synthesize containerView = containerView_; | 306 @synthesize containerView = containerView_; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 scoped_ptr<ui::NinePartImageIds> highlight; | 564 scoped_ptr<ui::NinePartImageIds> highlight; |
564 if (toolbarActionsBar_->is_highlighting()) { | 565 if (toolbarActionsBar_->is_highlighting()) { |
565 if (toolbarActionsBar_->highlight_type() == | 566 if (toolbarActionsBar_->highlight_type() == |
566 ToolbarActionsModel::HIGHLIGHT_INFO) | 567 ToolbarActionsModel::HIGHLIGHT_INFO) |
567 highlight.reset( | 568 highlight.reset( |
568 new ui::NinePartImageIds(IMAGE_GRID(IDR_TOOLBAR_ACTION_HIGHLIGHT))); | 569 new ui::NinePartImageIds(IMAGE_GRID(IDR_TOOLBAR_ACTION_HIGHLIGHT))); |
569 else | 570 else |
570 highlight.reset( | 571 highlight.reset( |
571 new ui::NinePartImageIds(IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT))); | 572 new ui::NinePartImageIds(IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT))); |
572 } | 573 } |
573 [containerView_ setHighlight:highlight.Pass()]; | 574 [containerView_ setHighlight:std::move(highlight)]; |
574 | 575 |
575 std::vector<ToolbarActionViewController*> toolbar_actions = | 576 std::vector<ToolbarActionViewController*> toolbar_actions = |
576 toolbarActionsBar_->GetActions(); | 577 toolbarActionsBar_->GetActions(); |
577 for (NSUInteger i = 0; i < [buttons_ count]; ++i) { | 578 for (NSUInteger i = 0; i < [buttons_ count]; ++i) { |
578 ToolbarActionViewController* controller = | 579 ToolbarActionViewController* controller = |
579 [[self buttonAtIndex:i] viewController]; | 580 [[self buttonAtIndex:i] viewController]; |
580 if (controller != toolbar_actions[i]) { | 581 if (controller != toolbar_actions[i]) { |
581 size_t j = i + 1; | 582 size_t j = i + 1; |
582 while (true) { | 583 while (true) { |
583 ToolbarActionViewController* other_controller = | 584 ToolbarActionViewController* other_controller = |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 } | 806 } |
806 } | 807 } |
807 | 808 |
808 - (void)containerMouseEntered:(NSNotification*)notification { | 809 - (void)containerMouseEntered:(NSNotification*)notification { |
809 if (!activeBubble_ && // only show one bubble at a time | 810 if (!activeBubble_ && // only show one bubble at a time |
810 ExtensionToolbarIconSurfacingBubbleDelegate::ShouldShowForProfile( | 811 ExtensionToolbarIconSurfacingBubbleDelegate::ShouldShowForProfile( |
811 browser_->profile())) { | 812 browser_->profile())) { |
812 scoped_ptr<ToolbarActionsBarBubbleDelegate> delegate( | 813 scoped_ptr<ToolbarActionsBarBubbleDelegate> delegate( |
813 new ExtensionToolbarIconSurfacingBubbleDelegate(browser_->profile())); | 814 new ExtensionToolbarIconSurfacingBubbleDelegate(browser_->profile())); |
814 ToolbarActionsBarBubbleMac* bubble = | 815 ToolbarActionsBarBubbleMac* bubble = |
815 [self createMessageBubble:delegate.Pass() | 816 [self createMessageBubble:std::move(delegate) anchorToSelf:YES]; |
816 anchorToSelf:YES]; | |
817 [bubble showWindow:nil]; | 817 [bubble showWindow:nil]; |
818 } | 818 } |
819 [containerView_ setTrackingEnabled:NO]; | 819 [containerView_ setTrackingEnabled:NO]; |
820 [[NSNotificationCenter defaultCenter] | 820 [[NSNotificationCenter defaultCenter] |
821 removeObserver:self | 821 removeObserver:self |
822 name:kBrowserActionsContainerMouseEntered | 822 name:kBrowserActionsContainerMouseEntered |
823 object:containerView_]; | 823 object:containerView_]; |
824 } | 824 } |
825 | 825 |
826 - (void)actionButtonDragging:(NSNotification*)notification { | 826 - (void)actionButtonDragging:(NSNotification*)notification { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 DCHECK_GE([buttons_ count], 0u); | 1027 DCHECK_GE([buttons_ count], 0u); |
1028 NSView* anchorView = | 1028 NSView* anchorView = |
1029 anchorToSelf ? containerView_ : [[self toolbarController] appMenuButton]; | 1029 anchorToSelf ? containerView_ : [[self toolbarController] appMenuButton]; |
1030 NSPoint anchor = [self popupPointForView:anchorView | 1030 NSPoint anchor = [self popupPointForView:anchorView |
1031 withBounds:[anchorView bounds]]; | 1031 withBounds:[anchorView bounds]]; |
1032 | 1032 |
1033 anchor = [[containerView_ window] convertBaseToScreen:anchor]; | 1033 anchor = [[containerView_ window] convertBaseToScreen:anchor]; |
1034 activeBubble_ = [[ToolbarActionsBarBubbleMac alloc] | 1034 activeBubble_ = [[ToolbarActionsBarBubbleMac alloc] |
1035 initWithParentWindow:[containerView_ window] | 1035 initWithParentWindow:[containerView_ window] |
1036 anchorPoint:anchor | 1036 anchorPoint:anchor |
1037 delegate:delegate.Pass()]; | 1037 delegate:std::move(delegate)]; |
1038 [[NSNotificationCenter defaultCenter] | 1038 [[NSNotificationCenter defaultCenter] |
1039 addObserver:self | 1039 addObserver:self |
1040 selector:@selector(bubbleWindowClosing:) | 1040 selector:@selector(bubbleWindowClosing:) |
1041 name:NSWindowWillCloseNotification | 1041 name:NSWindowWillCloseNotification |
1042 object:[activeBubble_ window]]; | 1042 object:[activeBubble_ window]]; |
1043 return activeBubble_; | 1043 return activeBubble_; |
1044 } | 1044 } |
1045 | 1045 |
1046 - (void)bubbleWindowClosing:(NSNotification*)notification { | 1046 - (void)bubbleWindowClosing:(NSNotification*)notification { |
1047 activeBubble_ = nil; | 1047 activeBubble_ = nil; |
1048 } | 1048 } |
1049 | 1049 |
1050 - (void)setFocusedViewIndex:(NSInteger)index { | 1050 - (void)setFocusedViewIndex:(NSInteger)index { |
1051 DCHECK(isOverflow_); | 1051 DCHECK(isOverflow_); |
1052 focusedViewIndex_ = index; | 1052 focusedViewIndex_ = index; |
1053 } | 1053 } |
1054 | 1054 |
1055 #pragma mark - | 1055 #pragma mark - |
1056 #pragma mark Testing Methods | 1056 #pragma mark Testing Methods |
1057 | 1057 |
1058 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index { | 1058 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index { |
1059 return index < [buttons_ count] ? [buttons_ objectAtIndex:index] : nil; | 1059 return index < [buttons_ count] ? [buttons_ objectAtIndex:index] : nil; |
1060 } | 1060 } |
1061 | 1061 |
1062 @end | 1062 @end |
OLD | NEW |