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" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 return; | 125 return; |
126 | 126 |
127 scoped_ptr<ListValue> args(new ListValue); | 127 scoped_ptr<ListValue> args(new ListValue); |
128 args->Append(manifest->DeepCopy()); | 128 args->Append(manifest->DeepCopy()); |
129 DCHECK(system->event_router()); | 129 DCHECK(system->event_router()); |
130 scoped_ptr<Event> event(new Event(kOnUpdateAvailableEvent, args.Pass())); | 130 scoped_ptr<Event> event(new Event(kOnUpdateAvailableEvent, args.Pass())); |
131 system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); | 131 system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); |
132 } | 132 } |
133 | 133 |
134 bool RuntimeGetBackgroundPageFunction::RunImpl() { | 134 bool RuntimeGetBackgroundPageFunction::RunImpl() { |
135 ExtensionHost* host = | 135 ExtensionSystem* system = ExtensionSystem::Get(profile()); |
136 ExtensionSystem::Get(profile())->process_manager()-> | 136 ExtensionHost* host = system->process_manager()-> |
137 GetBackgroundHostForExtension(extension_id()); | 137 GetBackgroundHostForExtension(extension_id()); |
138 if (host) { | 138 if (system->lazy_background_task_queue()->ShouldEnqueueTask( |
| 139 profile(), GetExtension())) { |
| 140 system->lazy_background_task_queue()->AddPendingTask( |
| 141 profile(), extension_id(), |
| 142 base::Bind(&RuntimeGetBackgroundPageFunction::OnPageLoaded, this)); |
| 143 } else if (host) { |
139 OnPageLoaded(host); | 144 OnPageLoaded(host); |
140 } else if (GetExtension()->has_lazy_background_page()) { | |
141 ExtensionSystem::Get(profile())->lazy_background_task_queue()-> | |
142 AddPendingTask( | |
143 profile(), extension_id(), | |
144 base::Bind(&RuntimeGetBackgroundPageFunction::OnPageLoaded, | |
145 this)); | |
146 } else { | 145 } else { |
147 error_ = kNoBackgroundPageError; | 146 error_ = kNoBackgroundPageError; |
148 return false; | 147 return false; |
149 } | 148 } |
150 | 149 |
151 return true; | 150 return true; |
152 } | 151 } |
153 | 152 |
154 void RuntimeGetBackgroundPageFunction::OnPageLoaded(ExtensionHost* host) { | 153 void RuntimeGetBackgroundPageFunction::OnPageLoaded(ExtensionHost* host) { |
155 if (host) { | 154 if (host) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 did_reply_ = true; | 236 did_reply_ = true; |
238 results_.reset(new base::ListValue); | 237 results_.reset(new base::ListValue); |
239 results_->AppendString(kUpdateFound); | 238 results_->AppendString(kUpdateFound); |
240 base::DictionaryValue* details = new base::DictionaryValue; | 239 base::DictionaryValue* details = new base::DictionaryValue; |
241 results_->Append(details); | 240 results_->Append(details); |
242 details->SetString("version", version); | 241 details->SetString("version", version); |
243 SendResponse(true); | 242 SendResponse(true); |
244 } | 243 } |
245 | 244 |
246 } // namespace extensions | 245 } // namespace extensions |
OLD | NEW |