| OLD | NEW |
| (Empty) |
| 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/ui/views/aura/multiple_window_indicator_button.h" | |
| 6 | |
| 7 #include "grit/theme_resources.h" | |
| 8 #include "ui/base/resource/resource_bundle.h" | |
| 9 #include "ui/gfx/image/image.h" | |
| 10 #include "ui/views/border.h" | |
| 11 | |
| 12 MultipleWindowIndicatorButton::MultipleWindowIndicatorButton( | |
| 13 StatusAreaButton::Delegate* delegate) | |
| 14 : StatusAreaButton(delegate, NULL) { | |
| 15 SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed( | |
| 16 IDR_STATUSBAR_MULTIPLE_WINDOW)); | |
| 17 UpdateVisiblity(); | |
| 18 BrowserList::AddObserver(this); | |
| 19 } | |
| 20 | |
| 21 MultipleWindowIndicatorButton::~MultipleWindowIndicatorButton() { | |
| 22 BrowserList::RemoveObserver(this); | |
| 23 } | |
| 24 | |
| 25 void MultipleWindowIndicatorButton::OnBrowserAdded(const Browser* browser) { | |
| 26 UpdateVisiblity(); | |
| 27 } | |
| 28 | |
| 29 void MultipleWindowIndicatorButton::OnBrowserRemoved(const Browser* browser) { | |
| 30 UpdateVisiblity(); | |
| 31 } | |
| 32 | |
| 33 void MultipleWindowIndicatorButton::UpdateVisiblity() { | |
| 34 bool visible = false; | |
| 35 int count = 0; | |
| 36 for (BrowserList::const_iterator it = BrowserList::begin(); | |
| 37 it != BrowserList::end(); ++it) { | |
| 38 if ((*it)->is_type_tabbed()) { | |
| 39 ++count; | |
| 40 if (count >= 2) { | |
| 41 visible = true; | |
| 42 break; | |
| 43 } | |
| 44 } | |
| 45 } | |
| 46 SetVisible(visible); | |
| 47 } | |
| 48 | |
| OLD | NEW |