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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 void RuntimeAPI::OnExtensionLoaded(const Extension* extension) { | 208 void RuntimeAPI::OnExtensionLoaded(const Extension* extension) { |
209 if (!dispatch_chrome_updated_event_) | 209 if (!dispatch_chrome_updated_event_) |
210 return; | 210 return; |
211 | 211 |
212 // Dispatch the onInstalled event with reason "chrome_update". | 212 // Dispatch the onInstalled event with reason "chrome_update". |
213 base::MessageLoop::current()->PostTask( | 213 base::MessageLoop::current()->PostTask( |
214 FROM_HERE, | 214 FROM_HERE, |
215 base::Bind(&RuntimeEventRouter::DispatchOnInstalledEvent, | 215 base::Bind(&RuntimeEventRouter::DispatchOnInstalledEvent, |
216 browser_context_, | 216 browser_context_, |
217 extension->id(), | 217 extension->id(), |
218 Version(), | 218 base::Version(), |
219 true)); | 219 true)); |
220 } | 220 } |
221 | 221 |
222 void RuntimeAPI::OnExtensionInstalled(const Extension* extension) { | 222 void RuntimeAPI::OnExtensionInstalled(const Extension* extension) { |
223 // Get the previous version to check if this is an upgrade. | 223 // Get the previous version to check if this is an upgrade. |
224 ExtensionService* service = ExtensionSystem::GetForBrowserContext( | 224 ExtensionService* service = ExtensionSystem::GetForBrowserContext( |
225 browser_context_)->extension_service(); | 225 browser_context_)->extension_service(); |
226 const Extension* old = service->GetExtensionById(extension->id(), true); | 226 const Extension* old = service->GetExtensionById(extension->id(), true); |
227 Version old_version; | 227 base::Version old_version; |
228 if (old) | 228 if (old) |
229 old_version = *old->version(); | 229 old_version = *old->version(); |
230 | 230 |
231 // Dispatch the onInstalled event. | 231 // Dispatch the onInstalled event. |
232 base::MessageLoop::current()->PostTask( | 232 base::MessageLoop::current()->PostTask( |
233 FROM_HERE, | 233 FROM_HERE, |
234 base::Bind(&RuntimeEventRouter::DispatchOnInstalledEvent, | 234 base::Bind(&RuntimeEventRouter::DispatchOnInstalledEvent, |
235 browser_context_, | 235 browser_context_, |
236 extension->id(), | 236 extension->id(), |
237 old_version, | 237 old_version, |
(...skipping 24 matching lines...) Expand all Loading... |
262 content::BrowserContext* context, const std::string& extension_id) { | 262 content::BrowserContext* context, const std::string& extension_id) { |
263 // TODO(jamescook): Convert to BrowserContext all the way down. | 263 // TODO(jamescook): Convert to BrowserContext all the way down. |
264 Profile* profile = static_cast<Profile*>(context); | 264 Profile* profile = static_cast<Profile*>(context); |
265 DispatchOnStartupEventImpl(profile, extension_id, true, NULL); | 265 DispatchOnStartupEventImpl(profile, extension_id, true, NULL); |
266 } | 266 } |
267 | 267 |
268 // static | 268 // static |
269 void RuntimeEventRouter::DispatchOnInstalledEvent( | 269 void RuntimeEventRouter::DispatchOnInstalledEvent( |
270 content::BrowserContext* context, | 270 content::BrowserContext* context, |
271 const std::string& extension_id, | 271 const std::string& extension_id, |
272 const Version& old_version, | 272 const base::Version& old_version, |
273 bool chrome_updated) { | 273 bool chrome_updated) { |
274 if (!ExtensionsBrowserClient::Get()->IsValidContext(context)) | 274 if (!ExtensionsBrowserClient::Get()->IsValidContext(context)) |
275 return; | 275 return; |
276 ExtensionSystem* system = ExtensionSystem::GetForBrowserContext(context); | 276 ExtensionSystem* system = ExtensionSystem::GetForBrowserContext(context); |
277 if (!system) | 277 if (!system) |
278 return; | 278 return; |
279 | 279 |
280 scoped_ptr<base::ListValue> event_args(new base::ListValue()); | 280 scoped_ptr<base::ListValue> event_args(new base::ListValue()); |
281 base::DictionaryValue* info = new base::DictionaryValue(); | 281 base::DictionaryValue* info = new base::DictionaryValue(); |
282 event_args->Append(info); | 282 event_args->Append(info); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 } | 470 } |
471 | 471 |
472 void RuntimeRequestUpdateCheckFunction::Observe( | 472 void RuntimeRequestUpdateCheckFunction::Observe( |
473 int type, | 473 int type, |
474 const content::NotificationSource& source, | 474 const content::NotificationSource& source, |
475 const content::NotificationDetails& details) { | 475 const content::NotificationDetails& details) { |
476 if (did_reply_) | 476 if (did_reply_) |
477 return; | 477 return; |
478 | 478 |
479 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND); | 479 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND); |
480 typedef const std::pair<std::string, Version> UpdateDetails; | 480 typedef const std::pair<std::string, base::Version> UpdateDetails; |
481 const std::string& id = content::Details<UpdateDetails>(details)->first; | 481 const std::string& id = content::Details<UpdateDetails>(details)->first; |
482 const Version& version = content::Details<UpdateDetails>(details)->second; | 482 const base::Version& version = |
| 483 content::Details<UpdateDetails>(details)->second; |
483 if (id == extension_id()) { | 484 if (id == extension_id()) { |
484 ReplyUpdateFound(version.GetString()); | 485 ReplyUpdateFound(version.GetString()); |
485 } | 486 } |
486 } | 487 } |
487 | 488 |
488 void RuntimeRequestUpdateCheckFunction::ReplyUpdateFound( | 489 void RuntimeRequestUpdateCheckFunction::ReplyUpdateFound( |
489 const std::string& version) { | 490 const std::string& version) { |
490 did_reply_ = true; | 491 did_reply_ = true; |
491 results_.reset(new base::ListValue); | 492 results_.reset(new base::ListValue); |
492 results_->AppendString(kUpdateFound); | 493 results_->AppendString(kUpdateFound); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 content::ChildProcessSecurityPolicy::GetInstance(); | 574 content::ChildProcessSecurityPolicy::GetInstance(); |
574 policy->GrantReadFileSystem(renderer_id, filesystem_id); | 575 policy->GrantReadFileSystem(renderer_id, filesystem_id); |
575 base::DictionaryValue* dict = new base::DictionaryValue(); | 576 base::DictionaryValue* dict = new base::DictionaryValue(); |
576 SetResult(dict); | 577 SetResult(dict); |
577 dict->SetString("fileSystemId", filesystem_id); | 578 dict->SetString("fileSystemId", filesystem_id); |
578 dict->SetString("baseName", relative_path); | 579 dict->SetString("baseName", relative_path); |
579 return true; | 580 return true; |
580 } | 581 } |
581 | 582 |
582 } // namespace extensions | 583 } // namespace extensions |
OLD | NEW |