Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ash / system / chromeos / enterprise / tray_enterprise.cc
blob23e954f456663a97eefce9e93128c2303435ddf8
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"
7 #include "ash/shell.h"
8 #include "ash/system/chromeos/label_tray_view.h"
9 #include "ash/system/tray/system_tray_delegate.h"
10 #include "ash/system/tray/system_tray_notifier.h"
11 #include "ash/system/user/login_status.h"
12 #include "base/logging.h"
13 #include "base/strings/string16.h"
14 #include "grit/ash_resources.h"
16 namespace ash {
18 TrayEnterprise::TrayEnterprise(SystemTray* system_tray)
19 : SystemTrayItem(system_tray),
20 tray_view_(NULL) {
21 Shell::GetInstance()->system_tray_notifier()->
22 AddEnterpriseDomainObserver(this);
25 TrayEnterprise::~TrayEnterprise() {
26 Shell::GetInstance()->system_tray_notifier()->
27 RemoveEnterpriseDomainObserver(this);
30 void TrayEnterprise::UpdateEnterpriseMessage() {
31 base::string16 message = Shell::GetInstance()->system_tray_delegate()->
32 GetEnterpriseMessage();
33 if (tray_view_)
34 tray_view_->SetMessage(message);
37 views::View* TrayEnterprise::CreateDefaultView(user::LoginStatus status) {
38 CHECK(tray_view_ == NULL);
39 // For public accounts, enterprise ownership is indicated in the user details
40 // instead.
41 if (status == ash::user::LOGGED_IN_PUBLIC)
42 return NULL;
43 tray_view_ = new LabelTrayView(this, IDR_AURA_UBER_TRAY_ENTERPRISE);
44 UpdateEnterpriseMessage();
45 return tray_view_;
48 void TrayEnterprise::DestroyDefaultView() {
49 tray_view_ = NULL;
52 void TrayEnterprise::OnEnterpriseDomainChanged() {
53 UpdateEnterpriseMessage();
56 void TrayEnterprise::OnViewClicked(views::View* sender) {
57 Shell::GetInstance()->system_tray_delegate()->ShowEnterpriseInfo();
60 } // namespace ash