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

Side by Side Diff: chrome/browser/ui/ash/system_tray_delegate_common.cc

Issue 1960293003: Remove OS_CHROMEOS from ui/ash code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
msw 2016/05/09 22:42:49 Odd that this file is marked as modified, not remo
oshima 2016/05/09 23:08:41 Yes, I noticed that, but I couldn't figure out how
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/ash/system_tray_delegate_common.h"
6
7 #include "ash/networking_config_delegate.h"
8 #include "ash/shell.h"
9 #include "ash/shell_delegate.h"
10 #include "ash/system/tray/system_tray.h"
11 #include "ash/system/tray/system_tray_notifier.h"
12 #include "ash/volume_control_delegate.h"
13 #include "base/time/time.h"
14 #include "build/build_config.h"
15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/lifetime/application_lifetime.h"
17 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/browser/ui/ash/system_tray_delegate_utils.h"
19 #include "chrome/browser/ui/chrome_pages.h"
20 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
21 #include "chrome/browser/upgrade_detector.h"
22 #include "chrome/grit/locale_settings.h"
23 #include "content/public/browser/notification_service.h"
24 #include "ui/base/l10n/l10n_util.h"
25
26 namespace {
27
28 ash::SystemTrayNotifier* GetSystemTrayNotifier() {
29 return ash::Shell::GetInstance()->system_tray_notifier();
30 }
31
32 } // namespace
33
34 SystemTrayDelegateCommon::SystemTrayDelegateCommon()
35 : clock_type_(base::GetHourClockType()) {
36 // Register notifications on construction so that events such as
37 // PROFILE_CREATED do not get missed if they happen before Initialize().
38 registrar_.reset(new content::NotificationRegistrar);
39 registrar_->Add(this,
40 chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
41 content::NotificationService::AllSources());
42 }
43
44 SystemTrayDelegateCommon::~SystemTrayDelegateCommon() {
45 registrar_.reset();
46 }
47
48 // Overridden from ash::SystemTrayDelegate:
49 void SystemTrayDelegateCommon::Initialize() {
50 UpdateClockType();
51 }
52
53 void SystemTrayDelegateCommon::Shutdown() {
54 }
55
56 bool SystemTrayDelegateCommon::GetTrayVisibilityOnStartup() {
57 return true;
58 }
59
60 ash::user::LoginStatus SystemTrayDelegateCommon::GetUserLoginStatus() const {
61 return ash::user::LOGGED_IN_OWNER;
62 }
63
64 bool SystemTrayDelegateCommon::IsUserSupervised() const {
65 return false;
66 }
67
68 bool SystemTrayDelegateCommon::IsUserChild() const {
69 return false;
70 }
71
72 void SystemTrayDelegateCommon::GetSystemUpdateInfo(
73 ash::UpdateInfo* info) const {
74 GetUpdateInfo(UpgradeDetector::GetInstance(), info);
75 }
76
77 base::HourClockType SystemTrayDelegateCommon::GetHourClockType() const {
78 return clock_type_;
79 }
80
81 void SystemTrayDelegateCommon::ShowChromeSlow() {
82 #if defined(OS_LINUX)
83 chrome::ScopedTabbedBrowserDisplayer displayer(
84 ProfileManager::GetPrimaryUserProfile());
85 chrome::ShowSlow(displayer.browser());
86 #endif // defined(OS_LINUX)
87 }
88
89 void SystemTrayDelegateCommon::ShowHelp() {
90 chrome::ShowHelpForProfile(ProfileManager::GetLastUsedProfile(),
91 chrome::HELP_SOURCE_MENU);
92 }
93
94 void SystemTrayDelegateCommon::RequestRestartForUpdate() {
95 chrome::AttemptRestart();
96 }
97
98 int SystemTrayDelegateCommon::GetSystemTrayMenuWidth() {
99 return l10n_util::GetLocalizedContentsWidthInPixels(
100 IDS_SYSTEM_TRAY_MENU_BUBBLE_WIDTH_PIXELS);
101 }
102
103 void SystemTrayDelegateCommon::UpdateClockType() {
104 clock_type_ = (base::GetHourClockType() == base::k24HourClock)
105 ? base::k24HourClock
106 : base::k12HourClock;
107 GetSystemTrayNotifier()->NotifyDateFormatChanged();
108 }
109
110 void SystemTrayDelegateCommon::Observe(
111 int type,
112 const content::NotificationSource& source,
113 const content::NotificationDetails& details) {
114 if (type == chrome::NOTIFICATION_UPGRADE_RECOMMENDED) {
115 ash::UpdateInfo info;
116 GetUpdateInfo(content::Source<UpgradeDetector>(source).ptr(), &info);
117 GetSystemTrayNotifier()->NotifyUpdateRecommended(info);
118 } else {
119 NOTREACHED();
120 }
121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698