| 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/api/runtime/runtime_api.h" | 5 #include "chrome/browser/extensions/api/runtime/runtime_api.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/event_router.h" | 7 #include "chrome/browser/extensions/event_router.h" |
| 8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
| 9 #include "chrome/browser/extensions/extension_process_manager.h" | 9 #include "chrome/browser/extensions/extension_process_manager.h" |
| 10 #include "chrome/browser/extensions/extension_system.h" | 10 #include "chrome/browser/extensions/extension_system.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 Profile* profile, const std::string& extension_id) { | 28 Profile* profile, const std::string& extension_id) { |
| 29 ExtensionSystem* system = ExtensionSystem::Get(profile); | 29 ExtensionSystem* system = ExtensionSystem::Get(profile); |
| 30 if (!system) | 30 if (!system) |
| 31 return; | 31 return; |
| 32 | 32 |
| 33 // Special case: normally, extensions add their own lazy event listeners. | 33 // Special case: normally, extensions add their own lazy event listeners. |
| 34 // However, since the extension has just been installed, it hasn't had a | 34 // However, since the extension has just been installed, it hasn't had a |
| 35 // chance to register for events. So we register on its behalf. If the | 35 // chance to register for events. So we register on its behalf. If the |
| 36 // extension does not actually have a listener, the event will just be | 36 // extension does not actually have a listener, the event will just be |
| 37 // ignored. | 37 // ignored. |
| 38 scoped_ptr<ListValue> event_args(new ListValue()); |
| 38 system->event_router()->AddLazyEventListener(kOnInstalledEvent, extension_id); | 39 system->event_router()->AddLazyEventListener(kOnInstalledEvent, extension_id); |
| 39 system->event_router()->DispatchEventToExtension( | 40 system->event_router()->DispatchEventToExtension( |
| 40 extension_id, kOnInstalledEvent, "[]", NULL, GURL()); | 41 extension_id, kOnInstalledEvent, event_args.Pass(), NULL, GURL()); |
| 41 } | 42 } |
| 42 | 43 |
| 43 bool RuntimeGetBackgroundPageFunction::RunImpl() { | 44 bool RuntimeGetBackgroundPageFunction::RunImpl() { |
| 44 ExtensionHost* host = | 45 ExtensionHost* host = |
| 45 ExtensionSystem::Get(profile())->process_manager()-> | 46 ExtensionSystem::Get(profile())->process_manager()-> |
| 46 GetBackgroundHostForExtension(extension_id()); | 47 GetBackgroundHostForExtension(extension_id()); |
| 47 if (host) { | 48 if (host) { |
| 48 OnPageLoaded(host); | 49 OnPageLoaded(host); |
| 49 } else if (GetExtension()->has_lazy_background_page()) { | 50 } else if (GetExtension()->has_lazy_background_page()) { |
| 50 ExtensionSystem::Get(profile())->lazy_background_task_queue()-> | 51 ExtensionSystem::Get(profile())->lazy_background_task_queue()-> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 63 void RuntimeGetBackgroundPageFunction::OnPageLoaded(ExtensionHost* host) { | 64 void RuntimeGetBackgroundPageFunction::OnPageLoaded(ExtensionHost* host) { |
| 64 if (host) { | 65 if (host) { |
| 65 SendResponse(true); | 66 SendResponse(true); |
| 66 } else { | 67 } else { |
| 67 error_ = kPageLoadError; | 68 error_ = kPageLoadError; |
| 68 SendResponse(false); | 69 SendResponse(false); |
| 69 } | 70 } |
| 70 } | 71 } |
| 71 | 72 |
| 72 } // namespace extensions | 73 } // namespace extensions |
| OLD | NEW |