| 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/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/extensions/event_router.h" | 8 #include "chrome/browser/extensions/event_router.h" |
| 9 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
| 10 #include "chrome/browser/extensions/extension_process_manager.h" | 10 #include "chrome/browser/extensions/extension_process_manager.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/extensions/extension_system.h" | 12 #include "chrome/browser/extensions/extension_system.h" |
| 13 #include "chrome/browser/extensions/lazy_background_task_queue.h" | 13 #include "chrome/browser/extensions/lazy_background_task_queue.h" |
| 14 #include "chrome/browser/extensions/updater/extension_updater.h" | 14 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/common/extensions/background_info.h" |
| 17 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
| 18 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 19 | 20 |
| 20 namespace extensions { | 21 namespace extensions { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 const char kOnStartupEvent[] = "runtime.onStartup"; | 25 const char kOnStartupEvent[] = "runtime.onStartup"; |
| 25 const char kOnInstalledEvent[] = "runtime.onInstalled"; | 26 const char kOnInstalledEvent[] = "runtime.onInstalled"; |
| 26 const char kOnUpdateAvailableEvent[] = "runtime.onUpdateAvailable"; | 27 const char kOnUpdateAvailableEvent[] = "runtime.onUpdateAvailable"; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 53 return; | 54 return; |
| 54 ExtensionSystem* system = ExtensionSystem::Get(profile); | 55 ExtensionSystem* system = ExtensionSystem::Get(profile); |
| 55 if (!system) | 56 if (!system) |
| 56 return; | 57 return; |
| 57 | 58 |
| 58 // If this is a persistent background page, we want to wait for it to load | 59 // If this is a persistent background page, we want to wait for it to load |
| 59 // (it might not be ready, since this is startup). But only enqueue once. | 60 // (it might not be ready, since this is startup). But only enqueue once. |
| 60 // If it fails to load the first time, don't bother trying again. | 61 // If it fails to load the first time, don't bother trying again. |
| 61 const Extension* extension = | 62 const Extension* extension = |
| 62 system->extension_service()->extensions()->GetByID(extension_id); | 63 system->extension_service()->extensions()->GetByID(extension_id); |
| 63 if (extension && extension->has_persistent_background_page() && first_call && | 64 if (extension && BackgroundInfo::HasPersistentBackgroundPage(extension) && |
| 65 first_call && |
| 64 system->lazy_background_task_queue()-> | 66 system->lazy_background_task_queue()-> |
| 65 ShouldEnqueueTask(profile, extension)) { | 67 ShouldEnqueueTask(profile, extension)) { |
| 66 system->lazy_background_task_queue()->AddPendingTask( | 68 system->lazy_background_task_queue()->AddPendingTask( |
| 67 profile, extension_id, | 69 profile, extension_id, |
| 68 base::Bind(&DispatchOnStartupEventImpl, | 70 base::Bind(&DispatchOnStartupEventImpl, |
| 69 profile, extension_id, false)); | 71 profile, extension_id, false)); |
| 70 return; | 72 return; |
| 71 } | 73 } |
| 72 | 74 |
| 73 scoped_ptr<base::ListValue> event_args(new ListValue()); | 75 scoped_ptr<base::ListValue> event_args(new ListValue()); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 did_reply_ = true; | 254 did_reply_ = true; |
| 253 results_.reset(new base::ListValue); | 255 results_.reset(new base::ListValue); |
| 254 results_->AppendString(kUpdateFound); | 256 results_->AppendString(kUpdateFound); |
| 255 base::DictionaryValue* details = new base::DictionaryValue; | 257 base::DictionaryValue* details = new base::DictionaryValue; |
| 256 results_->Append(details); | 258 results_->Append(details); |
| 257 details->SetString("version", version); | 259 details->SetString("version", version); |
| 258 SendResponse(true); | 260 SendResponse(true); |
| 259 } | 261 } |
| 260 | 262 |
| 261 } // namespace extensions | 263 } // namespace extensions |
| OLD | NEW |