| 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.h" | 13 #include "base/time.h" |
| 14 #include "chrome/common/chrome_paths.h" | |
| 15 #include "chrome/common/extensions/extension_constants.h" | 14 #include "chrome/common/extensions/extension_constants.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 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 loader_instance = NULL; | 102 loader_instance = NULL; |
| 103 } | 103 } |
| 104 | 104 |
| 105 const std::vector<std::string>& ExternalLoader::GetAppIds() { | 105 const std::vector<std::string>& ExternalLoader::GetAppIds() { |
| 106 CHECK(loaded_.IsSignaled()); | 106 CHECK(loaded_.IsSignaled()); |
| 107 return app_ids_; | 107 return app_ids_; |
| 108 } | 108 } |
| 109 | 109 |
| 110 void ExternalLoader::Load() { | 110 void ExternalLoader::Load() { |
| 111 base::FilePath ordinals_file; | 111 base::FilePath ordinals_file; |
| 112 CHECK(PathService::Get(chrome::FILE_DEFAULT_APP_ORDER, &ordinals_file)); | 112 CHECK(PathService::Get(chromeos::FILE_DEFAULT_APP_ORDER, &ordinals_file)); |
| 113 | 113 |
| 114 scoped_ptr<base::ListValue> ordinals_value( | 114 scoped_ptr<base::ListValue> ordinals_value( |
| 115 ReadExternalOrdinalFile(ordinals_file)); | 115 ReadExternalOrdinalFile(ordinals_file)); |
| 116 if (ordinals_value) { | 116 if (ordinals_value) { |
| 117 for (size_t i = 0; i < ordinals_value->GetSize(); ++i) { | 117 for (size_t i = 0; i < ordinals_value->GetSize(); ++i) { |
| 118 std::string app_id; | 118 std::string app_id; |
| 119 CHECK(ordinals_value->GetString(i, &app_id)); | 119 CHECK(ordinals_value->GetString(i, &app_id)); |
| 120 app_ids_.push_back(app_id); | 120 app_ids_.push_back(app_id); |
| 121 } | 121 } |
| 122 } else { | 122 } else { |
| 123 GetDefault(&app_ids_); | 123 GetDefault(&app_ids_); |
| 124 } | 124 } |
| 125 | 125 |
| 126 loaded_.Signal(); | 126 loaded_.Signal(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void Get(std::vector<std::string>* app_ids) { | 129 void Get(std::vector<std::string>* app_ids) { |
| 130 // |loader_instance| could be NULL for test. | 130 // |loader_instance| could be NULL for test. |
| 131 if (!loader_instance) { | 131 if (!loader_instance) { |
| 132 GetDefault(app_ids); | 132 GetDefault(app_ids); |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 | 135 |
| 136 *app_ids = loader_instance->GetAppIds(); | 136 *app_ids = loader_instance->GetAppIds(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace default_app_order | 139 } // namespace default_app_order |
| 140 } // namespace chromeos | 140 } // namespace chromeos |
| OLD | NEW |