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

Side by Side Diff: chrome/browser/status_icons/status_icon.cc

Issue 23190045: Switch ObserverList::size() to ObserverList::might_have_observers() Pt.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pure merge Created 7 years, 3 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) 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 #include "chrome/browser/status_icons/status_icon.h" 5 #include "chrome/browser/status_icons/status_icon.h"
6 6
7 #include "chrome/browser/status_icons/status_icon_observer.h" 7 #include "chrome/browser/status_icons/status_icon_observer.h"
8 #include "ui/base/models/menu_model.h" 8 #include "ui/base/models/menu_model.h"
9 9
10 StatusIcon::StatusIcon() { 10 StatusIcon::StatusIcon() {
11 } 11 }
12 12
13 StatusIcon::~StatusIcon() { 13 StatusIcon::~StatusIcon() {
14 } 14 }
15 15
16 void StatusIcon::AddObserver(StatusIconObserver* observer) { 16 void StatusIcon::AddObserver(StatusIconObserver* observer) {
17 observers_.AddObserver(observer); 17 observers_.AddObserver(observer);
18 } 18 }
19 19
20 void StatusIcon::RemoveObserver(StatusIconObserver* observer) { 20 void StatusIcon::RemoveObserver(StatusIconObserver* observer) {
21 observers_.RemoveObserver(observer); 21 observers_.RemoveObserver(observer);
22 } 22 }
23 23
24 bool StatusIcon::HasObservers() const { 24 bool StatusIcon::HasObservers() const {
25 return observers_.size() > 0; 25 return observers_.might_have_observers();
26 } 26 }
27 27
28 void StatusIcon::DispatchClickEvent() { 28 void StatusIcon::DispatchClickEvent() {
29 FOR_EACH_OBSERVER(StatusIconObserver, observers_, OnStatusIconClicked()); 29 FOR_EACH_OBSERVER(StatusIconObserver, observers_, OnStatusIconClicked());
30 } 30 }
31 31
32 #if defined(OS_WIN) 32 #if defined(OS_WIN)
33 void StatusIcon::DispatchBalloonClickEvent() { 33 void StatusIcon::DispatchBalloonClickEvent() {
34 FOR_EACH_OBSERVER(StatusIconObserver, observers_, OnBalloonClicked()); 34 FOR_EACH_OBSERVER(StatusIconObserver, observers_, OnBalloonClicked());
35 } 35 }
36 #endif 36 #endif
37 37
38 void StatusIcon::SetContextMenu(ui::MenuModel* menu) { 38 void StatusIcon::SetContextMenu(ui::MenuModel* menu) {
39 // The UI may been showing a menu for the current model, don't destroy it 39 // The UI may been showing a menu for the current model, don't destroy it
40 // until we've notified the UI of the change. 40 // until we've notified the UI of the change.
41 scoped_ptr<ui::MenuModel> old_menu = context_menu_contents_.Pass(); 41 scoped_ptr<ui::MenuModel> old_menu = context_menu_contents_.Pass();
42 context_menu_contents_.reset(menu); 42 context_menu_contents_.reset(menu);
43 UpdatePlatformContextMenu(menu); 43 UpdatePlatformContextMenu(menu);
44 } 44 }
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_service_impl.cc ('k') | chrome/browser/ui/panels/display_settings_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698