OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/drive_internals_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/drive_internals_ui.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 345 |
346 if (status != google_apis::HTTP_SUCCESS) { | 346 if (status != google_apis::HTTP_SUCCESS) { |
347 LOG(ERROR) << "Failed to get app list"; | 347 LOG(ERROR) << "Failed to get app list"; |
348 return; | 348 return; |
349 } | 349 } |
350 DCHECK(parsed_app_list); | 350 DCHECK(parsed_app_list); |
351 | 351 |
352 base::DictionaryValue app_list; | 352 base::DictionaryValue app_list; |
353 app_list.SetString("etag", parsed_app_list->etag()); | 353 app_list.SetString("etag", parsed_app_list->etag()); |
354 | 354 |
355 base::ListValue* items = new base::ListValue(); | 355 auto items = base::MakeUnique<base::ListValue>(); |
356 for (size_t i = 0; i < parsed_app_list->items().size(); ++i) { | 356 for (size_t i = 0; i < parsed_app_list->items().size(); ++i) { |
357 const google_apis::AppResource* app = parsed_app_list->items()[i].get(); | 357 const google_apis::AppResource* app = parsed_app_list->items()[i].get(); |
358 auto app_data = base::MakeUnique<base::DictionaryValue>(); | 358 auto app_data = base::MakeUnique<base::DictionaryValue>(); |
359 app_data->SetString("name", app->name()); | 359 app_data->SetString("name", app->name()); |
360 app_data->SetString("application_id", app->application_id()); | 360 app_data->SetString("application_id", app->application_id()); |
361 app_data->SetString("object_type", app->object_type()); | 361 app_data->SetString("object_type", app->object_type()); |
362 app_data->SetBoolean("supports_create", app->supports_create()); | 362 app_data->SetBoolean("supports_create", app->supports_create()); |
363 | 363 |
364 items->Append(std::move(app_data)); | 364 items->Append(std::move(app_data)); |
365 } | 365 } |
366 app_list.Set("items", items); | 366 app_list.Set("items", std::move(items)); |
367 | 367 |
368 web_ui()->CallJavascriptFunctionUnsafe("updateAppList", app_list); | 368 web_ui()->CallJavascriptFunctionUnsafe("updateAppList", app_list); |
369 } | 369 } |
370 | 370 |
371 void DriveInternalsWebUIHandler::RegisterMessages() { | 371 void DriveInternalsWebUIHandler::RegisterMessages() { |
372 web_ui()->RegisterMessageCallback( | 372 web_ui()->RegisterMessageCallback( |
373 "pageLoaded", | 373 "pageLoaded", |
374 base::Bind(&DriveInternalsWebUIHandler::OnPageLoaded, | 374 base::Bind(&DriveInternalsWebUIHandler::OnPageLoaded, |
375 weak_ptr_factory_.GetWeakPtr())); | 375 weak_ptr_factory_.GetWeakPtr())); |
376 web_ui()->RegisterMessageCallback( | 376 web_ui()->RegisterMessageCallback( |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 content::WebUIDataSource::Create(chrome::kChromeUIDriveInternalsHost); | 899 content::WebUIDataSource::Create(chrome::kChromeUIDriveInternalsHost); |
900 source->AddResourcePath("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); | 900 source->AddResourcePath("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); |
901 source->AddResourcePath("drive_internals.js", IDR_DRIVE_INTERNALS_JS); | 901 source->AddResourcePath("drive_internals.js", IDR_DRIVE_INTERNALS_JS); |
902 source->SetDefaultResource(IDR_DRIVE_INTERNALS_HTML); | 902 source->SetDefaultResource(IDR_DRIVE_INTERNALS_HTML); |
903 | 903 |
904 Profile* profile = Profile::FromWebUI(web_ui); | 904 Profile* profile = Profile::FromWebUI(web_ui); |
905 content::WebUIDataSource::Add(profile, source); | 905 content::WebUIDataSource::Add(profile, source); |
906 } | 906 } |
907 | 907 |
908 } // namespace chromeos | 908 } // namespace chromeos |
OLD | NEW |