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 24 matching lines...) Expand all Loading... |
51 return; | 52 return; |
52 ExtensionSystem* system = ExtensionSystem::Get(profile); | 53 ExtensionSystem* system = ExtensionSystem::Get(profile); |
53 if (!system) | 54 if (!system) |
54 return; | 55 return; |
55 | 56 |
56 // If this is a persistent background page, we want to wait for it to load | 57 // If this is a persistent background page, we want to wait for it to load |
57 // (it might not be ready, since this is startup). But only enqueue once. | 58 // (it might not be ready, since this is startup). But only enqueue once. |
58 // If it fails to load the first time, don't bother trying again. | 59 // If it fails to load the first time, don't bother trying again. |
59 const Extension* extension = | 60 const Extension* extension = |
60 system->extension_service()->extensions()->GetByID(extension_id); | 61 system->extension_service()->extensions()->GetByID(extension_id); |
61 if (extension && extension->has_persistent_background_page() && first_call && | 62 if (extension && BackgroundInfo::HasPersistentBackgroundPage(extension) && |
| 63 first_call && |
62 system->lazy_background_task_queue()-> | 64 system->lazy_background_task_queue()-> |
63 ShouldEnqueueTask(profile, extension)) { | 65 ShouldEnqueueTask(profile, extension)) { |
64 system->lazy_background_task_queue()->AddPendingTask( | 66 system->lazy_background_task_queue()->AddPendingTask( |
65 profile, extension_id, | 67 profile, extension_id, |
66 base::Bind(&DispatchOnStartupEventImpl, | 68 base::Bind(&DispatchOnStartupEventImpl, |
67 profile, extension_id, false)); | 69 profile, extension_id, false)); |
68 return; | 70 return; |
69 } | 71 } |
70 | 72 |
71 scoped_ptr<base::ListValue> event_args(new ListValue()); | 73 scoped_ptr<base::ListValue> event_args(new ListValue()); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 did_reply_ = true; | 238 did_reply_ = true; |
237 results_.reset(new base::ListValue); | 239 results_.reset(new base::ListValue); |
238 results_->AppendString(kUpdateFound); | 240 results_->AppendString(kUpdateFound); |
239 base::DictionaryValue* details = new base::DictionaryValue; | 241 base::DictionaryValue* details = new base::DictionaryValue; |
240 results_->Append(details); | 242 results_->Append(details); |
241 details->SetString("version", version); | 243 details->SetString("version", version); |
242 SendResponse(true); | 244 SendResponse(true); |
243 } | 245 } |
244 | 246 |
245 } // namespace extensions | 247 } // namespace extensions |
OLD | NEW |