Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(647)

Side by Side Diff: chrome/browser/ui/webui/identity_internals_ui.cc

Issue 2086763002: Don't use deprecated ListValue::Append(Value*) overload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/identity_internals_ui.h" 5 #include "chrome/browser/ui/webui/identity_internals_ui.h"
6 6
7 #include <memory>
7 #include <set> 8 #include <set>
8 #include <string> 9 #include <string>
10 #include <utility>
Dan Beam 2016/06/21 00:54:12 what's this for? i don't see a std::move() in thi
dcheng 2016/06/21 18:56:01 No clue. I'm guessing I needed it in an earlier it
9 11
10 #include "base/bind.h" 12 #include "base/bind.h"
11 #include "base/i18n/time_formatting.h" 13 #include "base/i18n/time_formatting.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
14 #include "base/values.h" 16 #include "base/values.h"
15 #include "chrome/browser/extensions/api/identity/identity_api.h" 17 #include "chrome/browser/extensions/api/identity/identity_api.h"
16 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
18 #include "chrome/grit/generated_resources.h" 20 #include "chrome/grit/generated_resources.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 const base::string16 GetStatus( 73 const base::string16 GetStatus(
72 const extensions::IdentityTokenCacheValue& token_cache_value); 74 const extensions::IdentityTokenCacheValue& token_cache_value);
73 75
74 // Gets a string representation of an expiration time of the access token in 76 // Gets a string representation of an expiration time of the access token in
75 // |token_cache_value|. 77 // |token_cache_value|.
76 const std::string GetExpirationTime( 78 const std::string GetExpirationTime(
77 const extensions::IdentityTokenCacheValue& token_cache_value); 79 const extensions::IdentityTokenCacheValue& token_cache_value);
78 80
79 // Converts a pair of |token_cache_key| and |token_cache_value| to a 81 // Converts a pair of |token_cache_key| and |token_cache_value| to a
80 // DictionaryValue object with corresponding information in a localized and 82 // DictionaryValue object with corresponding information in a localized and
81 // readable form and returns a pointer to created object. Caller gets the 83 // readable form and returns a pointer to created object.
82 // ownership of the returned object. 84 std::unique_ptr<base::DictionaryValue> GetInfoForToken(
83 base::DictionaryValue* GetInfoForToken(
84 const extensions::ExtensionTokenKey& token_cache_key, 85 const extensions::ExtensionTokenKey& token_cache_key,
85 const extensions::IdentityTokenCacheValue& token_cache_value); 86 const extensions::IdentityTokenCacheValue& token_cache_value);
86 87
87 // Gets all of the tokens stored in IdentityAPI token cache and returns them 88 // Gets all of the tokens stored in IdentityAPI token cache and returns them
88 // to the caller using Javascript callback function 89 // to the caller using Javascript callback function
89 // |identity_internals.returnTokens()|. 90 // |identity_internals.returnTokens()|.
90 void GetInfoForAllTokens(const base::ListValue* args); 91 void GetInfoForAllTokens(const base::ListValue* args);
91 92
92 // Initiates revoking of the token, based on the extension ID and token 93 // Initiates revoking of the token, based on the extension ID and token
93 // passed as entries in the |args| list. Updates the caller of completion 94 // passed as entries in the |args| list. Updates the caller of completion
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 NOTREACHED(); 203 NOTREACHED();
203 return base::string16(); 204 return base::string16();
204 } 205 }
205 206
206 const std::string IdentityInternalsUIMessageHandler::GetExpirationTime( 207 const std::string IdentityInternalsUIMessageHandler::GetExpirationTime(
207 const extensions::IdentityTokenCacheValue& token_cache_value) { 208 const extensions::IdentityTokenCacheValue& token_cache_value) {
208 return base::UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime( 209 return base::UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(
209 token_cache_value.expiration_time())); 210 token_cache_value.expiration_time()));
210 } 211 }
211 212
212 base::DictionaryValue* IdentityInternalsUIMessageHandler::GetInfoForToken( 213 std::unique_ptr<base::DictionaryValue>
214 IdentityInternalsUIMessageHandler::GetInfoForToken(
213 const extensions::ExtensionTokenKey& token_cache_key, 215 const extensions::ExtensionTokenKey& token_cache_key,
214 const extensions::IdentityTokenCacheValue& token_cache_value) { 216 const extensions::IdentityTokenCacheValue& token_cache_value) {
215 base::DictionaryValue* token_data = new base::DictionaryValue(); 217 std::unique_ptr<base::DictionaryValue> token_data(
218 new base::DictionaryValue());
216 token_data->SetString(kExtensionId, token_cache_key.extension_id); 219 token_data->SetString(kExtensionId, token_cache_key.extension_id);
217 token_data->SetString(kExtensionName, GetExtensionName(token_cache_key)); 220 token_data->SetString(kExtensionName, GetExtensionName(token_cache_key));
218 token_data->Set(kScopes, GetScopes(token_cache_key)); 221 token_data->Set(kScopes, GetScopes(token_cache_key));
219 token_data->SetString(kStatus, GetStatus(token_cache_value)); 222 token_data->SetString(kStatus, GetStatus(token_cache_value));
220 token_data->SetString(kAccessToken, token_cache_value.token()); 223 token_data->SetString(kAccessToken, token_cache_value.token());
221 token_data->SetString(kTokenExpirationTime, 224 token_data->SetString(kTokenExpirationTime,
222 GetExpirationTime(token_cache_value)); 225 GetExpirationTime(token_cache_value));
223 return token_data; 226 return token_data;
224 } 227 }
225 228
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 html_source->AddResourcePath("identity_internals.js", 317 html_source->AddResourcePath("identity_internals.js",
315 IDR_IDENTITY_INTERNALS_JS); 318 IDR_IDENTITY_INTERNALS_JS);
316 html_source->SetDefaultResource(IDR_IDENTITY_INTERNALS_HTML); 319 html_source->SetDefaultResource(IDR_IDENTITY_INTERNALS_HTML);
317 320
318 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); 321 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source);
319 322
320 web_ui->AddMessageHandler(new IdentityInternalsUIMessageHandler()); 323 web_ui->AddMessageHandler(new IdentityInternalsUIMessageHandler());
321 } 324 }
322 325
323 IdentityInternalsUI::~IdentityInternalsUI() {} 326 IdentityInternalsUI::~IdentityInternalsUI() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698