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. 4 5 #include "chrome/browser/status_icons/status_icon.h" 6 7 #include "chrome/browser/status_icons/status_icon_observer.h" 8 9 StatusIcon::StatusIcon() { 10 } 11 12 StatusIcon::~StatusIcon() { 13 } 14 15 void StatusIcon::AddObserver(StatusIconObserver* observer) { 16 observers_.AddObserver(observer); 17 } 18 19 void StatusIcon::RemoveObserver(StatusIconObserver* observer) { 20 observers_.RemoveObserver(observer); 21 } 22 23 bool StatusIcon::HasObservers() const { 24 return observers_.might_have_observers(); 25 } 26 27 void StatusIcon::DispatchClickEvent() { 28 FOR_EACH_OBSERVER(StatusIconObserver, observers_, OnStatusIconClicked()); 29 } 30 31 #if defined(OS_WIN) 32 void StatusIcon::DispatchBalloonClickEvent() { 33 FOR_EACH_OBSERVER(StatusIconObserver, observers_, OnBalloonClicked()); 34 } 35 #endif 36 37 void StatusIcon::ForceVisible() {} 38 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()); 45 } 46