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

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

Issue 726813002: [Extensions Toolbar] Make the ExtensionToolbarModel icon count more stable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 (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 <cmath> 7 #include <cmath>
8 #include <string> 8 #include <string>
9 9
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 namespace { 145 namespace {
146 146
147 // A bridge between the ToolbarActionsBar and the BrowserActionsController. 147 // A bridge between the ToolbarActionsBar and the BrowserActionsController.
148 class ToolbarActionsBarBridge : public ToolbarActionsBarDelegate { 148 class ToolbarActionsBarBridge : public ToolbarActionsBarDelegate {
149 public: 149 public:
150 explicit ToolbarActionsBarBridge(BrowserActionsController* controller); 150 explicit ToolbarActionsBarBridge(BrowserActionsController* controller);
151 ~ToolbarActionsBarBridge() override; 151 ~ToolbarActionsBarBridge() override;
152 152
153 private: 153 private:
154 // ToolbarActionsBarDelegate: 154 // ToolbarActionsBarDelegate:
155 bool IsReady() const override;
155 void AddViewForAction(ToolbarActionViewController* action, 156 void AddViewForAction(ToolbarActionViewController* action,
156 size_t index) override; 157 size_t index) override;
157 void RemoveViewForAction(ToolbarActionViewController* action) override; 158 void RemoveViewForAction(ToolbarActionViewController* action) override;
158 void RemoveAllViews() override; 159 void RemoveAllViews() override;
159 void Redraw(bool order_changed) override; 160 void Redraw(bool order_changed) override;
160 void ResizeAndAnimate(gfx::Tween::Type tween_type, 161 void ResizeAndAnimate(gfx::Tween::Type tween_type,
161 int target_width, 162 int target_width,
162 bool suppress_chevron) override; 163 bool suppress_chevron) override;
163 void SetChevronVisibility(bool chevron_visible) override; 164 void SetChevronVisibility(bool chevron_visible) override;
164 int GetWidth() const override; 165 int GetWidth() const override;
165 bool IsAnimating() const override; 166 bool IsAnimating() const override;
166 void StopAnimating() override; 167 void StopAnimating() override;
167 int GetChevronWidth() const override; 168 int GetChevronWidth() const override;
168 bool IsPopupRunning() const override; 169 bool IsPopupRunning() const override;
169 170
170 // The owning BrowserActionsController; weak. 171 // The owning BrowserActionsController; weak.
171 BrowserActionsController* controller_; 172 BrowserActionsController* controller_;
172 173
173 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBarBridge); 174 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBarBridge);
174 }; 175 };
175 176
176 ToolbarActionsBarBridge::ToolbarActionsBarBridge( 177 ToolbarActionsBarBridge::ToolbarActionsBarBridge(
177 BrowserActionsController* controller) 178 BrowserActionsController* controller)
178 : controller_(controller) { 179 : controller_(controller) {
179 } 180 }
180 181
181 ToolbarActionsBarBridge::~ToolbarActionsBarBridge() { 182 ToolbarActionsBarBridge::~ToolbarActionsBarBridge() {
182 } 183 }
183 184
185 bool ToolbarActionsBarBridge::IsReady() const {
186 // Unlike the ui/views implementation, the BrowserActionsController is ready
187 // to create views from the time of its construction.
188 return true;
189 }
190
184 void ToolbarActionsBarBridge::AddViewForAction( 191 void ToolbarActionsBarBridge::AddViewForAction(
185 ToolbarActionViewController* action, 192 ToolbarActionViewController* action,
186 size_t index) { 193 size_t index) {
187 [controller_ addViewForAction:action 194 [controller_ addViewForAction:action
188 withIndex:index]; 195 withIndex:index];
189 } 196 }
190 197
191 void ToolbarActionsBarBridge::RemoveViewForAction( 198 void ToolbarActionsBarBridge::RemoveViewForAction(
192 ToolbarActionViewController* action) { 199 ToolbarActionViewController* action) {
193 [controller_ removeViewForAction:action]; 200 [controller_ removeViewForAction:action];
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 761
755 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index { 762 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index {
756 const std::vector<ToolbarActionViewController*>& toolbar_actions = 763 const std::vector<ToolbarActionViewController*>& toolbar_actions =
757 toolbarActionsBar_->toolbar_actions(); 764 toolbarActionsBar_->toolbar_actions();
758 if (index < toolbar_actions.size()) 765 if (index < toolbar_actions.size())
759 return [self buttonForId:toolbar_actions[index]->GetId()]; 766 return [self buttonForId:toolbar_actions[index]->GetId()];
760 return nil; 767 return nil;
761 } 768 }
762 769
763 @end 770 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698