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
3 // found in the LICENSE file.
5 #include "chrome/browser/status_icons/status_icon.h"
7 #include "chrome/browser/status_icons/status_icon_observer.h"
9 StatusIcon::StatusIcon() {
12 StatusIcon::~StatusIcon() {
15 void StatusIcon::AddObserver(StatusIconObserver
* observer
) {
16 observers_
.AddObserver(observer
);
19 void StatusIcon::RemoveObserver(StatusIconObserver
* observer
) {
20 observers_
.RemoveObserver(observer
);
23 bool StatusIcon::HasObservers() const {
24 return observers_
.might_have_observers();
27 void StatusIcon::DispatchClickEvent() {
28 FOR_EACH_OBSERVER(StatusIconObserver
, observers_
, OnStatusIconClicked());
32 void StatusIcon::DispatchBalloonClickEvent() {
33 FOR_EACH_OBSERVER(StatusIconObserver
, observers_
, OnBalloonClicked());
37 void StatusIcon::ForceVisible() {}
39 void StatusIcon::SetContextMenu(scoped_ptr
<StatusIconMenuModel
> menu
) {
40 // The UI may been showing a menu for the current model, don't destroy it
41 // until we've notified the UI of the change.
42 scoped_ptr
<StatusIconMenuModel
> old_menu
= context_menu_contents_
.Pass();
43 context_menu_contents_
= menu
.Pass();
44 UpdatePlatformContextMenu(context_menu_contents_
.get());