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/copresence_ui_handler.h" | 5 #include "chrome/browser/ui/webui/copresence_ui_handler.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
| 9 #include <utility> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "base/values.h" | 15 #include "base/values.h" |
15 #include "chrome/browser/extensions/api/copresence/copresence_api.h" | 16 #include "chrome/browser/extensions/api/copresence/copresence_api.h" |
16 #include "components/copresence/proto/data.pb.h" | 17 #include "components/copresence/proto/data.pb.h" |
17 #include "components/copresence/public/copresence_manager.h" | 18 #include "components/copresence/public/copresence_manager.h" |
18 #include "components/copresence/public/copresence_state.h" | 19 #include "components/copresence/public/copresence_state.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 162 |
162 js_directive->SetString("type", FormatInstructionType( | 163 js_directive->SetString("type", FormatInstructionType( |
163 directive.token_instruction().token_instruction_type())); | 164 directive.token_instruction().token_instruction_type())); |
164 js_directive->SetString("medium", FormatMedium( | 165 js_directive->SetString("medium", FormatMedium( |
165 directive.token_instruction().medium())); | 166 directive.token_instruction().medium())); |
166 js_directive->SetString("duration", ui::TimeFormat::Simple( | 167 js_directive->SetString("duration", ui::TimeFormat::Simple( |
167 ui::TimeFormat::FORMAT_DURATION, | 168 ui::TimeFormat::FORMAT_DURATION, |
168 ui::TimeFormat::LENGTH_LONG, | 169 ui::TimeFormat::LENGTH_LONG, |
169 base::TimeDelta::FromMilliseconds(directive.ttl_millis()))); | 170 base::TimeDelta::FromMilliseconds(directive.ttl_millis()))); |
170 | 171 |
171 js_directives.Append(js_directive.release()); | 172 js_directives.Append(std::move(js_directive)); |
172 } | 173 } |
173 | 174 |
174 web_ui()->CallJavascriptFunctionUnsafe("refreshDirectives", js_directives); | 175 web_ui()->CallJavascriptFunctionUnsafe("refreshDirectives", js_directives); |
175 } | 176 } |
176 | 177 |
177 void CopresenceUIHandler::TokenTransmitted(const TransmittedToken& token) { | 178 void CopresenceUIHandler::TokenTransmitted(const TransmittedToken& token) { |
178 web_ui()->CallJavascriptFunctionUnsafe("updateTransmittedToken", | 179 web_ui()->CallJavascriptFunctionUnsafe("updateTransmittedToken", |
179 *FormatToken(token)); | 180 *FormatToken(token)); |
180 } | 181 } |
181 | 182 |
(...skipping 21 matching lines...) Expand all Loading... |
203 | 204 |
204 // CopresenceService::ResetState() deletes the CopresenceState object | 205 // CopresenceService::ResetState() deletes the CopresenceState object |
205 // we were using. We have to get the new one and reconnect to it. | 206 // we were using. We have to get the new one and reconnect to it. |
206 state_ = GetCopresenceState(service); | 207 state_ = GetCopresenceState(service); |
207 DCHECK(state_); | 208 DCHECK(state_); |
208 state_->AddObserver(this); | 209 state_->AddObserver(this); |
209 | 210 |
210 web_ui()->CallJavascriptFunctionUnsafe("clearTokens"); | 211 web_ui()->CallJavascriptFunctionUnsafe("clearTokens"); |
211 DirectivesUpdated(); | 212 DirectivesUpdated(); |
212 } | 213 } |
OLD | NEW |