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/google_apis/drive_api_parser.h" | 5 #include "chrome/browser/google_apis/drive_api_parser.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 scoped_ptr<AppResource> resource(new AppResource); | 401 scoped_ptr<AppResource> resource(new AppResource); |
402 resource->set_application_id(installed_app.app_id()); | 402 resource->set_application_id(installed_app.app_id()); |
403 resource->set_name(installed_app.app_name()); | 403 resource->set_name(installed_app.app_name()); |
404 resource->set_object_type(installed_app.object_type()); | 404 resource->set_object_type(installed_app.object_type()); |
405 resource->set_supports_create(installed_app.supports_create()); | 405 resource->set_supports_create(installed_app.supports_create()); |
406 resource->set_product_url(installed_app.GetProductUrl()); | 406 resource->set_product_url(installed_app.GetProductUrl()); |
407 | 407 |
408 { | 408 { |
409 ScopedVector<std::string> primary_mimetypes( | 409 ScopedVector<std::string> primary_mimetypes( |
410 CopyScopedVectorString(installed_app.primary_mimetypes())); | 410 CopyScopedVectorString(installed_app.primary_mimetypes())); |
411 resource->set_primary_mimetypes(&primary_mimetypes); | 411 resource->set_primary_mimetypes(primary_mimetypes.Pass()); |
412 } | 412 } |
413 { | 413 { |
414 ScopedVector<std::string> secondary_mimetypes( | 414 ScopedVector<std::string> secondary_mimetypes( |
415 CopyScopedVectorString(installed_app.secondary_mimetypes())); | 415 CopyScopedVectorString(installed_app.secondary_mimetypes())); |
416 resource->set_secondary_mimetypes(&secondary_mimetypes); | 416 resource->set_secondary_mimetypes(secondary_mimetypes.Pass()); |
417 } | 417 } |
418 { | 418 { |
419 ScopedVector<std::string> primary_file_extensions( | 419 ScopedVector<std::string> primary_file_extensions( |
420 CopyScopedVectorString(installed_app.primary_extensions())); | 420 CopyScopedVectorString(installed_app.primary_extensions())); |
421 resource->set_primary_file_extensions(&primary_file_extensions); | 421 resource->set_primary_file_extensions(primary_file_extensions.Pass()); |
422 } | 422 } |
423 { | 423 { |
424 ScopedVector<std::string> secondary_file_extensions( | 424 ScopedVector<std::string> secondary_file_extensions( |
425 CopyScopedVectorString(installed_app.secondary_extensions())); | 425 CopyScopedVectorString(installed_app.secondary_extensions())); |
426 resource->set_secondary_file_extensions(&secondary_file_extensions); | 426 resource->set_secondary_file_extensions(secondary_file_extensions.Pass()); |
427 } | 427 } |
428 | 428 |
429 { | 429 { |
430 const ScopedVector<AppIcon>& app_icons = installed_app.app_icons(); | 430 const ScopedVector<AppIcon>& app_icons = installed_app.app_icons(); |
431 ScopedVector<DriveAppIcon> icons; | 431 ScopedVector<DriveAppIcon> icons; |
432 icons.reserve(app_icons.size()); | 432 icons.reserve(app_icons.size()); |
433 for (size_t i = 0; i < app_icons.size(); ++i) { | 433 for (size_t i = 0; i < app_icons.size(); ++i) { |
434 icons.push_back(DriveAppIcon::CreateFromAppIcon(*app_icons[i]).release()); | 434 icons.push_back(DriveAppIcon::CreateFromAppIcon(*app_icons[i]).release()); |
435 } | 435 } |
436 resource->set_icons(&icons); | 436 resource->set_icons(icons.Pass()); |
437 } | 437 } |
438 | 438 |
439 // supports_import, installed and authorized are not supported in | 439 // supports_import, installed and authorized are not supported in |
440 // InstalledApp. | 440 // InstalledApp. |
441 | 441 |
442 return resource.Pass(); | 442 return resource.Pass(); |
443 } | 443 } |
444 | 444 |
445 | 445 |
446 bool AppResource::Parse(const base::Value& value) { | 446 bool AppResource::Parse(const base::Value& value) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 scoped_ptr<AppList> resource(new AppList); | 483 scoped_ptr<AppList> resource(new AppList); |
484 | 484 |
485 const ScopedVector<InstalledApp>& installed_apps = | 485 const ScopedVector<InstalledApp>& installed_apps = |
486 account_metadata.installed_apps(); | 486 account_metadata.installed_apps(); |
487 ScopedVector<AppResource> app_resources; | 487 ScopedVector<AppResource> app_resources; |
488 app_resources.reserve(installed_apps.size()); | 488 app_resources.reserve(installed_apps.size()); |
489 for (size_t i = 0; i < installed_apps.size(); ++i) { | 489 for (size_t i = 0; i < installed_apps.size(); ++i) { |
490 app_resources.push_back( | 490 app_resources.push_back( |
491 AppResource::CreateFromInstalledApp(*installed_apps[i]).release()); | 491 AppResource::CreateFromInstalledApp(*installed_apps[i]).release()); |
492 } | 492 } |
493 resource->set_items(&app_resources); | 493 resource->set_items(app_resources.Pass()); |
494 | 494 |
495 // etag is not supported in AccountMetadata. | 495 // etag is not supported in AccountMetadata. |
496 | 496 |
497 return resource.Pass(); | 497 return resource.Pass(); |
498 } | 498 } |
499 | 499 |
500 bool AppList::Parse(const base::Value& value) { | 500 bool AppList::Parse(const base::Value& value) { |
501 base::JSONValueConverter<AppList> converter; | 501 base::JSONValueConverter<AppList> converter; |
502 if (!converter.Convert(value, this)) { | 502 if (!converter.Convert(value, this)) { |
503 LOG(ERROR) << "Unable to parse: Invalid AppList"; | 503 LOG(ERROR) << "Unable to parse: Invalid AppList"; |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 bool FileLabels::Parse(const base::Value& value) { | 816 bool FileLabels::Parse(const base::Value& value) { |
817 base::JSONValueConverter<FileLabels> converter; | 817 base::JSONValueConverter<FileLabels> converter; |
818 if (!converter.Convert(value, this)) { | 818 if (!converter.Convert(value, this)) { |
819 LOG(ERROR) << "Unable to parse: Invalid FileLabels"; | 819 LOG(ERROR) << "Unable to parse: Invalid FileLabels"; |
820 return false; | 820 return false; |
821 } | 821 } |
822 return true; | 822 return true; |
823 } | 823 } |
824 | 824 |
825 } // namespace google_apis | 825 } // namespace google_apis |
OLD | NEW |