|
11 | 11 | #include "content/public/browser/browser_task_traits.h"
|
12 | 12 | #include "components/browsing_data/content/appcache_helper.h"
|
13 | 13 | #include "components/browsing_data/content/browsing_data_helper.h"
|
| 14 | +#include "components/component_updater/component_updater_service.h" |
| 15 | +#include "chrome/browser/browser_process.h" |
| 16 | +#include "chrome/browser/component_updater/widevine_cdm_component_installer.h" |
14 | 17 | #include "chrome/browser/devtools/devtools_window.h"
|
15 | 18 | #include "chrome/browser/extensions/devtools_util.h"
|
16 | 19 | #include "chrome/browser/extensions/extension_service.h"
|
@@ -99,6 +102,49 @@ NwAppCloseAllWindowsFunction::Run() {
|
99 | 102 | return RespondNow(NoArguments());
|
100 | 103 | }
|
101 | 104 |
|
| 105 | +ExtensionFunction::ResponseAction |
| 106 | +NwAppEnableComponentFunction::Run() { |
| 107 | + component_updater::RegisterWidevineCdmComponent(g_browser_process->component_updater(), |
| 108 | + base::BindOnce(&NwAppEnableComponentFunction::OnRegistered, |
| 109 | + this)); |
| 110 | + return RespondLater(); |
| 111 | +} |
| 112 | + |
| 113 | +void NwAppEnableComponentFunction::OnRegistered() { |
| 114 | + std::string ret; |
| 115 | + const std::vector<component_updater::ComponentInfo> component_list = |
| 116 | + g_browser_process->component_updater()->GetComponents(); |
| 117 | + |
| 118 | + for (const auto& component : component_list) { |
| 119 | + if (component.id == "oimompecagnajdejgnnjijobebaeigek") { |
| 120 | + ret = component.version.GetString(); |
| 121 | + } |
| 122 | + } |
| 123 | + auto result_value = std::make_unique<base::Value>(ret); |
| 124 | + |
| 125 | + Respond(OneArgument(std::move(result_value))); |
| 126 | +} |
| 127 | + |
| 128 | +ExtensionFunction::ResponseAction |
| 129 | + NwAppUpdateComponentFunction::Run() { |
| 130 | + g_browser_process->component_updater()->GetOnDemandUpdater().OnDemandUpdate( |
| 131 | + "oimompecagnajdejgnnjijobebaeigek", component_updater::OnDemandUpdater::Priority::FOREGROUND, |
| 132 | + base::BindOnce(&NwAppUpdateComponentFunction::OnUpdated, this)); |
| 133 | + |
| 134 | + return RespondLater(); |
| 135 | +} |
| 136 | + |
| 137 | +void NwAppUpdateComponentFunction::OnUpdated(update_client::Error error) { |
| 138 | + bool ret = (error == update_client::Error::NONE); |
| 139 | + auto result_value = std::make_unique<base::Value>(ret); |
| 140 | + if (ret) { |
| 141 | + Respond(OneArgument(std::move(result_value))); |
| 142 | + } else { |
| 143 | + VLOG(1) << "update component error: " << (int)error; |
| 144 | + Respond(OneArgument(std::move(result_value))); |
| 145 | + } |
| 146 | +} |
| 147 | + |
102 | 148 | NwAppGetArgvSyncFunction::NwAppGetArgvSyncFunction() {
|
103 | 149 | }
|
104 | 150 |
|
|
0 commit comments