| 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" |
| 21 #include "chromeos/settings/timezone_settings.h" | 18 #include "chromeos/settings/timezone_settings.h" |
| 22 #include "content/public/browser/web_ui.h" | 19 #include "content/public/browser/web_ui.h" |
| 23 #include "content/public/browser/web_ui_data_source.h" | 20 #include "content/public/browser/web_ui_data_source.h" |
| 24 #include "content/public/browser/web_ui_message_handler.h" | 21 #include "content/public/browser/web_ui_message_handler.h" |
| 25 #include "grit/browser_resources.h" | 22 #include "grit/browser_resources.h" |
| 26 | 23 |
| 24 #if defined(USE_ASH) |
| 25 #include "ash/shell.h" |
| 26 #include "ash/system/tray/system_tray_delegate.h" |
| 27 #include "ash/system/user/login_status.h" |
| 28 #endif |
| 29 |
| 27 namespace chromeos { | 30 namespace chromeos { |
| 28 | 31 |
| 29 namespace { | 32 namespace { |
| 30 | 33 |
| 31 class SetTimeMessageHandler : public content::WebUIMessageHandler, | 34 class SetTimeMessageHandler : public content::WebUIMessageHandler, |
| 32 public chromeos::SystemClockClient::Observer, | 35 public chromeos::SystemClockClient::Observer, |
| 33 public system::TimezoneSettings::Observer { | 36 public system::TimezoneSettings::Observer { |
| 34 public: | 37 public: |
| 35 SetTimeMessageHandler() { | 38 SetTimeMessageHandler() { |
| 36 system::TimezoneSettings::GetInstance()->AddObserver(this); | 39 system::TimezoneSettings::GetInstance()->AddObserver(this); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 IDS_OPTIONS_SETTINGS_TIMEZONE_DESCRIPTION); | 118 IDS_OPTIONS_SETTINGS_TIMEZONE_DESCRIPTION); |
| 116 source->AddLocalizedString("dateLabel", IDS_SET_TIME_DATE_LABEL); | 119 source->AddLocalizedString("dateLabel", IDS_SET_TIME_DATE_LABEL); |
| 117 source->AddLocalizedString("timeLabel", IDS_SET_TIME_TIME_LABEL); | 120 source->AddLocalizedString("timeLabel", IDS_SET_TIME_TIME_LABEL); |
| 118 | 121 |
| 119 base::DictionaryValue values; | 122 base::DictionaryValue values; |
| 120 values.Set("timezoneList", chromeos::system::GetTimezoneList().release()); | 123 values.Set("timezoneList", chromeos::system::GetTimezoneList().release()); |
| 121 | 124 |
| 122 // If we are not logged in, we need to show the time zone dropdown. | 125 // If we are not logged in, we need to show the time zone dropdown. |
| 123 // Otherwise, we can leave |currentTimezoneId| blank. | 126 // Otherwise, we can leave |currentTimezoneId| blank. |
| 124 std::string current_timezone_id; | 127 std::string current_timezone_id; |
| 128 #if defined(USE_ASH) |
| 125 if (ash::Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus() == | 129 if (ash::Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus() == |
| 126 ash::user::LOGGED_IN_NONE) { | 130 ash::user::LOGGED_IN_NONE) { |
| 127 CrosSettings::Get()->GetString(kSystemTimezone, ¤t_timezone_id); | 131 CrosSettings::Get()->GetString(kSystemTimezone, ¤t_timezone_id); |
| 128 } | 132 } |
| 133 #endif |
| 129 values.SetString("currentTimezoneId", current_timezone_id); | 134 values.SetString("currentTimezoneId", current_timezone_id); |
| 130 values.SetDouble("buildTime", base::GetBuildTime().ToJsTime()); | 135 values.SetDouble("buildTime", base::GetBuildTime().ToJsTime()); |
| 131 | 136 |
| 132 source->AddLocalizedStrings(values); | 137 source->AddLocalizedStrings(values); |
| 133 source->SetJsonPath("strings.js"); | 138 source->SetJsonPath("strings.js"); |
| 134 | 139 |
| 135 source->AddResourcePath("set_time.css", IDR_SET_TIME_CSS); | 140 source->AddResourcePath("set_time.css", IDR_SET_TIME_CSS); |
| 136 source->AddResourcePath("set_time.js", IDR_SET_TIME_JS); | 141 source->AddResourcePath("set_time.js", IDR_SET_TIME_JS); |
| 137 source->SetDefaultResource(IDR_SET_TIME_HTML); | 142 source->SetDefaultResource(IDR_SET_TIME_HTML); |
| 138 | 143 |
| 139 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source); | 144 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source); |
| 140 } | 145 } |
| 141 | 146 |
| 142 SetTimeUI::~SetTimeUI() { | 147 SetTimeUI::~SetTimeUI() { |
| 143 } | 148 } |
| 144 | 149 |
| 145 } // namespace chromeos | 150 } // namespace chromeos |
| OLD | NEW |