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 "ash/system/chromeos/enterprise/tray_enterprise.h"
8 #include "ash/system/chromeos/label_tray_view.h"
9 #include "ash/system/tray/system_tray_notifier.h"
10 #include "ash/system/user/login_status.h"
11 #include "base/logging.h"
12 #include "grit/ash_resources.h"
17 TrayEnterprise::TrayEnterprise(SystemTray* system_tray)
18 : SystemTrayItem(system_tray),
20 Shell::GetInstance()->system_tray_notifier()->
21 AddEnterpriseDomainObserver(this);
24 TrayEnterprise::~TrayEnterprise() {
25 Shell::GetInstance()->system_tray_notifier()->
26 RemoveEnterpriseDomainObserver(this);
29 void TrayEnterprise::UpdateEnterpriseMessage() {
30 base::string16 message = Shell::GetInstance()->system_tray_delegate()->
31 GetEnterpriseMessage();
33 tray_view_->SetMessage(message);
36 views::View* TrayEnterprise::CreateDefaultView(user::LoginStatus status) {
37 CHECK(tray_view_ == NULL);
38 // For public accounts, enterprise ownership is indicated in the user details
40 if (status == ash::user::LOGGED_IN_PUBLIC)
42 tray_view_ = new LabelTrayView(this, IDR_AURA_UBER_TRAY_ENTERPRISE_DARK);
43 UpdateEnterpriseMessage();
47 void TrayEnterprise::DestroyDefaultView() {
51 void TrayEnterprise::OnEnterpriseDomainChanged() {
52 UpdateEnterpriseMessage();
55 void TrayEnterprise::OnViewClicked(views::View* sender) {
56 Shell::GetInstance()->system_tray_delegate()->ShowEnterpriseInfo();
59 } // namespace internal