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

Side by Side Diff: chrome/browser/views/browser_actions_container.h

Issue 549151: re-try r37025 with fix for incognito mode... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/views/browser_actions_container.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ 5 #ifndef CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_
6 #define CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ 6 #define CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/task.h" 10 #include "base/task.h"
11 #include "chrome/browser/extensions/extension_toolbar_model.h"
11 #include "chrome/browser/extensions/image_loading_tracker.h" 12 #include "chrome/browser/extensions/image_loading_tracker.h"
12 #include "chrome/browser/views/browser_bubble.h" 13 #include "chrome/browser/views/browser_bubble.h"
13 #include "chrome/browser/views/extensions/extension_action_context_menu.h" 14 #include "chrome/browser/views/extensions/extension_action_context_menu.h"
14 #include "chrome/common/notification_observer.h" 15 #include "chrome/common/notification_observer.h"
15 #include "chrome/common/notification_registrar.h" 16 #include "chrome/common/notification_registrar.h"
16 #include "views/controls/button/menu_button.h" 17 #include "views/controls/button/menu_button.h"
17 #include "views/controls/menu/view_menu_delegate.h" 18 #include "views/controls/menu/view_menu_delegate.h"
18 #include "views/controls/resize_gripper.h" 19 #include "views/controls/resize_gripper.h"
19 #include "views/view.h" 20 #include "views/view.h"
20 21
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // animation ends and we don't want the chevron to flash into view while we are 209 // animation ends and we don't want the chevron to flash into view while we are
209 // growing the container. 210 // growing the container.
210 // 211 //
211 //////////////////////////////////////////////////////////////////////////////// 212 ////////////////////////////////////////////////////////////////////////////////
212 class BrowserActionsContainer 213 class BrowserActionsContainer
213 : public views::View, 214 : public views::View,
214 public NotificationObserver, 215 public NotificationObserver,
215 public BrowserBubble::Delegate, 216 public BrowserBubble::Delegate,
216 public views::ViewMenuDelegate, 217 public views::ViewMenuDelegate,
217 public views::ResizeGripper::ResizeGripperDelegate, 218 public views::ResizeGripper::ResizeGripperDelegate,
218 public AnimationDelegate { 219 public AnimationDelegate,
220 public ExtensionToolbarModel::Observer {
219 public: 221 public:
220 BrowserActionsContainer(Profile* profile, ToolbarView* toolbar); 222 BrowserActionsContainer(Profile* profile, ToolbarView* toolbar);
221 virtual ~BrowserActionsContainer(); 223 virtual ~BrowserActionsContainer();
222 224
223 static void RegisterUserPrefs(PrefService* prefs); 225 static void RegisterUserPrefs(PrefService* prefs);
224 226
225 // Get the number of browser actions being displayed. 227 // Get the number of browser actions being displayed.
226 int num_browser_actions() const { return browser_action_views_.size(); } 228 int num_browser_actions() const { return browser_action_views_.size(); }
227 229
228 // Whether we are performing resize animation on the container. 230 // Whether we are performing resize animation on the container.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 void HidePopup(); 290 void HidePopup();
289 291
290 // Simulate a click on a browser action button. This should only be 292 // Simulate a click on a browser action button. This should only be
291 // used by unit tests. 293 // used by unit tests.
292 void TestExecuteBrowserAction(int index); 294 void TestExecuteBrowserAction(int index);
293 295
294 // Retrieve the current popup. This should only be used by unit tests. 296 // Retrieve the current popup. This should only be used by unit tests.
295 ExtensionPopup* TestGetPopup() { return popup_; } 297 ExtensionPopup* TestGetPopup() { return popup_; }
296 298
297 private: 299 private:
298 // Adds a browser action view for the extension if it needs one. DCHECK if 300 // ExtensionToolbarModel::Observer implementation.
299 // it has already been added. 301 virtual void BrowserActionAdded(Extension* extension, int index);
300 void AddBrowserAction(Extension* extension); 302 virtual void BrowserActionRemoved(Extension* extension);
301
302 // Removes the browser action view for an extension if it has one. DCHECK if
303 // no such view.
304 void RemoveBrowserAction(Extension* extension);
305 303
306 // Takes a width in pixels, calculates how many icons fit within that space 304 // Takes a width in pixels, calculates how many icons fit within that space
307 // (up to the maximum number of icons in our vector) and shaves off the 305 // (up to the maximum number of icons in our vector) and shaves off the
308 // excess pixels. 306 // excess pixels.
309 int ClampToNearestIconCount(int pixels) const; 307 int ClampToNearestIconCount(int pixels) const;
310 308
311 // Calculates the width of the container area NOT used to show the icons (the 309 // Calculates the width of the container area NOT used to show the icons (the
312 // controls to the left and to the right of the icons). 310 // controls to the left and to the right of the icons).
313 int WidthOfNonIconArea() const; 311 int WidthOfNonIconArea() const;
314 312
(...skipping 16 matching lines...) Expand all
331 // The toolbar that owns us. 329 // The toolbar that owns us.
332 ToolbarView* toolbar_; 330 ToolbarView* toolbar_;
333 331
334 // The current popup and the button it came from. NULL if no popup. 332 // The current popup and the button it came from. NULL if no popup.
335 ExtensionPopup* popup_; 333 ExtensionPopup* popup_;
336 334
337 // The button that triggered the current popup (just a reference to a button 335 // The button that triggered the current popup (just a reference to a button
338 // from browser_action_views_). 336 // from browser_action_views_).
339 BrowserActionButton* popup_button_; 337 BrowserActionButton* popup_button_;
340 338
339 // The model that tracks the order of the toolbar icons.
340 ExtensionToolbarModel* model_;
341
341 // The current size of the container. 342 // The current size of the container.
342 gfx::Size container_size_; 343 gfx::Size container_size_;
343 344
344 // The resize gripper for the container. 345 // The resize gripper for the container.
345 views::ResizeGripper* resize_gripper_; 346 views::ResizeGripper* resize_gripper_;
346 347
347 // The chevron for accessing the overflow items. 348 // The chevron for accessing the overflow items.
348 views::MenuButton* chevron_; 349 views::MenuButton* chevron_;
349 350
350 // The animation that happens when the container snaps to place. 351 // The animation that happens when the container snaps to place.
(...skipping 10 matching lines...) Expand all
361 // Keeps track of the absolute pixel width the container should have when we 362 // Keeps track of the absolute pixel width the container should have when we
362 // are done animating. 363 // are done animating.
363 int animation_target_size_; 364 int animation_target_size_;
364 365
365 ScopedRunnableMethodFactory<BrowserActionsContainer> task_factory_; 366 ScopedRunnableMethodFactory<BrowserActionsContainer> task_factory_;
366 367
367 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); 368 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer);
368 }; 369 };
369 370
370 #endif // CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ 371 #endif // CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/views/browser_actions_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698