| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/shell/browser/shell_extension_system.h" | 5 #include "extensions/shell/browser/shell_extension_system.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 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" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 bool ShellExtensionSystem::LoadApp(const base::FilePath& app_dir) { | 41 bool ShellExtensionSystem::LoadApp(const base::FilePath& app_dir) { |
| 42 // app_shell only supports unpacked extensions. | 42 // app_shell only supports unpacked extensions. |
| 43 // NOTE: If you add packed extension support consider removing the flag | 43 // NOTE: If you add packed extension support consider removing the flag |
| 44 // FOLLOW_SYMLINKS_ANYWHERE below. Packed extensions should not have symlinks. | 44 // FOLLOW_SYMLINKS_ANYWHERE below. Packed extensions should not have symlinks. |
| 45 CHECK(base::DirectoryExists(app_dir)) << app_dir.AsUTF8Unsafe(); | 45 CHECK(base::DirectoryExists(app_dir)) << app_dir.AsUTF8Unsafe(); |
| 46 int load_flags = Extension::FOLLOW_SYMLINKS_ANYWHERE; | 46 int load_flags = Extension::FOLLOW_SYMLINKS_ANYWHERE; |
| 47 std::string load_error; | 47 std::string load_error; |
| 48 extension_ = file_util::LoadExtension( | 48 extension_ = file_util::LoadExtension( |
| 49 app_dir, Manifest::COMMAND_LINE, load_flags, &load_error); | 49 app_dir, Manifest::COMMAND_LINE, load_flags, &load_error); |
| 50 if (!extension_) { | 50 if (!extension_.get()) { |
| 51 LOG(ERROR) << "Loading extension at " << app_dir.value() | 51 LOG(ERROR) << "Loading extension at " << app_dir.value() |
| 52 << " failed with: " << load_error; | 52 << " failed with: " << load_error; |
| 53 return false; | 53 return false; |
| 54 } | 54 } |
| 55 app_id_ = extension_->id(); | 55 app_id_ = extension_->id(); |
| 56 | 56 |
| 57 // TODO(jamescook): We may want to do some of these things here: | 57 // TODO(jamescook): We may want to do some of these things here: |
| 58 // * Create a PermissionsUpdater. | 58 // * Create a PermissionsUpdater. |
| 59 // * Call PermissionsUpdater::GrantActivePermissions(). | 59 // * Call PermissionsUpdater::GrantActivePermissions(). |
| 60 // * Call ExtensionService::SatisfyImports(). | 60 // * Call ExtensionService::SatisfyImports(). |
| 61 // * Call ExtensionPrefs::OnExtensionInstalled(). | 61 // * Call ExtensionPrefs::OnExtensionInstalled(). |
| 62 // * Send NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED. | 62 // * Send NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED. |
| 63 | 63 |
| 64 ExtensionRegistry::Get(browser_context_)->AddEnabled(extension_); | 64 ExtensionRegistry::Get(browser_context_)->AddEnabled(extension_); |
| 65 | 65 |
| 66 RegisterExtensionWithRequestContexts(extension_); | 66 RegisterExtensionWithRequestContexts(extension_.get()); |
| 67 | 67 |
| 68 content::NotificationService::current()->Notify( | 68 content::NotificationService::current()->Notify( |
| 69 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | 69 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 70 content::Source<BrowserContext>(browser_context_), | 70 content::Source<BrowserContext>(browser_context_), |
| 71 content::Details<const Extension>(extension_)); | 71 content::Details<const Extension>(extension_.get())); |
| 72 | 72 |
| 73 // Inform the rest of the extensions system to start. | 73 // Inform the rest of the extensions system to start. |
| 74 ready_.Signal(); | 74 ready_.Signal(); |
| 75 content::NotificationService::current()->Notify( | 75 content::NotificationService::current()->Notify( |
| 76 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED, | 76 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED, |
| 77 content::Source<BrowserContext>(browser_context_), | 77 content::Source<BrowserContext>(browser_context_), |
| 78 content::NotificationService::NoDetails()); | 78 content::NotificationService::NoDetails()); |
| 79 return true; | 79 return true; |
| 80 } | 80 } |
| 81 | 81 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 return NULL; | 124 return NULL; |
| 125 } | 125 } |
| 126 | 126 |
| 127 StateStore* ShellExtensionSystem::rules_store() { | 127 StateStore* ShellExtensionSystem::rules_store() { |
| 128 return NULL; | 128 return NULL; |
| 129 } | 129 } |
| 130 | 130 |
| 131 InfoMap* ShellExtensionSystem::info_map() { | 131 InfoMap* ShellExtensionSystem::info_map() { |
| 132 if (!info_map_.get()) | 132 if (!info_map_.get()) |
| 133 info_map_ = new InfoMap; | 133 info_map_ = new InfoMap; |
| 134 return info_map_; | 134 return info_map_.get(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 LazyBackgroundTaskQueue* ShellExtensionSystem::lazy_background_task_queue() { | 137 LazyBackgroundTaskQueue* ShellExtensionSystem::lazy_background_task_queue() { |
| 138 return lazy_background_task_queue_.get(); | 138 return lazy_background_task_queue_.get(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 EventRouter* ShellExtensionSystem::event_router() { | 141 EventRouter* ShellExtensionSystem::event_router() { |
| 142 return event_router_.get(); | 142 return event_router_.get(); |
| 143 } | 143 } |
| 144 | 144 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 return empty.PassAs<ExtensionSet>(); | 193 return empty.PassAs<ExtensionSet>(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 DeclarativeUserScriptMaster* | 196 DeclarativeUserScriptMaster* |
| 197 ShellExtensionSystem::GetDeclarativeUserScriptMasterByExtension( | 197 ShellExtensionSystem::GetDeclarativeUserScriptMasterByExtension( |
| 198 const ExtensionId& extension_id) { | 198 const ExtensionId& extension_id) { |
| 199 return NULL; | 199 return NULL; |
| 200 } | 200 } |
| 201 | 201 |
| 202 } // namespace extensions | 202 } // namespace extensions |
| OLD | NEW |