| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/webui/chromeos/set_time_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/set_time_ui.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | |
| 8 #include "ash/system/tray/system_tray_delegate.h" | |
| 9 #include "ash/system/user/login_status.h" | |
| 10 #include "base/bind.h" | 7 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 12 #include "base/build_time.h" | 9 #include "base/build_time.h" |
| 13 #include "base/values.h" | 10 #include "base/values.h" |
| 14 #include "chrome/browser/chromeos/settings/cros_settings.h" | 11 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 15 #include "chrome/browser/chromeos/system/timezone_util.h" | 12 #include "chrome/browser/chromeos/system/timezone_util.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 18 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 19 #include "chromeos/dbus/dbus_thread_manager.h" | 16 #include "chromeos/dbus/dbus_thread_manager.h" |
| 20 #include "chromeos/dbus/system_clock_client.h" | 17 #include "chromeos/dbus/system_clock_client.h" |
| 18 #include "chromeos/login/login_state.h" |
| 21 #include "chromeos/settings/timezone_settings.h" | 19 #include "chromeos/settings/timezone_settings.h" |
| 22 #include "content/public/browser/web_ui.h" | 20 #include "content/public/browser/web_ui.h" |
| 23 #include "content/public/browser/web_ui_data_source.h" | 21 #include "content/public/browser/web_ui_data_source.h" |
| 24 #include "content/public/browser/web_ui_message_handler.h" | 22 #include "content/public/browser/web_ui_message_handler.h" |
| 25 #include "grit/browser_resources.h" | 23 #include "grit/browser_resources.h" |
| 26 | 24 |
| 27 namespace chromeos { | 25 namespace chromeos { |
| 28 | 26 |
| 29 namespace { | 27 namespace { |
| 30 | 28 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 IDS_OPTIONS_SETTINGS_TIMEZONE_DESCRIPTION); | 113 IDS_OPTIONS_SETTINGS_TIMEZONE_DESCRIPTION); |
| 116 source->AddLocalizedString("dateLabel", IDS_SET_TIME_DATE_LABEL); | 114 source->AddLocalizedString("dateLabel", IDS_SET_TIME_DATE_LABEL); |
| 117 source->AddLocalizedString("timeLabel", IDS_SET_TIME_TIME_LABEL); | 115 source->AddLocalizedString("timeLabel", IDS_SET_TIME_TIME_LABEL); |
| 118 | 116 |
| 119 base::DictionaryValue values; | 117 base::DictionaryValue values; |
| 120 values.Set("timezoneList", chromeos::system::GetTimezoneList().release()); | 118 values.Set("timezoneList", chromeos::system::GetTimezoneList().release()); |
| 121 | 119 |
| 122 // If we are not logged in, we need to show the time zone dropdown. | 120 // If we are not logged in, we need to show the time zone dropdown. |
| 123 // Otherwise, we can leave |currentTimezoneId| blank. | 121 // Otherwise, we can leave |currentTimezoneId| blank. |
| 124 std::string current_timezone_id; | 122 std::string current_timezone_id; |
| 125 if (ash::Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus() == | 123 if (!LoginState::Get()->IsUserLoggedIn()) |
| 126 ash::user::LOGGED_IN_NONE) { | |
| 127 CrosSettings::Get()->GetString(kSystemTimezone, ¤t_timezone_id); | 124 CrosSettings::Get()->GetString(kSystemTimezone, ¤t_timezone_id); |
| 128 } | |
| 129 values.SetString("currentTimezoneId", current_timezone_id); | 125 values.SetString("currentTimezoneId", current_timezone_id); |
| 130 values.SetDouble("buildTime", base::GetBuildTime().ToJsTime()); | 126 values.SetDouble("buildTime", base::GetBuildTime().ToJsTime()); |
| 131 | 127 |
| 132 source->AddLocalizedStrings(values); | 128 source->AddLocalizedStrings(values); |
| 133 source->SetJsonPath("strings.js"); | 129 source->SetJsonPath("strings.js"); |
| 134 | 130 |
| 135 source->AddResourcePath("set_time.css", IDR_SET_TIME_CSS); | 131 source->AddResourcePath("set_time.css", IDR_SET_TIME_CSS); |
| 136 source->AddResourcePath("set_time.js", IDR_SET_TIME_JS); | 132 source->AddResourcePath("set_time.js", IDR_SET_TIME_JS); |
| 137 source->SetDefaultResource(IDR_SET_TIME_HTML); | 133 source->SetDefaultResource(IDR_SET_TIME_HTML); |
| 138 | 134 |
| 139 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source); | 135 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source); |
| 140 } | 136 } |
| 141 | 137 |
| 142 SetTimeUI::~SetTimeUI() { | 138 SetTimeUI::~SetTimeUI() { |
| 143 } | 139 } |
| 144 | 140 |
| 145 } // namespace chromeos | 141 } // namespace chromeos |
| OLD | NEW |