| Index: components/component_updater/component_updater_service.cc
|
| diff --git a/components/component_updater/component_updater_service.cc b/components/component_updater/component_updater_service.cc
|
| index ab4ad19a24074eb33c711eeaa958a8fb4927f8cf..465493853fcf8894e8dde61685f8a8d58f77177a 100644
|
| --- a/components/component_updater/component_updater_service.cc
|
| +++ b/components/component_updater/component_updater_service.cc
|
| @@ -21,6 +21,7 @@
|
| #include "base/metrics/histogram_macros.h"
|
| #include "base/sequenced_task_runner.h"
|
| #include "base/single_thread_task_runner.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| #include "base/threading/sequenced_worker_pool.h"
|
| #include "base/threading/thread_checker.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| @@ -49,6 +50,9 @@ enum UpdateType {
|
|
|
| namespace component_updater {
|
|
|
| +ComponentInfo::ComponentInfo() {}
|
| +ComponentInfo::~ComponentInfo() {}
|
| +
|
| CrxUpdateService::CrxUpdateService(
|
| const scoped_refptr<Configurator>& config,
|
| const scoped_refptr<UpdateClient>& update_client)
|
| @@ -122,6 +126,8 @@ bool CrxUpdateService::RegisterComponent(const CrxComponent& component) {
|
|
|
| components_.insert(std::make_pair(id, component));
|
| components_order_.push_back(id);
|
| + for (const auto& mime_type : component.handled_mime_types)
|
| + component_ids_by_mime_type_[mime_type] = id;
|
|
|
| // Create an initial state for this component. The state is mutated in
|
| // response to events from the UpdateClient instance.
|
| @@ -185,6 +191,20 @@ std::vector<std::string> CrxUpdateService::GetComponentIDs() const {
|
| return ids;
|
| }
|
|
|
| +bool CrxUpdateService::GetComponentForMimeType(const std::string& mime_type,
|
| + ComponentInfo* info) const {
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| + const auto it = component_ids_by_mime_type_.find(mime_type);
|
| + if (it == component_ids_by_mime_type_.end())
|
| + return false;
|
| + const auto component = GetComponent(it->second);
|
| + if (!component)
|
| + return false;
|
| + info->id = GetCrxComponentID(*component);
|
| + info->name = base::UTF8ToUTF16(component->name);
|
| + return true;
|
| +}
|
| +
|
| OnDemandUpdater& CrxUpdateService::GetOnDemandUpdater() {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| return *this;
|
|
|