| 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/chromeos/extensions/default_app_order.h" | 5 #include "chrome/browser/chromeos/extensions/default_app_order.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/json/json_file_value_serializer.h" | 11 #include "base/json/json_file_value_serializer.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "chrome/common/extensions/extension_constants.h" | 14 #include "chrome/common/extensions/extension_constants.h" |
| 15 #include "chromeos/chromeos_paths.h" | 15 #include "chromeos/chromeos_paths.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 | 17 |
| 18 namespace chromeos { | 18 namespace chromeos { |
| 19 namespace default_app_order { | 19 namespace default_app_order { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // The single ExternalLoader instance. | 23 // The single ExternalLoader instance. |
| 24 ExternalLoader* loader_instance = NULL; | 24 ExternalLoader* loader_instance = NULL; |
| 25 | 25 |
| 26 // Reads external ordinal json file and returned the parsed value. Returns NULL | 26 // Reads external ordinal json file and returned the parsed value. Returns NULL |
| 27 // if the file does not exist or could not be parsed properly. Caller takes | 27 // if the file does not exist or could not be parsed properly. Caller takes |
| 28 // ownership of the returned value. | 28 // ownership of the returned value. |
| 29 base::ListValue* ReadExternalOrdinalFile(const base::FilePath& path) { | 29 base::ListValue* ReadExternalOrdinalFile(const base::FilePath& path) { |
| 30 if (!file_util::PathExists(path)) | 30 if (!base::PathExists(path)) |
| 31 return NULL; | 31 return NULL; |
| 32 | 32 |
| 33 JSONFileValueSerializer serializer(path); | 33 JSONFileValueSerializer serializer(path); |
| 34 std::string error_msg; | 34 std::string error_msg; |
| 35 base::Value* value = serializer.Deserialize(NULL, &error_msg); | 35 base::Value* value = serializer.Deserialize(NULL, &error_msg); |
| 36 if (!value) { | 36 if (!value) { |
| 37 LOG(WARNING) << "Unable to deserialize default app ordinals json data:" | 37 LOG(WARNING) << "Unable to deserialize default app ordinals json data:" |
| 38 << error_msg << ", file=" << path.value(); | 38 << error_msg << ", file=" << path.value(); |
| 39 return NULL; | 39 return NULL; |
| 40 } | 40 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 if (!loader_instance) { | 132 if (!loader_instance) { |
| 133 GetDefault(app_ids); | 133 GetDefault(app_ids); |
| 134 return; | 134 return; |
| 135 } | 135 } |
| 136 | 136 |
| 137 *app_ids = loader_instance->GetAppIds(); | 137 *app_ids = loader_instance->GetAppIds(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 } // namespace default_app_order | 140 } // namespace default_app_order |
| 141 } // namespace chromeos | 141 } // namespace chromeos |
| OLD | NEW |