Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1712)

Side by Side Diff: chrome/browser/extensions/api/runtime/runtime_api.cc

Issue 12220109: Fix a bug where chrome.runtime.getBackgroundPage would return null if the event (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698