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

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

Issue 2225003: Implement upgrade notifications.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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
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_TOOLBAR_VIEW_H_ 5 #ifndef CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_
6 #define CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ 6 #define CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "app/menus/simple_menu_model.h" 10 #include "app/menus/simple_menu_model.h"
11 #include "app/slide_animation.h"
11 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
12 #include "chrome/browser/app_menu_model.h" 13 #include "chrome/browser/app_menu_model.h"
13 #include "chrome/browser/back_forward_menu_model.h" 14 #include "chrome/browser/back_forward_menu_model.h"
14 #include "chrome/browser/command_updater.h" 15 #include "chrome/browser/command_updater.h"
15 #include "chrome/browser/page_menu_model.h" 16 #include "chrome/browser/page_menu_model.h"
16 #include "chrome/browser/pref_member.h" 17 #include "chrome/browser/pref_member.h"
17 #include "chrome/browser/views/accessible_toolbar_view.h" 18 #include "chrome/browser/views/accessible_toolbar_view.h"
18 #include "chrome/browser/views/go_button.h" 19 #include "chrome/browser/views/go_button.h"
19 #include "chrome/browser/views/location_bar/location_bar_view.h" 20 #include "chrome/browser/views/location_bar/location_bar_view.h"
20 #include "views/controls/button/menu_button.h" 21 #include "views/controls/button/menu_button.h"
(...skipping 10 matching lines...) Expand all
31 namespace views { 32 namespace views {
32 class Menu2; 33 class Menu2;
33 } 34 }
34 35
35 // The Browser Window's toolbar. 36 // The Browser Window's toolbar.
36 class ToolbarView : public AccessibleToolbarView, 37 class ToolbarView : public AccessibleToolbarView,
37 public views::ViewMenuDelegate, 38 public views::ViewMenuDelegate,
38 public views::FocusChangeListener, 39 public views::FocusChangeListener,
39 public menus::SimpleMenuModel::Delegate, 40 public menus::SimpleMenuModel::Delegate,
40 public LocationBarView::Delegate, 41 public LocationBarView::Delegate,
42 public AnimationDelegate,
41 public NotificationObserver, 43 public NotificationObserver,
42 public CommandUpdater::CommandObserver, 44 public CommandUpdater::CommandObserver,
43 public views::ButtonListener { 45 public views::ButtonListener {
44 public: 46 public:
45 explicit ToolbarView(Browser* browser); 47 explicit ToolbarView(Browser* browser);
46 virtual ~ToolbarView(); 48 virtual ~ToolbarView();
47 49
48 // Create the contents of the Browser Toolbar 50 // Create the contents of the Browser Toolbar
49 void Init(Profile* profile); 51 void Init(Profile* profile);
50 52
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // Overridden from Menu::BaseControllerDelegate: 102 // Overridden from Menu::BaseControllerDelegate:
101 virtual bool GetAcceleratorInfo(int id, menus::Accelerator* accel); 103 virtual bool GetAcceleratorInfo(int id, menus::Accelerator* accel);
102 104
103 // Overridden from views::MenuDelegate: 105 // Overridden from views::MenuDelegate:
104 virtual void RunMenu(views::View* source, const gfx::Point& pt); 106 virtual void RunMenu(views::View* source, const gfx::Point& pt);
105 107
106 // Overridden from LocationBarView::Delegate: 108 // Overridden from LocationBarView::Delegate:
107 virtual TabContents* GetTabContents(); 109 virtual TabContents* GetTabContents();
108 virtual void OnInputInProgress(bool in_progress); 110 virtual void OnInputInProgress(bool in_progress);
109 111
112 // Overridden from AnimationDelegate:
113 virtual void AnimationProgressed(const Animation* animation);
114
110 // Overridden from CommandUpdater::CommandObserver: 115 // Overridden from CommandUpdater::CommandObserver:
111 virtual void EnabledStateChangedForCommand(int id, bool enabled); 116 virtual void EnabledStateChangedForCommand(int id, bool enabled);
112 117
113 // Overridden from views::BaseButton::ButtonListener: 118 // Overridden from views::BaseButton::ButtonListener:
114 virtual void ButtonPressed(views::Button* sender, const views::Event& event); 119 virtual void ButtonPressed(views::Button* sender, const views::Event& event);
115 120
116 // Overridden from NotificationObserver: 121 // Overridden from NotificationObserver:
117 virtual void Observe(NotificationType type, 122 virtual void Observe(NotificationType type,
118 const NotificationSource& source, 123 const NotificationSource& source,
119 const NotificationDetails& details); 124 const NotificationDetails& details);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 171 }
167 172
168 // Take the menus out of the focus traversal, unregister accelerators, 173 // Take the menus out of the focus traversal, unregister accelerators,
169 // and stop listening to focus change events. 174 // and stop listening to focus change events.
170 void ExitMenuBarEmulationMode(); 175 void ExitMenuBarEmulationMode();
171 176
172 // Restore the view that was focused before EnterMenuBarEmulationMode 177 // Restore the view that was focused before EnterMenuBarEmulationMode
173 // was called. 178 // was called.
174 void RestoreLastFocusedView(); 179 void RestoreLastFocusedView();
175 180
181 // Starts the recurring timer that periodically asks the upgrade notifier
182 // to pulsate.
183 void ShowUpgradeReminder();
184
185 // Show the reminder, tempting the user to upgrade by pulsating.
186 void PulsateUpgradeNotifier();
187
188 // Gets a canvas with the icon for the app menu. It will possibly contain
189 // an overlaid badge if an update is recommended.
190 SkBitmap GetAppMenuIcon();
191
176 scoped_ptr<BackForwardMenuModel> back_menu_model_; 192 scoped_ptr<BackForwardMenuModel> back_menu_model_;
177 scoped_ptr<BackForwardMenuModel> forward_menu_model_; 193 scoped_ptr<BackForwardMenuModel> forward_menu_model_;
178 194
179 // The model that contains the security level, text, icon to display... 195 // The model that contains the security level, text, icon to display...
180 ToolbarModel* model_; 196 ToolbarModel* model_;
181 197
182 // Controls 198 // Controls
183 views::ImageButton* back_; 199 views::ImageButton* back_;
184 views::ImageButton* forward_; 200 views::ImageButton* forward_;
185 views::ImageButton* home_; 201 views::ImageButton* home_;
(...skipping 29 matching lines...) Expand all
215 // so that we can remove focus listeners in the destructor. 231 // so that we can remove focus listeners in the destructor.
216 views::FocusManager* focus_manager_; 232 views::FocusManager* focus_manager_;
217 233
218 // Storage id for the last view that was focused before focus 234 // Storage id for the last view that was focused before focus
219 // was given to one of the toolbar views. 235 // was given to one of the toolbar views.
220 int last_focused_view_storage_id_; 236 int last_focused_view_storage_id_;
221 237
222 // Vector of listeners to receive callbacks when the menu opens. 238 // Vector of listeners to receive callbacks when the menu opens.
223 std::vector<views::MenuListener*> menu_listeners_; 239 std::vector<views::MenuListener*> menu_listeners_;
224 240
241 // The animation that makes the update reminder pulse.
242 scoped_ptr<SlideAnimation> update_reminder_animation_;
243
244 // We periodically restart the animation after it has been showed
245 // once, to create a pulsating effect.
246 base::RepeatingTimer<ToolbarView> upgrade_reminder_pulse_timer_;
247
225 // Are we in the menu bar emulation mode, where the app and page menu 248 // Are we in the menu bar emulation mode, where the app and page menu
226 // are temporarily focusable? 249 // are temporarily focusable?
227 bool menu_bar_emulation_mode_; 250 bool menu_bar_emulation_mode_;
228 251
229 // Used to post tasks to switch to the next/previous menu. 252 // Used to post tasks to switch to the next/previous menu.
230 ScopedRunnableMethodFactory<ToolbarView> method_factory_; 253 ScopedRunnableMethodFactory<ToolbarView> method_factory_;
231 254
232 // If non-null the destuctor sets this to true. This is set to a non-null 255 NotificationRegistrar registrar_;
256
257 // If non-null the destructor sets this to true. This is set to a non-null
233 // while the menu is showing and used to detect if the menu was deleted while 258 // while the menu is showing and used to detect if the menu was deleted while
234 // running. 259 // running.
235 bool* destroyed_flag_; 260 bool* destroyed_flag_;
236 261
237 // When collapsed, the toolbar is just a tiny strip, no controls are visible. 262 // When collapsed, the toolbar is just a tiny strip, no controls are visible.
238 bool collapsed_; 263 bool collapsed_;
239 264
240 DISALLOW_IMPLICIT_CONSTRUCTORS(ToolbarView); 265 DISALLOW_IMPLICIT_CONSTRUCTORS(ToolbarView);
241 }; 266 };
242 267
243 #endif // CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ 268 #endif // CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698