| 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/extensions/api/messaging/arc_support_host.h" | 5 #include "chrome/browser/extensions/api/messaging/arc_support_host.h" |
| 6 | 6 |
| 7 #include "ash/system/chromeos/devicetype_utils.h" | 7 #include "ash/system/chromeos/devicetype_utils.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/base/webui/web_ui_util.h" | 15 #include "ui/base/webui/web_ui_util.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 const char kAction[] = "action"; | 18 const char kAction[] = "action"; |
| 19 const char kCode[] = "code"; |
| 19 const char kStatus[] = "status"; | 20 const char kStatus[] = "status"; |
| 20 const char kData[] = "data"; | 21 const char kData[] = "data"; |
| 21 const char kPage[] = "page"; | 22 const char kPage[] = "page"; |
| 22 const char kActionSetLocalization[] = "setLocalization"; | 23 const char kActionSetLocalization[] = "setLocalization"; |
| 23 const char kActionCheckAuthCode[] = "checkAuthCode"; | 24 const char kActionStartLSO[] = "startLSO"; |
| 24 const char kActionCancelAuthCode[] = "cancelAuthCode"; | 25 const char kActionCancelAuthCode[] = "cancelAuthCode"; |
| 26 const char kActionSetAuthCode[] = "setAuthCode"; |
| 25 const char kActionCloseUI[] = "closeUI"; | 27 const char kActionCloseUI[] = "closeUI"; |
| 26 const char kActionShowPage[] = "showPage"; | 28 const char kActionShowPage[] = "showPage"; |
| 27 } // namespace | 29 } // namespace |
| 28 | 30 |
| 29 // static | 31 // static |
| 30 const char ArcSupportHost::kHostName[] = "com.google.arc_support"; | 32 const char ArcSupportHost::kHostName[] = "com.google.arc_support"; |
| 31 | 33 |
| 32 // static | 34 // static |
| 33 const char* const ArcSupportHost::kHostOrigin[] = { | 35 const char* const ArcSupportHost::kHostOrigin[] = { |
| 34 "chrome-extension://cnbgggchhmkkdmeppjobngjoejnihlei/" | 36 "chrome-extension://cnbgggchhmkkdmeppjobngjoejnihlei/" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 NOTREACHED(); | 133 NOTREACHED(); |
| 132 return; | 134 return; |
| 133 } | 135 } |
| 134 | 136 |
| 135 std::string action; | 137 std::string action; |
| 136 if (!request->GetString(kAction, &action)) { | 138 if (!request->GetString(kAction, &action)) { |
| 137 NOTREACHED(); | 139 NOTREACHED(); |
| 138 return; | 140 return; |
| 139 } | 141 } |
| 140 | 142 |
| 141 if (action == kActionCheckAuthCode) { | 143 if (action == kActionStartLSO) { |
| 142 arc::ArcAuthService::Get()->CheckAuthCode(); | 144 arc::ArcAuthService::Get()->StartLSO(); |
| 145 } else if (action == kActionSetAuthCode) { |
| 146 std::string code; |
| 147 if (!request->GetString(kCode, &code)) { |
| 148 NOTREACHED(); |
| 149 return; |
| 150 } |
| 151 arc::ArcAuthService::Get()->SetAuthCodeAndStartArc(code); |
| 143 } else if (action == kActionCancelAuthCode) { | 152 } else if (action == kActionCancelAuthCode) { |
| 144 arc::ArcAuthService::Get()->CancelAuthCode(); | 153 arc::ArcAuthService::Get()->CancelAuthCode(); |
| 145 } else { | 154 } else { |
| 146 NOTREACHED(); | 155 NOTREACHED(); |
| 147 } | 156 } |
| 148 } | 157 } |
| 149 | 158 |
| 150 scoped_refptr<base::SingleThreadTaskRunner> ArcSupportHost::task_runner() | 159 scoped_refptr<base::SingleThreadTaskRunner> ArcSupportHost::task_runner() |
| 151 const { | 160 const { |
| 152 return base::ThreadTaskRunnerHandle::Get(); | 161 return base::ThreadTaskRunnerHandle::Get(); |
| 153 } | 162 } |
| OLD | NEW |