| 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/extension_global_error.h" | 5 #include "chrome/browser/extensions/extension_global_error.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/ui/global_error.h" | 11 #include "chrome/browser/ui/global_error.h" |
| 12 #include "grit/chromium_strings.h" | 12 #include "grit/chromium_strings.h" |
| 13 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 | 15 |
| 16 using extensions::ExtensionIdSet; |
| 17 |
| 16 ExtensionGlobalError::ExtensionGlobalError(ExtensionService* extension_service) | 18 ExtensionGlobalError::ExtensionGlobalError(ExtensionService* extension_service) |
| 17 : extension_service_(extension_service), | 19 : extension_service_(extension_service), |
| 18 external_extension_ids_(new ExtensionIdSet), | 20 external_extension_ids_(new ExtensionIdSet), |
| 19 blacklisted_extension_ids_(new ExtensionIdSet), | 21 blacklisted_extension_ids_(new ExtensionIdSet), |
| 20 orphaned_extension_ids_(new ExtensionIdSet) { | 22 orphaned_extension_ids_(new ExtensionIdSet) { |
| 21 DCHECK(extension_service_); | 23 DCHECK(extension_service_); |
| 22 } | 24 } |
| 23 | 25 |
| 24 ExtensionGlobalError::~ExtensionGlobalError() { | 26 ExtensionGlobalError::~ExtensionGlobalError() { |
| 25 } | 27 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 70 |
| 69 string16 ExtensionGlobalError::GenerateMessageSection( | 71 string16 ExtensionGlobalError::GenerateMessageSection( |
| 70 const ExtensionIdSet* extensions, | 72 const ExtensionIdSet* extensions, |
| 71 int template_message_id) { | 73 int template_message_id) { |
| 72 CHECK(extensions); | 74 CHECK(extensions); |
| 73 CHECK(template_message_id); | 75 CHECK(template_message_id); |
| 74 string16 message; | 76 string16 message; |
| 75 | 77 |
| 76 for (ExtensionIdSet::const_iterator iter = extensions->begin(); | 78 for (ExtensionIdSet::const_iterator iter = extensions->begin(); |
| 77 iter != extensions->end(); ++iter) { | 79 iter != extensions->end(); ++iter) { |
| 78 const Extension* e = extension_service_->GetExtensionById(*iter, true); | 80 const extensions::Extension* e = extension_service_->GetExtensionById(*iter, |
| 81 true); |
| 79 message += l10n_util::GetStringFUTF16(template_message_id, | 82 message += l10n_util::GetStringFUTF16(template_message_id, |
| 80 string16(ASCIIToUTF16(e->name()))); | 83 string16(ASCIIToUTF16(e->name()))); |
| 81 } | 84 } |
| 82 return message; | 85 return message; |
| 83 } | 86 } |
| 84 | 87 |
| 85 string16 ExtensionGlobalError::GenerateMessage() { | 88 string16 ExtensionGlobalError::GenerateMessage() { |
| 86 return GenerateMessageSection(external_extension_ids_.get(), | 89 return GenerateMessageSection(external_extension_ids_.get(), |
| 87 IDS_EXTENSION_ALERT_ITEM_EXTERNAL) + | 90 IDS_EXTENSION_ALERT_ITEM_EXTERNAL) + |
| 88 GenerateMessageSection(blacklisted_extension_ids_.get(), | 91 GenerateMessageSection(blacklisted_extension_ids_.get(), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 112 extension_service_->HandleExtensionAlertClosed(); | 115 extension_service_->HandleExtensionAlertClosed(); |
| 113 } | 116 } |
| 114 | 117 |
| 115 void ExtensionGlobalError::BubbleViewAcceptButtonPressed(Browser* browser) { | 118 void ExtensionGlobalError::BubbleViewAcceptButtonPressed(Browser* browser) { |
| 116 extension_service_->HandleExtensionAlertAccept(); | 119 extension_service_->HandleExtensionAlertAccept(); |
| 117 } | 120 } |
| 118 | 121 |
| 119 void ExtensionGlobalError::BubbleViewCancelButtonPressed(Browser* browser) { | 122 void ExtensionGlobalError::BubbleViewCancelButtonPressed(Browser* browser) { |
| 120 extension_service_->HandleExtensionAlertDetails(browser); | 123 extension_service_->HandleExtensionAlertDetails(browser); |
| 121 } | 124 } |
| OLD | NEW |