| 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/drive/fake_drive_service.h" | 5 #include "chrome/browser/drive/fake_drive_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 const std::string& product_id, | 266 const std::string& product_id, |
| 267 const std::string& create_url, | 267 const std::string& create_url, |
| 268 bool is_removable) { | 268 bool is_removable) { |
| 269 if (app_json_template_.empty()) { | 269 if (app_json_template_.empty()) { |
| 270 base::FilePath path = | 270 base::FilePath path = |
| 271 test_util::GetTestFilePath("drive/applist_app_template.json"); | 271 test_util::GetTestFilePath("drive/applist_app_template.json"); |
| 272 CHECK(base::ReadFileToString(path, &app_json_template_)); | 272 CHECK(base::ReadFileToString(path, &app_json_template_)); |
| 273 } | 273 } |
| 274 | 274 |
| 275 std::string app_json = app_json_template_; | 275 std::string app_json = app_json_template_; |
| 276 ReplaceSubstringsAfterOffset(&app_json, 0, "$AppId", app_id); | 276 base::ReplaceSubstringsAfterOffset(&app_json, 0, "$AppId", app_id); |
| 277 ReplaceSubstringsAfterOffset(&app_json, 0, "$AppName", app_name); | 277 base::ReplaceSubstringsAfterOffset(&app_json, 0, "$AppName", app_name); |
| 278 ReplaceSubstringsAfterOffset(&app_json, 0, "$ProductId", product_id); | 278 base::ReplaceSubstringsAfterOffset(&app_json, 0, "$ProductId", product_id); |
| 279 ReplaceSubstringsAfterOffset(&app_json, 0, "$CreateUrl", create_url); | 279 base::ReplaceSubstringsAfterOffset(&app_json, 0, "$CreateUrl", create_url); |
| 280 ReplaceSubstringsAfterOffset( | 280 base::ReplaceSubstringsAfterOffset( |
| 281 &app_json, 0, "$Removable", is_removable ? "true" : "false"); | 281 &app_json, 0, "$Removable", is_removable ? "true" : "false"); |
| 282 | 282 |
| 283 JSONStringValueDeserializer json(app_json); | 283 JSONStringValueDeserializer json(app_json); |
| 284 std::string error_message; | 284 std::string error_message; |
| 285 scoped_ptr<base::Value> value(json.Deserialize(NULL, &error_message)); | 285 scoped_ptr<base::Value> value(json.Deserialize(NULL, &error_message)); |
| 286 CHECK_EQ(base::Value::TYPE_DICTIONARY, value->GetType()); | 286 CHECK_EQ(base::Value::TYPE_DICTIONARY, value->GetType()); |
| 287 | 287 |
| 288 base::ListValue* item_list; | 288 base::ListValue* item_list; |
| 289 CHECK(app_info_value_->GetListWithoutPathExpansion("items", &item_list)); | 289 CHECK(app_info_value_->GetListWithoutPathExpansion("items", &item_list)); |
| 290 item_list->Append(value.release()); | 290 item_list->Append(value.release()); |
| (...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1778 | 1778 |
| 1779 NOTREACHED(); | 1779 NOTREACHED(); |
| 1780 return scoped_ptr<BatchRequestConfiguratorInterface>(); | 1780 return scoped_ptr<BatchRequestConfiguratorInterface>(); |
| 1781 } | 1781 } |
| 1782 | 1782 |
| 1783 void FakeDriveService::NotifyObservers() { | 1783 void FakeDriveService::NotifyObservers() { |
| 1784 FOR_EACH_OBSERVER(ChangeObserver, change_observers_, OnNewChangeAvailable()); | 1784 FOR_EACH_OBSERVER(ChangeObserver, change_observers_, OnNewChangeAvailable()); |
| 1785 } | 1785 } |
| 1786 | 1786 |
| 1787 } // namespace drive | 1787 } // namespace drive |
| OLD | NEW |