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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 scoped_ptr<DictionaryValue> FormatToken(const T& token) { | 91 scoped_ptr<DictionaryValue> FormatToken(const T& token) { |
92 scoped_ptr<DictionaryValue> js_token(new DictionaryValue); | 92 scoped_ptr<DictionaryValue> js_token(new DictionaryValue); |
93 | 93 |
94 js_token->SetString("id", token.id); | 94 js_token->SetString("id", token.id); |
95 js_token->SetString("statuses", ConvertStatus(token)); | 95 js_token->SetString("statuses", ConvertStatus(token)); |
96 js_token->SetString("medium", FormatMedium(token.medium)); | 96 js_token->SetString("medium", FormatMedium(token.medium)); |
97 DCHECK(!token.start_time.is_null()); | 97 DCHECK(!token.start_time.is_null()); |
98 js_token->SetString("time", | 98 js_token->SetString("time", |
99 base::TimeFormatTimeOfDay(token.start_time)); | 99 base::TimeFormatTimeOfDay(token.start_time)); |
100 | 100 |
101 return js_token.Pass(); | 101 return js_token; |
102 } | 102 } |
103 | 103 |
104 // Retrieve the CopresenceService, if any. | 104 // Retrieve the CopresenceService, if any. |
105 CopresenceService* GetCopresenceService(WebUI* web_ui) { | 105 CopresenceService* GetCopresenceService(WebUI* web_ui) { |
106 DCHECK(web_ui); | 106 DCHECK(web_ui); |
107 return CopresenceService::GetFactoryInstance()->Get( | 107 return CopresenceService::GetFactoryInstance()->Get( |
108 web_ui->GetWebContents()->GetBrowserContext()); | 108 web_ui->GetWebContents()->GetBrowserContext()); |
109 } | 109 } |
110 | 110 |
111 // Safely retrieve the CopresenceState, if any. | 111 // Safely retrieve the CopresenceState, if any. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 203 |
204 // CopresenceService::ResetState() deletes the CopresenceState object | 204 // CopresenceService::ResetState() deletes the CopresenceState object |
205 // we were using. We have to get the new one and reconnect to it. | 205 // we were using. We have to get the new one and reconnect to it. |
206 state_ = GetCopresenceState(service); | 206 state_ = GetCopresenceState(service); |
207 DCHECK(state_); | 207 DCHECK(state_); |
208 state_->AddObserver(this); | 208 state_->AddObserver(this); |
209 | 209 |
210 web_ui()->CallJavascriptFunction("clearTokens"); | 210 web_ui()->CallJavascriptFunction("clearTokens"); |
211 DirectivesUpdated(); | 211 DirectivesUpdated(); |
212 } | 212 } |
OLD | NEW |