| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chromeos/arc/arc_support_host.h" | 5 #include "chrome/browser/chromeos/arc/arc_support_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "ash/common/system/chromeos/devicetype_utils.h" | 9 #include "ash/common/system/chromeos/devicetype_utils.h" |
| 10 #include "base/i18n/timezone.h" | 10 #include "base/i18n/timezone.h" |
| 11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
| 12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chromeos/arc/arc_auth_service.h" | |
| 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 16 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 17 #include "chrome/browser/extensions/extension_util.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 19 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 20 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 21 #include "chrome/browser/ui/extensions/application_launch.h" |
| 20 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 21 #include "components/user_manager/known_user.h" | 23 #include "components/user_manager/known_user.h" |
| 24 #include "extensions/browser/extension_registry.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/base/webui/web_ui_util.h" | 26 #include "ui/base/webui/web_ui_util.h" |
| 24 #include "ui/display/screen.h" | 27 #include "ui/display/screen.h" |
| 25 | 28 |
| 26 namespace { | 29 namespace { |
| 27 constexpr char kAction[] = "action"; | 30 constexpr char kAction[] = "action"; |
| 28 constexpr char kArcManaged[] = "arcManaged"; | 31 constexpr char kArcManaged[] = "arcManaged"; |
| 29 constexpr char kData[] = "data"; | 32 constexpr char kData[] = "data"; |
| 30 constexpr char kDeviceId[] = "deviceId"; | 33 constexpr char kDeviceId[] = "deviceId"; |
| 31 constexpr char kActionInitialize[] = "initialize"; | 34 constexpr char kActionInitialize[] = "initialize"; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 constexpr char kIsBackupRestoreEnabled[] = "isBackupRestoreEnabled"; | 78 constexpr char kIsBackupRestoreEnabled[] = "isBackupRestoreEnabled"; |
| 76 constexpr char kIsLocationServiceEnabled[] = "isLocationServiceEnabled"; | 79 constexpr char kIsLocationServiceEnabled[] = "isLocationServiceEnabled"; |
| 77 | 80 |
| 78 // "onRetryClicked" is fired when a user clicks "RETRY" button on the error | 81 // "onRetryClicked" is fired when a user clicks "RETRY" button on the error |
| 79 // page. | 82 // page. |
| 80 constexpr char kEventOnRetryClicked[] = "onRetryClicked"; | 83 constexpr char kEventOnRetryClicked[] = "onRetryClicked"; |
| 81 | 84 |
| 82 // "onSendFeedbackClicked" is fired when a user clicks "Send Feedback" button. | 85 // "onSendFeedbackClicked" is fired when a user clicks "Send Feedback" button. |
| 83 constexpr char kEventOnSendFeedbackClicked[] = "onSendFeedbackClicked"; | 86 constexpr char kEventOnSendFeedbackClicked[] = "onSendFeedbackClicked"; |
| 84 | 87 |
| 88 std::ostream& operator<<(std::ostream& os, ArcSupportHost::UIPage ui_page) { |
| 89 switch (ui_page) { |
| 90 case ArcSupportHost::UIPage::NO_PAGE: |
| 91 return os << "NO_PAGE"; |
| 92 case ArcSupportHost::UIPage::TERMS: |
| 93 return os << "TERMS"; |
| 94 case ArcSupportHost::UIPage::LSO: |
| 95 return os << "LSO"; |
| 96 case ArcSupportHost::UIPage::ARC_LOADING: |
| 97 return os << "ARC_LOADING"; |
| 98 case ArcSupportHost::UIPage::ERROR: |
| 99 return os << "ERROR"; |
| 100 } |
| 101 |
| 102 // Some compiler reports an error even if all values of an enum-class are |
| 103 // covered indivisually in a switch statement. |
| 104 NOTREACHED(); |
| 105 return os; |
| 106 } |
| 107 |
| 108 std::ostream& operator<<(std::ostream& os, ArcSupportHost::Error error) { |
| 109 switch (error) { |
| 110 case ArcSupportHost::Error::SIGN_IN_NETWORK_ERROR: |
| 111 return os << "SIGN_IN_NETWORK_ERROR"; |
| 112 case ArcSupportHost::Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR: |
| 113 return os << "SIGN_IN_SERVICE_UNAVAILABLE_ERROR"; |
| 114 case ArcSupportHost::Error::SIGN_IN_BAD_AUTHENTICATION_ERROR: |
| 115 return os << "SIGN_IN_BAD_AUTHENTICATION_ERROR"; |
| 116 case ArcSupportHost::Error::SIGN_IN_GMS_NOT_AVAILABLE_ERROR: |
| 117 return os << "SIGN_IN_GMS_NOT_AVAILABLE_ERROR"; |
| 118 case ArcSupportHost::Error::SIGN_IN_CLOUD_PROVISION_FLOW_FAIL_ERROR: |
| 119 return os << "SIGN_IN_CLOUD_PROVISION_FLOW_FAIL_ERROR"; |
| 120 case ArcSupportHost::Error::SIGN_IN_UNKNOWN_ERROR: |
| 121 return os << "SIGN_IN_UNKNOWN_ERROR"; |
| 122 case ArcSupportHost::Error::SERVER_COMMUNICATION_ERROR: |
| 123 return os << "SERVER_COMMUNICATION_ERROR"; |
| 124 case ArcSupportHost::Error::ANDROID_MANAGEMENT_REQUIRED_ERROR: |
| 125 return os << "ANDROID_MANAGEMENT_REQUIRED_ERROR"; |
| 126 } |
| 127 |
| 128 // Some compiler reports an error even if all values of an enum-class are |
| 129 // covered indivisually in a switch statement. |
| 130 NOTREACHED(); |
| 131 return os; |
| 132 } |
| 133 |
| 85 } // namespace | 134 } // namespace |
| 86 | 135 |
| 87 // static | 136 // static |
| 88 const char ArcSupportHost::kHostAppId[] = "cnbgggchhmkkdmeppjobngjoejnihlei"; | 137 const char ArcSupportHost::kHostAppId[] = "cnbgggchhmkkdmeppjobngjoejnihlei"; |
| 89 | 138 |
| 90 // static | 139 // static |
| 91 const char ArcSupportHost::kStorageId[] = "arc_support"; | 140 const char ArcSupportHost::kStorageId[] = "arc_support"; |
| 92 | 141 |
| 93 ArcSupportHost::ArcSupportHost() = default; | 142 ArcSupportHost::ArcSupportHost(Profile* profile) : profile_(profile) {} |
| 94 | 143 |
| 95 ArcSupportHost::~ArcSupportHost() { | 144 ArcSupportHost::~ArcSupportHost() { |
| 96 if (message_host_) | 145 if (message_host_) |
| 97 DisconnectMessageHost(); | 146 DisconnectMessageHost(); |
| 98 } | 147 } |
| 99 | 148 |
| 100 void ArcSupportHost::AddObserver(Observer* observer) { | 149 void ArcSupportHost::AddObserver(Observer* observer) { |
| 101 DCHECK(!observer_); | 150 DCHECK(!observer_); |
| 102 observer_ = observer; | 151 observer_ = observer; |
| 103 } | 152 } |
| 104 | 153 |
| 154 void ArcSupportHost::SetArcManaged(bool is_arc_managed) { |
| 155 DCHECK(!message_host_); |
| 156 is_arc_managed_ = is_arc_managed; |
| 157 } |
| 158 |
| 105 void ArcSupportHost::Close() { | 159 void ArcSupportHost::Close() { |
| 160 ui_page_ = UIPage::NO_PAGE; |
| 106 if (!message_host_) { | 161 if (!message_host_) { |
| 107 VLOG(2) << "ArcSupportHost::Close() is called " | 162 VLOG(2) << "ArcSupportHost::Close() is called " |
| 108 << "but message_host_ is not available."; | 163 << "but message_host_ is not available."; |
| 109 return; | 164 return; |
| 110 } | 165 } |
| 111 | 166 |
| 112 base::DictionaryValue message; | 167 base::DictionaryValue message; |
| 113 message.SetString(kAction, kActionCloseWindow); | 168 message.SetString(kAction, kActionCloseWindow); |
| 114 message_host_->SendMessage(message); | 169 message_host_->SendMessage(message); |
| 115 | 170 |
| 116 // Disconnect immediately, so that onWindowClosed event will not be | 171 // Disconnect immediately, so that onWindowClosed event will not be |
| 117 // delivered to here. | 172 // delivered to here. |
| 118 DisconnectMessageHost(); | 173 DisconnectMessageHost(); |
| 119 } | 174 } |
| 120 | 175 |
| 121 void ArcSupportHost::ShowPage(UIPage page, const base::string16& status) { | 176 void ArcSupportHost::ShowTermsOfService() { |
| 177 ShowPage(UIPage::TERMS); |
| 178 } |
| 179 |
| 180 void ArcSupportHost::ShowLso() { |
| 181 ShowPage(UIPage::LSO); |
| 182 } |
| 183 |
| 184 void ArcSupportHost::ShowArcLoading() { |
| 185 ShowPage(UIPage::ARC_LOADING); |
| 186 } |
| 187 |
| 188 void ArcSupportHost::ShowPage(UIPage ui_page) { |
| 189 ui_page_ = ui_page; |
| 122 if (!message_host_) { | 190 if (!message_host_) { |
| 123 VLOG(2) << "ArcSupportHost::ShowPage() is called " | 191 if (app_start_pending_) { |
| 124 << "but message_host_ is not available."; | 192 VLOG(2) << "ArcSupportHost::ShowPage(" << ui_page << ") is called " |
| 193 << "before connection to ARC support Chrome app has finished " |
| 194 << "establishing."; |
| 195 return; |
| 196 } |
| 197 RequestAppStart(); |
| 125 return; | 198 return; |
| 126 } | 199 } |
| 127 | 200 |
| 128 base::DictionaryValue message; | 201 base::DictionaryValue message; |
| 129 if (page == UIPage::ERROR || page == UIPage::ERROR_WITH_FEEDBACK) { | 202 message.SetString(kAction, kActionShowPage); |
| 130 message.SetString(kAction, kActionShowErrorPage); | 203 switch (ui_page) { |
| 131 message.SetString(kErrorMessage, status); | 204 case UIPage::TERMS: |
| 132 message.SetBoolean(kShouldShowSendFeedback, | 205 message.SetString(kPage, "terms"); |
| 133 page == UIPage::ERROR_WITH_FEEDBACK); | 206 break; |
| 134 } else { | 207 case UIPage::LSO: |
| 135 message.SetString(kAction, kActionShowPage); | 208 // TODO(hidehiko): Merge LSO and LSO_LOADING. |
| 136 switch (page) { | 209 message.SetString(kPage, "lso-loading"); |
| 137 case UIPage::NO_PAGE: | 210 break; |
| 138 message.SetString(kPage, "none"); | 211 case UIPage::ARC_LOADING: |
| 139 break; | 212 message.SetString(kPage, "arc-loading"); |
| 140 case UIPage::TERMS: | 213 break; |
| 141 message.SetString(kPage, "terms"); | 214 default: |
| 142 break; | 215 NOTREACHED(); |
| 143 case UIPage::LSO_PROGRESS: | 216 return; |
| 144 message.SetString(kPage, "lso-loading"); | |
| 145 break; | |
| 146 // Skip LSO. LSO and LSO_LOADING should be merged well. | |
| 147 // TODO(hidehiko): Do it. | |
| 148 case UIPage::START_PROGRESS: | |
| 149 message.SetString(kPage, "arc-loading"); | |
| 150 break; | |
| 151 default: | |
| 152 NOTREACHED(); | |
| 153 return; | |
| 154 } | |
| 155 } | 217 } |
| 156 message_host_->SendMessage(message); | 218 message_host_->SendMessage(message); |
| 157 } | 219 } |
| 158 | 220 |
| 221 void ArcSupportHost::ShowError(Error error, bool should_show_send_feedback) { |
| 222 ui_page_ = UIPage::ERROR; |
| 223 error_ = error; |
| 224 should_show_send_feedback_ = should_show_send_feedback; |
| 225 if (!message_host_) { |
| 226 if (app_start_pending_) { |
| 227 VLOG(2) << "ArcSupportHost::ShowError(" << error << ", " |
| 228 << should_show_send_feedback << ") is called before connection " |
| 229 << "to ARC support Chrome app is established."; |
| 230 return; |
| 231 } |
| 232 RequestAppStart(); |
| 233 return; |
| 234 } |
| 235 |
| 236 base::DictionaryValue message; |
| 237 message.SetString(kAction, kActionShowErrorPage); |
| 238 int message_id; |
| 239 switch (error) { |
| 240 case Error::SIGN_IN_NETWORK_ERROR: |
| 241 message_id = IDS_ARC_SIGN_IN_NETWORK_ERROR; |
| 242 break; |
| 243 case Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR: |
| 244 message_id = IDS_ARC_SIGN_IN_SERVICE_UNAVAILABLE_ERROR; |
| 245 break; |
| 246 case Error::SIGN_IN_BAD_AUTHENTICATION_ERROR: |
| 247 message_id = IDS_ARC_SIGN_IN_BAD_AUTHENTICATION_ERROR; |
| 248 break; |
| 249 case Error::SIGN_IN_GMS_NOT_AVAILABLE_ERROR: |
| 250 message_id = IDS_ARC_SIGN_IN_GMS_NOT_AVAILABLE_ERROR; |
| 251 break; |
| 252 case Error::SIGN_IN_CLOUD_PROVISION_FLOW_FAIL_ERROR: |
| 253 message_id = IDS_ARC_SIGN_IN_CLOUD_PROVISION_FLOW_FAIL_ERROR; |
| 254 break; |
| 255 case Error::SIGN_IN_UNKNOWN_ERROR: |
| 256 message_id = IDS_ARC_SIGN_IN_UNKNOWN_ERROR; |
| 257 break; |
| 258 case Error::SERVER_COMMUNICATION_ERROR: |
| 259 message_id = IDS_ARC_SERVER_COMMUNICATION_ERROR; |
| 260 break; |
| 261 case Error::ANDROID_MANAGEMENT_REQUIRED_ERROR: |
| 262 message_id = IDS_ARC_ANDROID_MANAGEMENT_REQUIRED_ERROR; |
| 263 break; |
| 264 } |
| 265 message.SetString(kErrorMessage, l10n_util::GetStringUTF16(message_id)); |
| 266 message.SetBoolean(kShouldShowSendFeedback, should_show_send_feedback); |
| 267 message_host_->SendMessage(message); |
| 268 } |
| 269 |
| 159 void ArcSupportHost::SetMetricsPreferenceCheckbox(bool is_enabled, | 270 void ArcSupportHost::SetMetricsPreferenceCheckbox(bool is_enabled, |
| 160 bool is_managed) { | 271 bool is_managed) { |
| 161 metrics_checkbox_ = PreferenceCheckboxData(is_enabled, is_managed); | 272 metrics_checkbox_ = PreferenceCheckboxData(is_enabled, is_managed); |
| 162 SendPreferenceCheckboxUpdate(kActionSetMetricsMode, metrics_checkbox_); | 273 SendPreferenceCheckboxUpdate(kActionSetMetricsMode, metrics_checkbox_); |
| 163 } | 274 } |
| 164 | 275 |
| 165 void ArcSupportHost::SetBackupAndRestorePreferenceCheckbox(bool is_enabled, | 276 void ArcSupportHost::SetBackupAndRestorePreferenceCheckbox(bool is_enabled, |
| 166 bool is_managed) { | 277 bool is_managed) { |
| 167 backup_and_restore_checkbox_ = PreferenceCheckboxData(is_enabled, is_managed); | 278 backup_and_restore_checkbox_ = PreferenceCheckboxData(is_enabled, is_managed); |
| 168 SendPreferenceCheckboxUpdate(kActionBackupAndRestoreMode, | 279 SendPreferenceCheckboxUpdate(kActionBackupAndRestoreMode, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 186 message.SetString(kAction, action_name); | 297 message.SetString(kAction, action_name); |
| 187 message.SetBoolean(kEnabled, data.is_enabled); | 298 message.SetBoolean(kEnabled, data.is_enabled); |
| 188 message.SetBoolean(kManaged, data.is_managed); | 299 message.SetBoolean(kManaged, data.is_managed); |
| 189 message_host_->SendMessage(message); | 300 message_host_->SendMessage(message); |
| 190 } | 301 } |
| 191 | 302 |
| 192 void ArcSupportHost::SetMessageHost(arc::ArcSupportMessageHost* message_host) { | 303 void ArcSupportHost::SetMessageHost(arc::ArcSupportMessageHost* message_host) { |
| 193 if (message_host_ == message_host) | 304 if (message_host_ == message_host) |
| 194 return; | 305 return; |
| 195 | 306 |
| 307 app_start_pending_ = false; |
| 196 if (message_host_) | 308 if (message_host_) |
| 197 DisconnectMessageHost(); | 309 DisconnectMessageHost(); |
| 198 message_host_ = message_host; | 310 message_host_ = message_host; |
| 199 message_host_->SetObserver(this); | 311 message_host_->SetObserver(this); |
| 200 display::Screen::GetScreen()->AddObserver(this); | 312 display::Screen::GetScreen()->AddObserver(this); |
| 201 | 313 |
| 202 if (!Initialize()) { | 314 if (!Initialize()) { |
| 203 Close(); | 315 Close(); |
| 204 return; | 316 return; |
| 205 } | 317 } |
| 206 | 318 |
| 319 // Hereafter, install the requested ui state into the ARC support Chrome app. |
| 320 |
| 321 // Set preference checkbox state. |
| 207 SendPreferenceCheckboxUpdate(kActionSetMetricsMode, metrics_checkbox_); | 322 SendPreferenceCheckboxUpdate(kActionSetMetricsMode, metrics_checkbox_); |
| 208 SendPreferenceCheckboxUpdate(kActionBackupAndRestoreMode, | 323 SendPreferenceCheckboxUpdate(kActionBackupAndRestoreMode, |
| 209 backup_and_restore_checkbox_); | 324 backup_and_restore_checkbox_); |
| 210 SendPreferenceCheckboxUpdate(kActionLocationServiceMode, | 325 SendPreferenceCheckboxUpdate(kActionLocationServiceMode, |
| 211 location_services_checkbox_); | 326 location_services_checkbox_); |
| 212 | 327 |
| 213 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get(); | 328 if (ui_page_ == UIPage::NO_PAGE) { |
| 214 DCHECK(arc_auth_service); | 329 // Close() is called before opening the window. |
| 215 ShowPage(arc_auth_service->ui_page(), arc_auth_service->ui_page_status()); | 330 Close(); |
| 331 } else if (ui_page_ == UIPage::ERROR) { |
| 332 ShowError(error_, should_show_send_feedback_); |
| 333 } else { |
| 334 ShowPage(ui_page_); |
| 335 } |
| 216 } | 336 } |
| 217 | 337 |
| 218 void ArcSupportHost::UnsetMessageHost( | 338 void ArcSupportHost::UnsetMessageHost( |
| 219 arc::ArcSupportMessageHost* message_host) { | 339 arc::ArcSupportMessageHost* message_host) { |
| 220 if (message_host_ != message_host) | 340 if (message_host_ != message_host) |
| 221 return; | 341 return; |
| 222 DisconnectMessageHost(); | 342 DisconnectMessageHost(); |
| 223 } | 343 } |
| 224 | 344 |
| 225 void ArcSupportHost::DisconnectMessageHost() { | 345 void ArcSupportHost::DisconnectMessageHost() { |
| 226 DCHECK(message_host_); | 346 DCHECK(message_host_); |
| 227 display::Screen::GetScreen()->RemoveObserver(this); | 347 display::Screen::GetScreen()->RemoveObserver(this); |
| 228 message_host_->SetObserver(nullptr); | 348 message_host_->SetObserver(nullptr); |
| 229 message_host_ = nullptr; | 349 message_host_ = nullptr; |
| 230 } | 350 } |
| 231 | 351 |
| 352 void ArcSupportHost::RequestAppStart() { |
| 353 DCHECK(!message_host_); |
| 354 DCHECK(!app_start_pending_); |
| 355 |
| 356 app_start_pending_ = true; |
| 357 const extensions::Extension* extension = |
| 358 extensions::ExtensionRegistry::Get(profile_)->GetInstalledExtension( |
| 359 kHostAppId); |
| 360 DCHECK(extension); |
| 361 DCHECK(extensions::util::IsAppLaunchable(kHostAppId, profile_)); |
| 362 OpenApplication(CreateAppLaunchParamsUserContainer( |
| 363 profile_, extension, WindowOpenDisposition::NEW_WINDOW, |
| 364 extensions::SOURCE_CHROME_INTERNAL)); |
| 365 } |
| 366 |
| 232 bool ArcSupportHost::Initialize() { | 367 bool ArcSupportHost::Initialize() { |
| 233 DCHECK(message_host_); | 368 DCHECK(message_host_); |
| 234 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get(); | |
| 235 if (!arc_auth_service->IsAllowed()) | |
| 236 return false; | |
| 237 | 369 |
| 238 std::unique_ptr<base::DictionaryValue> loadtime_data( | 370 auto loadtime_data = base::MakeUnique<base::DictionaryValue>(); |
| 239 new base::DictionaryValue()); | |
| 240 base::string16 device_name = ash::GetChromeOSDeviceName(); | 371 base::string16 device_name = ash::GetChromeOSDeviceName(); |
| 241 loadtime_data->SetString( | 372 loadtime_data->SetString( |
| 242 "greetingHeader", | 373 "greetingHeader", |
| 243 l10n_util::GetStringFUTF16(IDS_ARC_OPT_IN_DIALOG_HEADER, device_name)); | 374 l10n_util::GetStringFUTF16(IDS_ARC_OPT_IN_DIALOG_HEADER, device_name)); |
| 244 loadtime_data->SetString("greetingDescription", | 375 loadtime_data->SetString("greetingDescription", |
| 245 l10n_util::GetStringFUTF16( | 376 l10n_util::GetStringFUTF16( |
| 246 IDS_ARC_OPT_IN_DIALOG_DESCRIPTION, device_name)); | 377 IDS_ARC_OPT_IN_DIALOG_DESCRIPTION, device_name)); |
| 247 loadtime_data->SetString( | 378 loadtime_data->SetString( |
| 248 "buttonAgree", | 379 "buttonAgree", |
| 249 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_BUTTON_AGREE)); | 380 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_BUTTON_AGREE)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 loadtime_data->SetString( | 432 loadtime_data->SetString( |
| 302 "learnMoreLocationServices", | 433 "learnMoreLocationServices", |
| 303 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_LEARN_MORE_LOCATION_SERVICES)); | 434 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_LEARN_MORE_LOCATION_SERVICES)); |
| 304 loadtime_data->SetString( | 435 loadtime_data->SetString( |
| 305 "overlayClose", | 436 "overlayClose", |
| 306 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_LEARN_MORE_CLOSE)); | 437 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_LEARN_MORE_CLOSE)); |
| 307 loadtime_data->SetString( | 438 loadtime_data->SetString( |
| 308 "privacyPolicyLink", | 439 "privacyPolicyLink", |
| 309 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_PRIVACY_POLICY_LINK)); | 440 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_PRIVACY_POLICY_LINK)); |
| 310 | 441 |
| 311 const std::string& app_locale = g_browser_process->GetApplicationLocale(); | 442 loadtime_data->SetBoolean(kArcManaged, is_arc_managed_); |
| 443 loadtime_data->SetBoolean("isOwnerProfile", |
| 444 chromeos::ProfileHelper::IsOwnerProfile(profile_)); |
| 445 |
| 312 const std::string& country_code = base::CountryCodeForCurrentTimezone(); | 446 const std::string& country_code = base::CountryCodeForCurrentTimezone(); |
| 313 loadtime_data->SetString("countryCode", country_code); | 447 loadtime_data->SetString("countryCode", country_code); |
| 314 loadtime_data->SetBoolean(kArcManaged, arc_auth_service->IsArcManaged()); | |
| 315 | 448 |
| 449 const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
| 316 webui::SetLoadTimeDataDefaults(app_locale, loadtime_data.get()); | 450 webui::SetLoadTimeDataDefaults(app_locale, loadtime_data.get()); |
| 317 DCHECK(arc_auth_service); | |
| 318 const std::string device_id = user_manager::known_user::GetDeviceId( | |
| 319 multi_user_util::GetAccountIdFromProfile(arc_auth_service->profile())); | |
| 320 DCHECK(!device_id.empty()); | |
| 321 loadtime_data->SetBoolean( | |
| 322 "isOwnerProfile", | |
| 323 chromeos::ProfileHelper::IsOwnerProfile(arc_auth_service->profile())); | |
| 324 | 451 |
| 325 base::DictionaryValue message; | 452 base::DictionaryValue message; |
| 326 message.SetString(kAction, kActionInitialize); | 453 message.SetString(kAction, kActionInitialize); |
| 327 message.Set(kData, std::move(loadtime_data)); | 454 message.Set(kData, std::move(loadtime_data)); |
| 455 |
| 456 const std::string device_id = user_manager::known_user::GetDeviceId( |
| 457 multi_user_util::GetAccountIdFromProfile(profile_)); |
| 458 DCHECK(!device_id.empty()); |
| 328 message.SetString(kDeviceId, device_id); | 459 message.SetString(kDeviceId, device_id); |
| 460 |
| 329 message_host_->SendMessage(message); | 461 message_host_->SendMessage(message); |
| 330 return true; | 462 return true; |
| 331 } | 463 } |
| 332 | 464 |
| 333 void ArcSupportHost::OnDisplayAdded(const display::Display& new_display) {} | 465 void ArcSupportHost::OnDisplayAdded(const display::Display& new_display) {} |
| 334 | 466 |
| 335 void ArcSupportHost::OnDisplayRemoved(const display::Display& old_display) {} | 467 void ArcSupportHost::OnDisplayRemoved(const display::Display& old_display) {} |
| 336 | 468 |
| 337 void ArcSupportHost::OnDisplayMetricsChanged(const display::Display& display, | 469 void ArcSupportHost::OnDisplayMetricsChanged(const display::Display& display, |
| 338 uint32_t changed_metrics) { | 470 uint32_t changed_metrics) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 } | 513 } |
| 382 } else if (event == kEventOnRetryClicked) { | 514 } else if (event == kEventOnRetryClicked) { |
| 383 observer_->OnRetryClicked(); | 515 observer_->OnRetryClicked(); |
| 384 } else if (event == kEventOnSendFeedbackClicked) { | 516 } else if (event == kEventOnSendFeedbackClicked) { |
| 385 observer_->OnSendFeedbackClicked(); | 517 observer_->OnSendFeedbackClicked(); |
| 386 } else { | 518 } else { |
| 387 LOG(ERROR) << "Unknown message: " << event; | 519 LOG(ERROR) << "Unknown message: " << event; |
| 388 NOTREACHED(); | 520 NOTREACHED(); |
| 389 } | 521 } |
| 390 } | 522 } |
| OLD | NEW |