Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Side by Side Diff: ash/common/system/chromeos/settings/tray_settings.cc

Issue 2072013002: mash: Move tray settings and deps to common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undo 'git cl format' and nullptr changes. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/system/chromeos/settings/tray_settings.h" 5 #include "ash/common/system/chromeos/settings/tray_settings.h"
6 6
7 #include "ash/common/session/session_state_delegate.h" 7 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/common/system/chromeos/power/power_status.h"
9 #include "ash/common/system/chromeos/power/power_status_view.h"
8 #include "ash/common/system/tray/actionable_view.h" 10 #include "ash/common/system/tray/actionable_view.h"
9 #include "ash/common/system/tray/fixed_sized_image_view.h" 11 #include "ash/common/system/tray/fixed_sized_image_view.h"
10 #include "ash/common/system/tray/system_tray_delegate.h" 12 #include "ash/common/system/tray/system_tray_delegate.h"
11 #include "ash/common/system/tray/tray_constants.h" 13 #include "ash/common/system/tray/tray_constants.h"
12 #include "ash/common/wm_shell.h" 14 #include "ash/common/wm_shell.h"
13 #include "ash/shell.h"
14 #include "ash/system/chromeos/power/power_status.h"
15 #include "ash/system/chromeos/power/power_status_view.h"
16 #include "base/logging.h" 15 #include "base/logging.h"
17 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
18 #include "grit/ash_resources.h" 17 #include "grit/ash_resources.h"
19 #include "grit/ash_strings.h" 18 #include "grit/ash_strings.h"
20 #include "third_party/skia/include/core/SkColor.h" 19 #include "third_party/skia/include/core/SkColor.h"
21 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
22 #include "ui/gfx/image/image.h" 21 #include "ui/gfx/image/image.h"
23 #include "ui/views/controls/image_view.h" 22 #include "ui/views/controls/image_view.h"
24 #include "ui/views/controls/label.h" 23 #include "ui/views/controls/label.h"
25 #include "ui/views/layout/box_layout.h" 24 #include "ui/views/layout/box_layout.h"
26 #include "ui/views/layout/fill_layout.h" 25 #include "ui/views/layout/fill_layout.h"
27 #include "ui/views/view.h" 26 #include "ui/views/view.h"
28 27
29 namespace ash { 28 namespace ash {
30 namespace tray { 29 namespace tray {
31 30
32 class SettingsDefaultView : public ActionableView, 31 class SettingsDefaultView : public ActionableView,
33 public PowerStatus::Observer { 32 public PowerStatus::Observer {
34 public: 33 public:
35 explicit SettingsDefaultView(LoginStatus status) 34 explicit SettingsDefaultView(LoginStatus status)
36 : login_status_(status), label_(NULL), power_status_view_(NULL) { 35 : login_status_(status), label_(NULL), power_status_view_(NULL) {
37 PowerStatus::Get()->AddObserver(this); 36 PowerStatus::Get()->AddObserver(this);
38 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, 37 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
39 ash::kTrayPopupPaddingHorizontal, 0, 38 ash::kTrayPopupPaddingHorizontal, 0,
40 ash::kTrayPopupPaddingBetweenItems)); 39 ash::kTrayPopupPaddingBetweenItems));
41 40
42 bool power_view_right_align = false; 41 bool power_view_right_align = false;
43 bool userAddingRunning = ash::Shell::GetInstance()
44 ->session_state_delegate()
45 ->IsInSecondaryLoginScreen();
46
47 if (login_status_ != LoginStatus::NOT_LOGGED_IN && 42 if (login_status_ != LoginStatus::NOT_LOGGED_IN &&
48 login_status_ != LoginStatus::LOCKED && !userAddingRunning) { 43 login_status_ != LoginStatus::LOCKED &&
44 !WmShell::Get()
45 ->GetSessionStateDelegate()
46 ->IsInSecondaryLoginScreen()) {
49 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 47 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
50 views::ImageView* icon = 48 views::ImageView* icon =
51 new ash::FixedSizedImageView(0, ash::kTrayPopupItemHeight); 49 new ash::FixedSizedImageView(0, ash::kTrayPopupItemHeight);
52 icon->SetImage( 50 icon->SetImage(
53 rb.GetImageNamed(IDR_AURA_UBER_TRAY_SETTINGS).ToImageSkia()); 51 rb.GetImageNamed(IDR_AURA_UBER_TRAY_SETTINGS).ToImageSkia());
54 icon->set_id(test::kSettingsTrayItemViewId); 52 icon->set_id(test::kSettingsTrayItemViewId);
55 AddChildView(icon); 53 AddChildView(icon);
56 54
57 base::string16 text = rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_SETTINGS); 55 base::string16 text = rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_SETTINGS);
58 label_ = new views::Label(text); 56 label_ = new views::Label(text);
59 AddChildView(label_); 57 AddChildView(label_);
60 SetAccessibleName(text); 58 SetAccessibleName(text);
61 59
62 power_view_right_align = true; 60 power_view_right_align = true;
63 } 61 }
64 62
65 if (PowerStatus::Get()->IsBatteryPresent()) { 63 if (PowerStatus::Get()->IsBatteryPresent()) {
66 power_status_view_ = new ash::PowerStatusView(power_view_right_align); 64 power_status_view_ = new ash::PowerStatusView(power_view_right_align);
67 AddChildView(power_status_view_); 65 AddChildView(power_status_view_);
68 OnPowerStatusChanged(); 66 OnPowerStatusChanged();
69 } 67 }
70 } 68 }
71 69
72 ~SettingsDefaultView() override { PowerStatus::Get()->RemoveObserver(this); } 70 ~SettingsDefaultView() override { PowerStatus::Get()->RemoveObserver(this); }
73 71
74 // Overridden from ash::ActionableView. 72 // Overridden from ash::ActionableView.
75 bool PerformAction(const ui::Event& event) override { 73 bool PerformAction(const ui::Event& event) override {
76 bool adding_user = Shell::GetInstance()
77 ->session_state_delegate()
78 ->IsInSecondaryLoginScreen();
79
80 if (login_status_ == LoginStatus::NOT_LOGGED_IN || 74 if (login_status_ == LoginStatus::NOT_LOGGED_IN ||
81 login_status_ == LoginStatus::LOCKED || adding_user) { 75 login_status_ == LoginStatus::LOCKED ||
76 WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) {
82 return false; 77 return false;
83 } 78 }
84 79
85 WmShell::Get()->system_tray_delegate()->ShowSettings(); 80 WmShell::Get()->system_tray_delegate()->ShowSettings();
86 return true; 81 return true;
87 } 82 }
88 83
89 // Overridden from views::View. 84 // Overridden from views::View.
90 void Layout() override { 85 void Layout() override {
91 views::View::Layout(); 86 views::View::Layout();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 CHECK(default_view_ == NULL); 145 CHECK(default_view_ == NULL);
151 default_view_ = new tray::SettingsDefaultView(status); 146 default_view_ = new tray::SettingsDefaultView(status);
152 return default_view_; 147 return default_view_;
153 } 148 }
154 149
155 views::View* TraySettings::CreateDetailedView(LoginStatus status) { 150 views::View* TraySettings::CreateDetailedView(LoginStatus status) {
156 NOTIMPLEMENTED(); 151 NOTIMPLEMENTED();
157 return NULL; 152 return NULL;
158 } 153 }
159 154
160 void TraySettings::DestroyTrayView() { 155 void TraySettings::DestroyTrayView() {}
161 }
162 156
163 void TraySettings::DestroyDefaultView() { 157 void TraySettings::DestroyDefaultView() {
164 default_view_ = NULL; 158 default_view_ = NULL;
165 } 159 }
166 160
167 void TraySettings::DestroyDetailedView() { 161 void TraySettings::DestroyDetailedView() {}
168 }
169 162
170 void TraySettings::UpdateAfterLoginStatusChange(LoginStatus status) {} 163 void TraySettings::UpdateAfterLoginStatusChange(LoginStatus status) {}
171 164
172 } // namespace ash 165 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698