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/component_updater/component_updater_service.h" | 5 #include "chrome/browser/component_updater/component_updater_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 crx->size = it->size; | 846 crx->size = it->size; |
847 crx->diff_crx_url = it->diff_crx_url; | 847 crx->diff_crx_url = it->diff_crx_url; |
848 crx->diff_size = it->diff_size; | 848 crx->diff_size = it->diff_size; |
849 crx->status = CrxUpdateItem::kCanUpdate; | 849 crx->status = CrxUpdateItem::kCanUpdate; |
850 crx->next_version = Version(it->version); | 850 crx->next_version = Version(it->version); |
851 crx->next_fp = it->package_fingerprint; | 851 crx->next_fp = it->package_fingerprint; |
852 ++update_pending; | 852 ++update_pending; |
853 | 853 |
854 content::NotificationService::current()->Notify( | 854 content::NotificationService::current()->Notify( |
855 chrome::NOTIFICATION_COMPONENT_UPDATE_FOUND, | 855 chrome::NOTIFICATION_COMPONENT_UPDATE_FOUND, |
856 content::Source<std::string>(&crx->id), | 856 content::Source<UpdateSource>(&crx->id), |
857 content::NotificationService::NoDetails()); | 857 content::NotificationService::NoDetails()); |
858 } | 858 } |
859 | 859 |
860 // All the components that are not mentioned in the manifest we | 860 // All the components that are not mentioned in the manifest we |
861 // consider them up to date. | 861 // consider them up to date. |
862 ChangeItemStatus(CrxUpdateItem::kChecking, CrxUpdateItem::kUpToDate); | 862 ChangeItemStatus(CrxUpdateItem::kChecking, CrxUpdateItem::kUpToDate); |
863 | 863 |
864 // If there are updates pending we do a short wait. | 864 // If there are updates pending we do a short wait. |
865 ScheduleNextRun(update_pending > 0); | 865 ScheduleNextRun(update_pending > 0); |
866 } | 866 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 } else { | 914 } else { |
915 count = ChangeItemStatus(CrxUpdateItem::kDownloading, | 915 count = ChangeItemStatus(CrxUpdateItem::kDownloading, |
916 CrxUpdateItem::kUpdating); | 916 CrxUpdateItem::kUpdating); |
917 } | 917 } |
918 DCHECK_EQ(count, 1ul); | 918 DCHECK_EQ(count, 1ul); |
919 | 919 |
920 url_fetcher_.reset(); | 920 url_fetcher_.reset(); |
921 | 921 |
922 content::NotificationService::current()->Notify( | 922 content::NotificationService::current()->Notify( |
923 chrome::NOTIFICATION_COMPONENT_UPDATE_READY, | 923 chrome::NOTIFICATION_COMPONENT_UPDATE_READY, |
924 content::Source<std::string>(&context->id), | 924 content::Source<UpdateSource>(&context->id), |
925 content::NotificationService::NoDetails()); | 925 content::NotificationService::NoDetails()); |
926 | 926 |
927 // Why unretained? See comment at top of file. | 927 // Why unretained? See comment at top of file. |
928 BrowserThread::PostDelayedTask( | 928 BrowserThread::PostDelayedTask( |
929 BrowserThread::FILE, | 929 BrowserThread::FILE, |
930 FROM_HERE, | 930 FROM_HERE, |
931 base::Bind(&CrxUpdateService::Install, | 931 base::Bind(&CrxUpdateService::Install, |
932 base::Unretained(this), | 932 base::Unretained(this), |
933 context, | 933 context, |
934 temp_crx_path), | 934 temp_crx_path), |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 break; | 997 break; |
998 default: | 998 default: |
999 event = Configurator::kUnpackError; | 999 event = Configurator::kUnpackError; |
1000 break; | 1000 break; |
1001 } | 1001 } |
1002 | 1002 |
1003 config_->OnEvent(event, CrxIdtoUMAId(component_id)); | 1003 config_->OnEvent(event, CrxIdtoUMAId(component_id)); |
1004 ScheduleNextRun(false); | 1004 ScheduleNextRun(false); |
1005 } | 1005 } |
1006 | 1006 |
| 1007 bool ComponentUpdateService::IsUpdateNotificationForComponent( |
| 1008 const content::NotificationSource& src, |
| 1009 const CrxComponent& component) { |
| 1010 std::string id = |
| 1011 HexStringToID(StringToLowerASCII(base::HexEncode(&component.pk_hash[0], |
| 1012 component.pk_hash.size()/2))); |
| 1013 return content::Source<UpdateSource>(src)->compare(id) == 0; |
| 1014 } |
| 1015 |
1007 // The component update factory. Using the component updater as a singleton | 1016 // The component update factory. Using the component updater as a singleton |
1008 // is the job of the browser process. | 1017 // is the job of the browser process. |
1009 ComponentUpdateService* ComponentUpdateServiceFactory( | 1018 ComponentUpdateService* ComponentUpdateServiceFactory( |
1010 ComponentUpdateService::Configurator* config) { | 1019 ComponentUpdateService::Configurator* config) { |
1011 DCHECK(config); | 1020 DCHECK(config); |
1012 return new CrxUpdateService(config); | 1021 return new CrxUpdateService(config); |
1013 } | 1022 } |
OLD | NEW |