OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extensions_service.h" | 5 #include "chrome/browser/extensions/extensions_service.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/gfx/png_encoder.h" | 10 #include "base/gfx/png_encoder.h" |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 delete extension; | 319 delete extension; |
320 } | 320 } |
321 | 321 |
322 void ExtensionsService::LoadExtension(const FilePath& extension_path) { | 322 void ExtensionsService::LoadExtension(const FilePath& extension_path) { |
323 backend_loop_->PostTask(FROM_HERE, NewRunnableMethod(backend_.get(), | 323 backend_loop_->PostTask(FROM_HERE, NewRunnableMethod(backend_.get(), |
324 &ExtensionsServiceBackend::LoadSingleExtension, | 324 &ExtensionsServiceBackend::LoadSingleExtension, |
325 extension_path, scoped_refptr<ExtensionsService>(this))); | 325 extension_path, scoped_refptr<ExtensionsService>(this))); |
326 } | 326 } |
327 | 327 |
328 void ExtensionsService::OnExtensionsLoaded(ExtensionList* new_extensions) { | 328 void ExtensionsService::OnExtensionsLoaded(ExtensionList* new_extensions) { |
329 extensions_.insert(extensions_.end(), new_extensions->begin(), | 329 // If extensions aren't enabled, we still want to add themes. However, themes |
330 new_extensions->end()); | 330 // should not trigger EXTENSIONS_LOADED. |
331 NotificationService::current()->Notify( | 331 bool has_extension = false; |
332 NotificationType::EXTENSIONS_LOADED, | 332 for (ExtensionList::iterator iter = new_extensions->begin(); |
333 NotificationService::AllSources(), | 333 iter != new_extensions->end(); ++iter) { |
334 Details<ExtensionList>(new_extensions)); | 334 if (extensions_enabled() || (*iter)->IsTheme()) { |
335 extensions_.push_back(*iter); | |
336 if (!(*iter)->IsTheme()) | |
337 has_extension = true; | |
338 } | |
339 } | |
340 | |
341 if (has_extension) { | |
Aaron Boodman
2009/06/01 23:44:36
Can you add:
TODO(aa): This can be re-enabled whe
| |
342 NotificationService::current()->Notify( | |
343 NotificationType::EXTENSIONS_LOADED, | |
344 NotificationService::AllSources(), | |
345 Details<ExtensionList>(new_extensions)); | |
346 } | |
335 delete new_extensions; | 347 delete new_extensions; |
336 } | 348 } |
337 | 349 |
338 void ExtensionsService::OnExtensionInstalled(Extension* extension, | 350 void ExtensionsService::OnExtensionInstalled(Extension* extension, |
339 bool update) { | 351 bool update) { |
340 NotificationService::current()->Notify( | |
341 NotificationType::EXTENSION_INSTALLED, | |
342 NotificationService::AllSources(), | |
343 Details<Extension>(extension)); | |
344 | |
345 // If the extension is a theme, tell the profile (and therefore ThemeProvider) | 352 // If the extension is a theme, tell the profile (and therefore ThemeProvider) |
346 // to apply it. | 353 // to apply it. |
347 if (extension->IsTheme()) { | 354 if (extension->IsTheme()) { |
348 NotificationService::current()->Notify( | 355 NotificationService::current()->Notify( |
349 NotificationType::THEME_INSTALLED, | 356 NotificationType::THEME_INSTALLED, |
350 NotificationService::AllSources(), | 357 NotificationService::AllSources(), |
351 Details<Extension>(extension)); | 358 Details<Extension>(extension)); |
359 } else { | |
360 NotificationService::current()->Notify( | |
361 NotificationType::EXTENSION_INSTALLED, | |
362 NotificationService::AllSources(), | |
363 Details<Extension>(extension)); | |
352 } | 364 } |
353 } | 365 } |
354 | 366 |
355 void ExtensionsService::OnExtensionVersionReinstalled(const std::string& id) { | 367 void ExtensionsService::OnExtensionVersionReinstalled(const std::string& id) { |
356 Extension* extension = GetExtensionByID(id); | 368 Extension* extension = GetExtensionByID(id); |
357 if (extension && extension->IsTheme()) { | 369 if (extension && extension->IsTheme()) { |
358 NotificationService::current()->Notify( | 370 NotificationService::current()->Notify( |
359 NotificationType::THEME_INSTALLED, | 371 NotificationType::THEME_INSTALLED, |
360 NotificationService::AllSources(), | 372 NotificationService::AllSources(), |
361 Details<Extension>(extension)); | 373 Details<Extension>(extension)); |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
995 | 1007 |
996 bool ExtensionsServiceBackend::ShouldInstall(const std::string& id, | 1008 bool ExtensionsServiceBackend::ShouldInstall(const std::string& id, |
997 const std::string& version) { | 1009 const std::string& version) { |
998 FilePath dir(install_directory_.AppendASCII(id.c_str())); | 1010 FilePath dir(install_directory_.AppendASCII(id.c_str())); |
999 std::string current_version; | 1011 std::string current_version; |
1000 if (ReadCurrentVersion(dir, ¤t_version)) { | 1012 if (ReadCurrentVersion(dir, ¤t_version)) { |
1001 return CheckCurrentVersion(version, current_version, dir); | 1013 return CheckCurrentVersion(version, current_version, dir); |
1002 } | 1014 } |
1003 return true; | 1015 return true; |
1004 } | 1016 } |
OLD | NEW |