| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "apps/shell/browser/shell_extension_system.h" | 5 #include "apps/shell/browser/shell_extension_system.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "apps/shell_window_registry.h" |
| 9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/common/extensions/extension_file_util.h" | 13 #include "chrome/common/extensions/extension_file_util.h" |
| 13 #include "content/public/browser/browser_context.h" | 14 #include "content/public/browser/browser_context.h" |
| 14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/notification_details.h" | 16 #include "content/public/browser/notification_details.h" |
| 16 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 17 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
| 18 #include "extensions/browser/event_router.h" | 19 #include "extensions/browser/event_router.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 scoped_refptr<Extension> extension = | 53 scoped_refptr<Extension> extension = |
| 53 extension_file_util::LoadExtension(app_dir, | 54 extension_file_util::LoadExtension(app_dir, |
| 54 extensions::Manifest::COMMAND_LINE, | 55 extensions::Manifest::COMMAND_LINE, |
| 55 Extension::NO_FLAGS, | 56 Extension::NO_FLAGS, |
| 56 &load_error); | 57 &load_error); |
| 57 if (!extension) { | 58 if (!extension) { |
| 58 LOG(ERROR) << "Loading extension at " << app_dir.value() | 59 LOG(ERROR) << "Loading extension at " << app_dir.value() |
| 59 << " failed with: " << load_error; | 60 << " failed with: " << load_error; |
| 60 return false; | 61 return false; |
| 61 } | 62 } |
| 63 app_id_ = extension->id(); |
| 62 | 64 |
| 63 // TODO(jamescook): We may want to do some of these things here: | 65 // TODO(jamescook): We may want to do some of these things here: |
| 64 // * Create a PermissionsUpdater. | 66 // * Create a PermissionsUpdater. |
| 65 // * Call PermissionsUpdater::GrantActivePermissions(). | 67 // * Call PermissionsUpdater::GrantActivePermissions(). |
| 66 // * Call ExtensionService::SatisfyImports(). | 68 // * Call ExtensionService::SatisfyImports(). |
| 67 // * Call ExtensionPrefs::OnExtensionInstalled(). | 69 // * Call ExtensionPrefs::OnExtensionInstalled(). |
| 68 // * Send NOTIFICATION_EXTENSION_INSTALLED. | 70 // * Send NOTIFICATION_EXTENSION_INSTALLED. |
| 69 | 71 |
| 70 ExtensionRegistry::Get(browser_context_)->AddEnabled(extension); | 72 ExtensionRegistry::Get(browser_context_)->AddEnabled(extension); |
| 71 | 73 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 90 launch_data->SetBoolean("isKioskSession", false); | 92 launch_data->SetBoolean("isKioskSession", false); |
| 91 scoped_ptr<base::ListValue> event_args(new base::ListValue()); | 93 scoped_ptr<base::ListValue> event_args(new base::ListValue()); |
| 92 event_args->Append(launch_data.release()); | 94 event_args->Append(launch_data.release()); |
| 93 scoped_ptr<Event> event( | 95 scoped_ptr<Event> event( |
| 94 new Event("app.runtime.onLaunched", event_args.Pass())); | 96 new Event("app.runtime.onLaunched", event_args.Pass())); |
| 95 event_router_->DispatchEventWithLazyListener(extension->id(), event.Pass()); | 97 event_router_->DispatchEventWithLazyListener(extension->id(), event.Pass()); |
| 96 | 98 |
| 97 return true; | 99 return true; |
| 98 } | 100 } |
| 99 | 101 |
| 102 void ShellExtensionSystem::CloseApp() { |
| 103 apps::ShellWindowRegistry::Get(browser_context_) |
| 104 ->CloseAllShellWindowsForApp(app_id_); |
| 105 } |
| 106 |
| 100 void ShellExtensionSystem::Shutdown() { | 107 void ShellExtensionSystem::Shutdown() { |
| 101 } | 108 } |
| 102 | 109 |
| 103 void ShellExtensionSystem::InitForRegularProfile(bool extensions_enabled) { | 110 void ShellExtensionSystem::InitForRegularProfile(bool extensions_enabled) { |
| 104 runtime_data_.reset( | 111 runtime_data_.reset( |
| 105 new RuntimeData(ExtensionRegistry::Get(browser_context_))); | 112 new RuntimeData(ExtensionRegistry::Get(browser_context_))); |
| 106 lazy_background_task_queue_.reset( | 113 lazy_background_task_queue_.reset( |
| 107 new LazyBackgroundTaskQueue(browser_context_)); | 114 new LazyBackgroundTaskQueue(browser_context_)); |
| 108 event_router_.reset( | 115 event_router_.reset( |
| 109 new EventRouter(browser_context_, ExtensionPrefs::Get(browser_context_))); | 116 new EventRouter(browser_context_, ExtensionPrefs::Get(browser_context_))); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 void ShellExtensionSystem::UnregisterExtensionWithRequestContexts( | 192 void ShellExtensionSystem::UnregisterExtensionWithRequestContexts( |
| 186 const std::string& extension_id, | 193 const std::string& extension_id, |
| 187 const UnloadedExtensionInfo::Reason reason) { | 194 const UnloadedExtensionInfo::Reason reason) { |
| 188 } | 195 } |
| 189 | 196 |
| 190 const OneShotEvent& ShellExtensionSystem::ready() const { | 197 const OneShotEvent& ShellExtensionSystem::ready() const { |
| 191 return ready_; | 198 return ready_; |
| 192 } | 199 } |
| 193 | 200 |
| 194 } // namespace extensions | 201 } // namespace extensions |
| OLD | NEW |