| 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/requirements_checker.h" | 5 #include "chrome/browser/extensions/requirements_checker.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/gpu/gpu_feature_checker.h" | 9 #include "chrome/browser/gpu/gpu_feature_checker.h" |
| 10 #include "chrome/common/extensions/api/requirements/requirements_handler.h" |
| 10 #include "chrome/common/extensions/extension_manifest_constants.h" | 11 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 11 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 12 #include "chrome/common/extensions/manifest.h" | 13 #include "chrome/common/extensions/manifest.h" |
| 13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/common/gpu_feature_type.h" | 15 #include "content/public/common/gpu_feature_type.h" |
| 15 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 17 | 18 |
| 18 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 19 #include "base/win/metro.h" | 20 #include "base/win/metro.h" |
| 20 #endif // defined(OS_WIN) | 21 #endif // defined(OS_WIN) |
| 21 | 22 |
| 22 namespace extensions { | 23 namespace extensions { |
| 23 | 24 |
| 24 RequirementsChecker::RequirementsChecker() | 25 RequirementsChecker::RequirementsChecker() |
| 25 : pending_requirement_checks_(0) { | 26 : pending_requirement_checks_(0) { |
| 26 } | 27 } |
| 27 | 28 |
| 28 RequirementsChecker::~RequirementsChecker() { | 29 RequirementsChecker::~RequirementsChecker() { |
| 29 } | 30 } |
| 30 | 31 |
| 31 void RequirementsChecker::Check(scoped_refptr<const Extension> extension, | 32 void RequirementsChecker::Check(scoped_refptr<const Extension> extension, |
| 32 base::Callback<void(std::vector<std::string> errors)> callback) { | 33 base::Callback<void(std::vector<std::string> errors)> callback) { |
| 33 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 34 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 34 | 35 |
| 35 callback_ = callback; | 36 callback_ = callback; |
| 36 const Extension::Requirements& requirements = extension->requirements(); | 37 const RequirementsInfo& requirements = |
| 38 RequirementsInfo::GetRequirements(extension); |
| 37 | 39 |
| 38 if (requirements.npapi) { | 40 if (requirements.npapi) { |
| 39 #if defined(OS_CHROMEOS) | 41 #if defined(OS_CHROMEOS) |
| 40 errors_.push_back( | 42 errors_.push_back( |
| 41 l10n_util::GetStringUTF8(IDS_EXTENSION_NPAPI_NOT_SUPPORTED)); | 43 l10n_util::GetStringUTF8(IDS_EXTENSION_NPAPI_NOT_SUPPORTED)); |
| 42 #endif // defined(OS_CHROMEOS) | 44 #endif // defined(OS_CHROMEOS) |
| 43 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
| 44 if (base::win::IsMetroProcess()) { | 46 if (base::win::IsMetroProcess()) { |
| 45 errors_.push_back( | 47 errors_.push_back( |
| 46 l10n_util::GetStringUTF8(IDS_EXTENSION_NPAPI_NOT_SUPPORTED)); | 48 l10n_util::GetStringUTF8(IDS_EXTENSION_NPAPI_NOT_SUPPORTED)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 if (--pending_requirement_checks_ == 0) { | 101 if (--pending_requirement_checks_ == 0) { |
| 100 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 102 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| 101 base::Bind(callback_, errors_)); | 103 base::Bind(callback_, errors_)); |
| 102 // Reset the callback so any ref-counted bound parameters will get released. | 104 // Reset the callback so any ref-counted bound parameters will get released. |
| 103 callback_.Reset(); | 105 callback_.Reset(); |
| 104 errors_.clear(); | 106 errors_.clear(); |
| 105 } | 107 } |
| 106 } | 108 } |
| 107 | 109 |
| 108 } // namespace extensions | 110 } // namespace extensions |
| OLD | NEW |