| 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/extensions/component_loader.h" | 5 #include "chrome/browser/extensions/component_loader.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 std::unique_ptr<base::DictionaryValue> manifest( | 90 std::unique_ptr<base::DictionaryValue> manifest( |
| 91 file_util::LoadManifest(root_directory, manifest_filename, &error)); | 91 file_util::LoadManifest(root_directory, manifest_filename, &error)); |
| 92 if (!manifest) { | 92 if (!manifest) { |
| 93 LOG(ERROR) << "Can't load " | 93 LOG(ERROR) << "Can't load " |
| 94 << root_directory.Append(manifest_filename).AsUTF8Unsafe() | 94 << root_directory.Append(manifest_filename).AsUTF8Unsafe() |
| 95 << ": " << error; | 95 << ": " << error; |
| 96 return nullptr; | 96 return nullptr; |
| 97 } | 97 } |
| 98 bool localized = extension_l10n_util::LocalizeExtension( | 98 bool localized = extension_l10n_util::LocalizeExtension( |
| 99 root_directory, manifest.get(), &error); | 99 root_directory, manifest.get(), &error); |
| 100 CHECK(localized) << error; | 100 CHECK(localized); |
| 101 return manifest; | 101 return manifest; |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool IsNormalSession() { | 104 bool IsNormalSession() { |
| 105 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 105 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 106 chromeos::switches::kGuestSession) && | 106 chromeos::switches::kGuestSession) && |
| 107 user_manager::UserManager::IsInitialized() && | 107 user_manager::UserManager::IsInitialized() && |
| 108 user_manager::UserManager::Get()->IsUserLoggedIn(); | 108 user_manager::UserManager::Get()->IsUserLoggedIn(); |
| 109 } | 109 } |
| 110 #endif // defined(OS_CHROMEOS) | 110 #endif // defined(OS_CHROMEOS) |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 246 } |
| 247 | 247 |
| 248 void ComponentLoader::Load(const ComponentExtensionInfo& info) { | 248 void ComponentLoader::Load(const ComponentExtensionInfo& info) { |
| 249 std::string error; | 249 std::string error; |
| 250 scoped_refptr<const Extension> extension(CreateExtension(info, &error)); | 250 scoped_refptr<const Extension> extension(CreateExtension(info, &error)); |
| 251 if (!extension.get()) { | 251 if (!extension.get()) { |
| 252 LOG(ERROR) << error; | 252 LOG(ERROR) << error; |
| 253 return; | 253 return; |
| 254 } | 254 } |
| 255 | 255 |
| 256 CHECK_EQ(info.extension_id, extension->id()) << extension->name(); | 256 CHECK_EQ(info.extension_id, extension->id()); |
| 257 extension_service_->AddComponentExtension(extension.get()); | 257 extension_service_->AddComponentExtension(extension.get()); |
| 258 } | 258 } |
| 259 | 259 |
| 260 void ComponentLoader::Remove(const base::FilePath& root_directory) { | 260 void ComponentLoader::Remove(const base::FilePath& root_directory) { |
| 261 // Find the ComponentExtensionInfo for the extension. | 261 // Find the ComponentExtensionInfo for the extension. |
| 262 for (const auto& component_extension : component_extensions_) { | 262 for (const auto& component_extension : component_extensions_) { |
| 263 if (component_extension.root_directory == root_directory) { | 263 if (component_extension.root_directory == root_directory) { |
| 264 Remove(GenerateId(component_extension.manifest.get(), root_directory)); | 264 Remove(GenerateId(component_extension.manifest.get(), root_directory)); |
| 265 break; | 265 break; |
| 266 } | 266 } |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 return; // Error already logged. | 684 return; // Error already logged. |
| 685 std::string actual_extension_id = | 685 std::string actual_extension_id = |
| 686 Add(std::move(manifest), root_directory, false); | 686 Add(std::move(manifest), root_directory, false); |
| 687 CHECK_EQ(extension_id, actual_extension_id); | 687 CHECK_EQ(extension_id, actual_extension_id); |
| 688 if (!done_cb.is_null()) | 688 if (!done_cb.is_null()) |
| 689 done_cb.Run(); | 689 done_cb.Run(); |
| 690 } | 690 } |
| 691 #endif | 691 #endif |
| 692 | 692 |
| 693 } // namespace extensions | 693 } // namespace extensions |
| OLD | NEW |