| Index: chrome/browser/plugins/plugin_observer.cc
|
| diff --git a/chrome/browser/plugins/plugin_observer.cc b/chrome/browser/plugins/plugin_observer.cc
|
| index 605ca81f7bbd0f8738585177f75208f1d3db9541..340e2359adc39dc87fc24a67b9e0840343caa9ad 100644
|
| --- a/chrome/browser/plugins/plugin_observer.cc
|
| +++ b/chrome/browser/plugins/plugin_observer.cc
|
| @@ -9,6 +9,7 @@
|
| #include "base/auto_reset.h"
|
| #include "base/bind.h"
|
| #include "base/debug/crash_logging.h"
|
| +#include "base/memory/ptr_util.h"
|
| #include "base/metrics/histogram.h"
|
| #include "base/stl_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| @@ -23,6 +24,7 @@
|
| #include "chrome/common/render_messages.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "chrome/grit/generated_resources.h"
|
| +#include "components/component_updater/component_updater_service.h"
|
| #include "components/content_settings/content/common/content_settings_messages.h"
|
| #include "components/content_settings/core/browser/host_content_settings_map.h"
|
| #include "components/infobars/core/confirm_infobar_delegate.h"
|
| @@ -164,7 +166,7 @@ ReloadPluginInfoBarDelegate::ReloadPluginInfoBarDelegate(
|
| : controller_(controller),
|
| message_(message) {}
|
|
|
| -ReloadPluginInfoBarDelegate::~ReloadPluginInfoBarDelegate(){ }
|
| +ReloadPluginInfoBarDelegate::~ReloadPluginInfoBarDelegate() {}
|
|
|
| infobars::InfoBarDelegate::InfoBarIdentifier
|
| ReloadPluginInfoBarDelegate::GetIdentifier() const {
|
| @@ -255,6 +257,54 @@ class PluginObserver::PluginPlaceholderHost : public PluginInstallerObserver {
|
| };
|
| #endif // defined(ENABLE_PLUGIN_INSTALLATION)
|
|
|
| +class PluginObserver::ComponentObserver
|
| + : public update_client::UpdateClient::Observer {
|
| + public:
|
| + using Events = update_client::UpdateClient::Observer::Events;
|
| + ComponentObserver(PluginObserver* observer,
|
| + int routing_id,
|
| + const std::string& component_id)
|
| + : observer_(observer),
|
| + routing_id_(routing_id),
|
| + component_id_(component_id) {
|
| + g_browser_process->component_updater()->AddObserver(this);
|
| + }
|
| +
|
| + ~ComponentObserver() override {
|
| + g_browser_process->component_updater()->RemoveObserver(this);
|
| + }
|
| +
|
| + void OnEvent(Events event, const std::string& id) override {
|
| + if (id != component_id_)
|
| + return;
|
| + switch (event) {
|
| + case Events::COMPONENT_UPDATED:
|
| + observer_->Send(
|
| + new ChromeViewMsg_PluginComponentUpdateSuccess(routing_id_));
|
| + observer_->RemoveComponentObserver(routing_id_);
|
| + break;
|
| + case Events::COMPONENT_UPDATE_FOUND:
|
| + observer_->Send(
|
| + new ChromeViewMsg_PluginComponentUpdateDownloading(routing_id_));
|
| + break;
|
| + case Events::COMPONENT_NOT_UPDATED:
|
| + observer_->Send(
|
| + new ChromeViewMsg_PluginComponentUpdateFailure(routing_id_));
|
| + observer_->RemoveComponentObserver(routing_id_);
|
| + break;
|
| + default:
|
| + // No message to send.
|
| + break;
|
| + }
|
| + }
|
| +
|
| + private:
|
| + PluginObserver* observer_;
|
| + int routing_id_;
|
| + std::string component_id_;
|
| + DISALLOW_COPY_AND_ASSIGN(ComponentObserver);
|
| +};
|
| +
|
| PluginObserver::PluginObserver(content::WebContents* web_contents)
|
| : content::WebContentsObserver(web_contents),
|
| weak_ptr_factory_(this) {
|
| @@ -321,6 +371,8 @@ bool PluginObserver::OnMessageReceived(
|
| IPC_BEGIN_MESSAGE_MAP(PluginObserver, message)
|
| IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedOutdatedPlugin,
|
| OnBlockedOutdatedPlugin)
|
| + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedComponentUpdatedPlugin,
|
| + OnBlockedComponentUpdatedPlugin)
|
| #if defined(ENABLE_PLUGIN_INSTALLATION)
|
| IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RemovePluginPlaceholderHost,
|
| OnRemovePluginPlaceholderHost)
|
| @@ -359,6 +411,21 @@ void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id,
|
| #endif // defined(ENABLE_PLUGIN_INSTALLATION)
|
| }
|
|
|
| +void PluginObserver::OnBlockedComponentUpdatedPlugin(
|
| + int placeholder_id,
|
| + const std::string& identifier) {
|
| + component_observers_[placeholder_id] =
|
| + base::MakeUnique<ComponentObserver>(this, placeholder_id, identifier);
|
| + g_browser_process->component_updater()->GetOnDemandUpdater().OnDemandUpdate(
|
| + identifier);
|
| +}
|
| +
|
| +void PluginObserver::RemoveComponentObserver(int placeholder_id) {
|
| + auto it = component_observers_.find(placeholder_id);
|
| + DCHECK(it != component_observers_.end());
|
| + component_observers_.erase(it);
|
| +}
|
| +
|
| #if defined(ENABLE_PLUGIN_INSTALLATION)
|
| void PluginObserver::OnRemovePluginPlaceholderHost(int placeholder_id) {
|
| std::map<int, PluginPlaceholderHost*>::iterator it =
|
|
|