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 #ifndef CHROME_BROWSER_UI_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "ui/base/animation/animation_delegate.h" | 26 #include "ui/base/animation/animation_delegate.h" |
27 #include "ui/base/animation/tween.h" | 27 #include "ui/base/animation/tween.h" |
28 #include "ui/views/controls/button/menu_button.h" | 28 #include "ui/views/controls/button/menu_button.h" |
29 #include "ui/views/controls/button/menu_button_listener.h" | 29 #include "ui/views/controls/button/menu_button_listener.h" |
30 #include "ui/views/controls/resize_area_delegate.h" | 30 #include "ui/views/controls/resize_area_delegate.h" |
31 #include "ui/views/drag_controller.h" | 31 #include "ui/views/drag_controller.h" |
32 #include "ui/views/view.h" | 32 #include "ui/views/view.h" |
33 | 33 |
34 class Browser; | 34 class Browser; |
35 class BrowserActionsContainer; | 35 class BrowserActionsContainer; |
36 class Extension; | |
37 class ExtensionAction; | 36 class ExtensionAction; |
38 class ExtensionPopup; | 37 class ExtensionPopup; |
39 class PrefService; | 38 class PrefService; |
40 class Profile; | 39 class Profile; |
41 | 40 |
| 41 namespace extensions { |
| 42 class Extension; |
| 43 } |
| 44 |
42 namespace ui { | 45 namespace ui { |
43 class SlideAnimation; | 46 class SlideAnimation; |
44 } | 47 } |
45 | 48 |
46 namespace views { | 49 namespace views { |
47 class MenuItemView; | 50 class MenuItemView; |
48 class ResizeArea; | 51 class ResizeArea; |
49 } | 52 } |
50 | 53 |
51 //////////////////////////////////////////////////////////////////////////////// | 54 //////////////////////////////////////////////////////////////////////////////// |
52 // BrowserActionButton | 55 // BrowserActionButton |
53 | 56 |
54 // The BrowserActionButton is a specialization of the MenuButton class. | 57 // The BrowserActionButton is a specialization of the MenuButton class. |
55 // It acts on a ExtensionAction, in this case a BrowserAction and handles | 58 // It acts on a ExtensionAction, in this case a BrowserAction and handles |
56 // loading the image for the button asynchronously on the file thread. | 59 // loading the image for the button asynchronously on the file thread. |
57 class BrowserActionButton : public views::MenuButton, | 60 class BrowserActionButton : public views::MenuButton, |
58 public views::ButtonListener, | 61 public views::ButtonListener, |
59 public ImageLoadingTracker::Observer, | 62 public ImageLoadingTracker::Observer, |
60 public content::NotificationObserver { | 63 public content::NotificationObserver { |
61 public: | 64 public: |
62 BrowserActionButton(const Extension* extension, | 65 BrowserActionButton(const extensions::Extension* extension, |
63 BrowserActionsContainer* panel); | 66 BrowserActionsContainer* panel); |
64 | 67 |
65 // Call this instead of delete. | 68 // Call this instead of delete. |
66 void Destroy(); | 69 void Destroy(); |
67 | 70 |
68 ExtensionAction* browser_action() const { return browser_action_; } | 71 ExtensionAction* browser_action() const { return browser_action_; } |
69 const Extension* extension() { return extension_; } | 72 const extensions::Extension* extension() { return extension_; } |
70 | 73 |
71 // Called to update the display to match the browser action's state. | 74 // Called to update the display to match the browser action's state. |
72 void UpdateState(); | 75 void UpdateState(); |
73 | 76 |
74 // Returns the default icon, if any. | 77 // Returns the default icon, if any. |
75 const SkBitmap& default_icon() const { return default_icon_; } | 78 const SkBitmap& default_icon() const { return default_icon_; } |
76 | 79 |
77 // Does this button's action have a popup? | 80 // Does this button's action have a popup? |
78 virtual bool IsPopup(); | 81 virtual bool IsPopup(); |
79 virtual GURL GetPopupUrl(); | 82 virtual GURL GetPopupUrl(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 View* child) OVERRIDE; | 123 View* child) OVERRIDE; |
121 | 124 |
122 private: | 125 private: |
123 virtual ~BrowserActionButton(); | 126 virtual ~BrowserActionButton(); |
124 | 127 |
125 // The browser action this view represents. The ExtensionAction is not owned | 128 // The browser action this view represents. The ExtensionAction is not owned |
126 // by this class. | 129 // by this class. |
127 ExtensionAction* browser_action_; | 130 ExtensionAction* browser_action_; |
128 | 131 |
129 // The extension associated with the browser action we're displaying. | 132 // The extension associated with the browser action we're displaying. |
130 const Extension* extension_; | 133 const extensions::Extension* extension_; |
131 | 134 |
132 // The object that is waiting for the image loading to complete | 135 // The object that is waiting for the image loading to complete |
133 // asynchronously. | 136 // asynchronously. |
134 ImageLoadingTracker tracker_; | 137 ImageLoadingTracker tracker_; |
135 | 138 |
136 // The default icon for our browser action. This might be non-empty if the | 139 // The default icon for our browser action. This might be non-empty if the |
137 // browser action had a value for default_icon in the manifest. | 140 // browser action had a value for default_icon in the manifest. |
138 SkBitmap default_icon_; | 141 SkBitmap default_icon_; |
139 | 142 |
140 // The browser action shelf. | 143 // The browser action shelf. |
(...skipping 14 matching lines...) Expand all Loading... |
155 }; | 158 }; |
156 | 159 |
157 | 160 |
158 //////////////////////////////////////////////////////////////////////////////// | 161 //////////////////////////////////////////////////////////////////////////////// |
159 // BrowserActionView | 162 // BrowserActionView |
160 // A single section in the browser action container. This contains the actual | 163 // A single section in the browser action container. This contains the actual |
161 // BrowserActionButton, as well as the logic to paint the badge. | 164 // BrowserActionButton, as well as the logic to paint the badge. |
162 | 165 |
163 class BrowserActionView : public views::View { | 166 class BrowserActionView : public views::View { |
164 public: | 167 public: |
165 BrowserActionView(const Extension* extension, BrowserActionsContainer* panel); | 168 BrowserActionView(const extensions::Extension* extension, |
| 169 BrowserActionsContainer* panel); |
166 virtual ~BrowserActionView(); | 170 virtual ~BrowserActionView(); |
167 | 171 |
168 BrowserActionButton* button() { return button_; } | 172 BrowserActionButton* button() { return button_; } |
169 | 173 |
170 // Allocates a canvas object on the heap and draws into it the icon for the | 174 // Allocates a canvas object on the heap and draws into it the icon for the |
171 // view as well as the badge (if any). Caller is responsible for deleting the | 175 // view as well as the badge (if any). Caller is responsible for deleting the |
172 // returned object. | 176 // returned object. |
173 gfx::Canvas* GetIconWithBadge(); | 177 gfx::Canvas* GetIconWithBadge(); |
174 | 178 |
175 // Overridden from views::View: | 179 // Overridden from views::View: |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 403 |
400 typedef std::vector<BrowserActionView*> BrowserActionViews; | 404 typedef std::vector<BrowserActionView*> BrowserActionViews; |
401 | 405 |
402 // Returns the width of an icon, optionally with its padding. | 406 // Returns the width of an icon, optionally with its padding. |
403 static int IconWidth(bool include_padding); | 407 static int IconWidth(bool include_padding); |
404 | 408 |
405 // Returns the height of an icon. | 409 // Returns the height of an icon. |
406 static int IconHeight(); | 410 static int IconHeight(); |
407 | 411 |
408 // ExtensionToolbarModel::Observer implementation. | 412 // ExtensionToolbarModel::Observer implementation. |
409 virtual void BrowserActionAdded(const Extension* extension, | 413 virtual void BrowserActionAdded(const extensions::Extension* extension, |
410 int index) OVERRIDE; | 414 int index) OVERRIDE; |
411 virtual void BrowserActionRemoved(const Extension* extension) OVERRIDE; | 415 virtual void BrowserActionRemoved( |
412 virtual void BrowserActionMoved(const Extension* extension, | 416 const extensions::Extension* extension) OVERRIDE; |
| 417 virtual void BrowserActionMoved(const extensions::Extension* extension, |
413 int index) OVERRIDE; | 418 int index) OVERRIDE; |
414 virtual void ModelLoaded() OVERRIDE; | 419 virtual void ModelLoaded() OVERRIDE; |
415 | 420 |
416 void LoadImages(); | 421 void LoadImages(); |
417 | 422 |
418 // Sets the initial container width. | 423 // Sets the initial container width. |
419 void SetContainerWidth(); | 424 void SetContainerWidth(); |
420 | 425 |
421 // Closes the overflow menu if open. | 426 // Closes the overflow menu if open. |
422 void CloseOverflowMenu(); | 427 void CloseOverflowMenu(); |
(...skipping 29 matching lines...) Expand all Loading... |
452 | 457 |
453 // Animate to the target size (unless testing, in which case we go straight to | 458 // Animate to the target size (unless testing, in which case we go straight to |
454 // the target size). This also saves the target number of visible icons in | 459 // the target size). This also saves the target number of visible icons in |
455 // the pref if we're not incognito. | 460 // the pref if we're not incognito. |
456 void SaveDesiredSizeAndAnimate(ui::Tween::Type type, | 461 void SaveDesiredSizeAndAnimate(ui::Tween::Type type, |
457 size_t num_visible_icons); | 462 size_t num_visible_icons); |
458 | 463 |
459 // Returns true if this extension should be shown in this toolbar. This can | 464 // Returns true if this extension should be shown in this toolbar. This can |
460 // return false if we are in an incognito window and the extension is disabled | 465 // return false if we are in an incognito window and the extension is disabled |
461 // for incognito. | 466 // for incognito. |
462 bool ShouldDisplayBrowserAction(const Extension* extension); | 467 bool ShouldDisplayBrowserAction(const extensions::Extension* extension); |
463 | 468 |
464 // The vector of browser actions (icons/image buttons for each action). Note | 469 // The vector of browser actions (icons/image buttons for each action). Note |
465 // that not every BrowserAction in the ToolbarModel will necessarily be in | 470 // that not every BrowserAction in the ToolbarModel will necessarily be in |
466 // this collection. Some extensions may be disabled in incognito windows. | 471 // this collection. Some extensions may be disabled in incognito windows. |
467 BrowserActionViews browser_action_views_; | 472 BrowserActionViews browser_action_views_; |
468 | 473 |
469 Profile* profile_; | 474 Profile* profile_; |
470 | 475 |
471 // The Browser object the container is associated with. | 476 // The Browser object the container is associated with. |
472 Browser* browser_; | 477 Browser* browser_; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 | 525 |
521 base::WeakPtrFactory<BrowserActionsContainer> task_factory_; | 526 base::WeakPtrFactory<BrowserActionsContainer> task_factory_; |
522 | 527 |
523 // Handles delayed showing of the overflow menu when hovering. | 528 // Handles delayed showing of the overflow menu when hovering. |
524 base::WeakPtrFactory<BrowserActionsContainer> show_menu_task_factory_; | 529 base::WeakPtrFactory<BrowserActionsContainer> show_menu_task_factory_; |
525 | 530 |
526 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); | 531 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); |
527 }; | 532 }; |
528 | 533 |
529 #endif // CHROME_BROWSER_UI_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ | 534 #endif // CHROME_BROWSER_UI_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ |
OLD | NEW |