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

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

Issue 1237004: Views: fix a crash where in the browser actions container.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 // The BrowserActionButton is a specialization of the MenuButton class. 44 // The BrowserActionButton is a specialization of the MenuButton class.
45 // It acts on a ExtensionAction, in this case a BrowserAction and handles 45 // It acts on a ExtensionAction, in this case a BrowserAction and handles
46 // loading the image for the button asynchronously on the file thread. 46 // loading the image for the button asynchronously on the file thread.
47 class BrowserActionButton : public views::MenuButton, 47 class BrowserActionButton : public views::MenuButton,
48 public views::ButtonListener, 48 public views::ButtonListener,
49 public ImageLoadingTracker::Observer, 49 public ImageLoadingTracker::Observer,
50 public NotificationObserver { 50 public NotificationObserver {
51 public: 51 public:
52 BrowserActionButton(Extension* extension, BrowserActionsContainer* panel); 52 BrowserActionButton(Extension* extension, BrowserActionsContainer* panel);
53 ~BrowserActionButton(); 53
54 // Call this instead of delete.
55 void Destroy();
54 56
55 ExtensionAction* browser_action() const { return browser_action_; } 57 ExtensionAction* browser_action() const { return browser_action_; }
56 Extension* extension() { return extension_; } 58 Extension* extension() { return extension_; }
57 59
58 // Called to update the display to match the browser action's state. 60 // Called to update the display to match the browser action's state.
59 void UpdateState(); 61 void UpdateState();
60 62
61 // Returns the default icon, if any. 63 // Returns the default icon, if any.
62 const SkBitmap& default_icon() const { return default_icon_; } 64 const SkBitmap& default_icon() const { return default_icon_; }
63 65
(...skipping 23 matching lines...) Expand all
87 virtual void OnMouseReleased(const views::MouseEvent& e, bool canceled); 89 virtual void OnMouseReleased(const views::MouseEvent& e, bool canceled);
88 virtual bool OnKeyReleased(const views::KeyEvent& e); 90 virtual bool OnKeyReleased(const views::KeyEvent& e);
89 virtual void OnMouseExited(const views::MouseEvent& event); 91 virtual void OnMouseExited(const views::MouseEvent& event);
90 92
91 // Does this button's action have a popup? 93 // Does this button's action have a popup?
92 virtual bool IsPopup(); 94 virtual bool IsPopup();
93 virtual GURL GetPopupUrl(); 95 virtual GURL GetPopupUrl();
94 96
95 // Notifications when to set button state to pushed/not pushed (for when the 97 // Notifications when to set button state to pushed/not pushed (for when the
96 // popup/context menu is hidden or shown by the container). 98 // popup/context menu is hidden or shown by the container).
97 virtual void SetButtonPushed(); 99 void SetButtonPushed();
98 virtual void SetButtonNotPushed(); 100 void SetButtonNotPushed();
99 101
100 private: 102 private:
103 virtual ~BrowserActionButton();
104
101 // The browser action this view represents. The ExtensionAction is not owned 105 // The browser action this view represents. The ExtensionAction is not owned
102 // by this class. 106 // by this class.
103 ExtensionAction* browser_action_; 107 ExtensionAction* browser_action_;
104 108
105 // The extension associated with the browser action we're displaying. 109 // The extension associated with the browser action we're displaying.
106 Extension* extension_; 110 Extension* extension_;
107 111
108 // The object that is waiting for the image loading to complete 112 // The object that is waiting for the image loading to complete
109 // asynchronously. 113 // asynchronously.
110 ImageLoadingTracker tracker_; 114 ImageLoadingTracker tracker_;
111 115
112 // Whether we are currently showing/just finished showing a context menu. 116 // Whether we are currently showing/just finished showing a context menu.
113 bool showing_context_menu_; 117 bool showing_context_menu_;
114 118
115 // The default icon for our browser action. This might be non-empty if the 119 // The default icon for our browser action. This might be non-empty if the
116 // browser action had a value for default_icon in the manifest. 120 // browser action had a value for default_icon in the manifest.
117 SkBitmap default_icon_; 121 SkBitmap default_icon_;
118 122
119 // The browser action shelf. 123 // The browser action shelf.
120 BrowserActionsContainer* panel_; 124 BrowserActionsContainer* panel_;
121 125
122 scoped_ptr<ExtensionContextMenuModel> context_menu_contents_; 126 scoped_ptr<ExtensionContextMenuModel> context_menu_contents_;
123 scoped_ptr<views::Menu2> context_menu_menu_; 127 scoped_ptr<views::Menu2> context_menu_menu_;
124 128
125 NotificationRegistrar registrar_; 129 NotificationRegistrar registrar_;
126 130
131 friend class DeleteTask<BrowserActionButton>;
132
127 DISALLOW_COPY_AND_ASSIGN(BrowserActionButton); 133 DISALLOW_COPY_AND_ASSIGN(BrowserActionButton);
128 }; 134 };
129 135
130 136
131 //////////////////////////////////////////////////////////////////////////////// 137 ////////////////////////////////////////////////////////////////////////////////
132 // BrowserActionView 138 // BrowserActionView
133 // A single section in the browser action container. This contains the actual 139 // A single section in the browser action container. This contains the actual
134 // BrowserActionButton, as well as the logic to paint the badge. 140 // BrowserActionButton, as well as the logic to paint the badge.
135 141
136 class BrowserActionView : public views::View { 142 class BrowserActionView : public views::View {
137 public: 143 public:
138 BrowserActionView(Extension* extension, BrowserActionsContainer* panel); 144 BrowserActionView(Extension* extension, BrowserActionsContainer* panel);
145 virtual ~BrowserActionView();
146
139 BrowserActionButton* button() { return button_; } 147 BrowserActionButton* button() { return button_; }
140 148
141 // Allocates a canvas object on the heap and draws into it the icon for the 149 // Allocates a canvas object on the heap and draws into it the icon for the
142 // view as well as the badge (if any). Caller is responsible for deleting the 150 // view as well as the badge (if any). Caller is responsible for deleting the
143 // returned object. 151 // returned object.
144 gfx::Canvas* GetIconWithBadge(); 152 gfx::Canvas* GetIconWithBadge();
145 153
146 // Accessibility accessors, overridden from View. 154 // Accessibility accessors, overridden from View.
147 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); 155 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
148 virtual bool GetAccessibleName(std::wstring* name); 156 virtual bool GetAccessibleName(std::wstring* name);
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 486
479 ScopedRunnableMethodFactory<BrowserActionsContainer> task_factory_; 487 ScopedRunnableMethodFactory<BrowserActionsContainer> task_factory_;
480 488
481 // Handles delayed showing of the overflow menu when hovering. 489 // Handles delayed showing of the overflow menu when hovering.
482 ScopedRunnableMethodFactory<BrowserActionsContainer> show_menu_task_factory_; 490 ScopedRunnableMethodFactory<BrowserActionsContainer> show_menu_task_factory_;
483 491
484 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); 492 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer);
485 }; 493 };
486 494
487 #endif // CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ 495 #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