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

Unified Diff: chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm

Issue 766263003: [Extension Toolbar] Refactor and finish pop out logic for actions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
diff --git a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
index 0026449601710cedc08ca15ca3ae7fe5ca2a03f6..c512165dcf343746519d6d31ef7bc1487104c546 100644
--- a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
+++ b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
@@ -234,18 +234,20 @@ bool ToolbarActionsBarBridge::IsPopupRunning() const {
- (id)initWithBrowser:(Browser*)browser
containerView:(BrowserActionsContainerView*)container
- isOverflow:(BOOL)isOverflow {
+ mainController:(BrowserActionsController*)mainController {
DCHECK(browser && container);
if ((self = [super init])) {
browser_ = browser;
- isOverflow_ = isOverflow;
+ isOverflow_ = mainController != nil;
toolbarActionsBarBridge_.reset(new ToolbarActionsBarBridge(self));
+ ToolbarActionsBar* mainBar =
+ mainController ? [mainController toolbarActionsBar] : nullptr;
toolbarActionsBar_.reset(
new ToolbarActionsBar(toolbarActionsBarBridge_.get(),
browser_,
- isOverflow));
+ mainBar));
containerView_ = container;
[containerView_ setPostsFrameChangedNotifications:YES];
@@ -454,11 +456,32 @@ bool ToolbarActionsBarBridge::IsPopupRunning() const {
}
[self showChevronIfNecessaryInFrame:[containerView_ frame]];
- NSUInteger offset = isOverflow_ ?
+ NSUInteger minIndex = isOverflow_ ?
[buttons_ count] - toolbarActionsBar_->GetIconCount() : 0;
- for (NSUInteger i = offset; i < [buttons_ count]; ++i) {
- if (![[buttons_ objectAtIndex:i] isBeingDragged])
- [self moveButton:[buttons_ objectAtIndex:i] toIndex:i - offset];
+ NSUInteger maxIndex = isOverflow_ ?
+ [buttons_ count] : toolbarActionsBar_->GetIconCount();
+ for (NSUInteger i = 0; i < [buttons_ count]; ++i) {
+ BrowserActionButton* button = [buttons_ objectAtIndex:i];
+ if ([button isBeingDragged])
+ continue;
+
+ [self moveButton:[buttons_ objectAtIndex:i] toIndex:i - minIndex];
+
+ if (i >= minIndex && i < maxIndex) {
+ // Make sure the button is within the visible container.
+ if ([button superview] != containerView_) {
+ // We add the subview under the sibling views so that when it
+ // "slides in", it does so under its neighbors.
+ [containerView_ addSubview:button
+ positioned:NSWindowBelow
+ relativeTo:nil];
+ }
+ // We need to set the alpha value in case the container has resized.
+ [button setAlphaValue:1.0];
+ } else if ([button superview] == containerView_) {
+ [button removeFromSuperview];
+ [button setAlphaValue:0.0];
+ }
}
}
@@ -626,22 +649,6 @@ bool ToolbarActionsBarBridge::IsPopupRunning() const {
[button setFrame:buttonFrame
animate:!toolbarActionsBar_->suppress_animation()];
-
- if (index < toolbarActionsBar_->GetIconCount()) {
- // Make sure the button is within the visible container.
- if ([button superview] != containerView_) {
- // We add the subview under the sibling views so that when it "slides in",
- // it does so under its neighbors.
- [containerView_ addSubview:button
- positioned:NSWindowBelow
- relativeTo:nil];
- }
- // We need to set the alpha value in case the container has resized.
- [button setAlphaValue:1.0];
- } else if ([button superview] == containerView_) {
- [button removeFromSuperview];
- [button setAlphaValue:0.0];
- }
}
- (BOOL)browserActionClicked:(BrowserActionButton*)button {

Powered by Google App Engine
This is Rietveld 408576698