| Index: chrome/browser/extensions/api/terminal/terminal_private_api.cc
|
| diff --git a/chrome/browser/extensions/api/terminal/terminal_private_api.cc b/chrome/browser/extensions/api/terminal/terminal_private_api.cc
|
| index be7674716bc56f8413fe336b98ab25c055b1ba6b..9db5ff91281ea85ff359da3fd9294f77fd072c55 100644
|
| --- a/chrome/browser/extensions/api/terminal/terminal_private_api.cc
|
| +++ b/chrome/browser/extensions/api/terminal/terminal_private_api.cc
|
| @@ -9,6 +9,7 @@
|
| #include "base/values.h"
|
| #include "chrome/browser/chromeos/process_proxy/process_proxy_registry.h"
|
| #include "chrome/browser/chromeos/system/runtime_environment.h"
|
| +#include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h"
|
| #include "chrome/browser/extensions/extension_event_names.h"
|
| #include "chrome/browser/extensions/extension_event_router.h"
|
| #include "chrome/browser/extensions/extension_service.h"
|
| @@ -25,29 +26,6 @@ const char kStubbedCroshCommand[] = "cat";
|
| const char kPermissionError[] =
|
| "Extension does not have the permission to use this API";
|
|
|
| -const char* kAllowedExtensionIds[] ={
|
| - "okddffdblfhhnmhodogpojmfkjmhinfp", // test SSH/Crosh Client
|
| - "pnhechapfaindjhompbnflcldabbghjo" // HTerm App
|
| -};
|
| -
|
| -// Allow component and whitelisted extensions.
|
| -bool AllowAccessToExtension(Profile* profile, const std::string& extension_id) {
|
| - ExtensionService* service = profile->GetExtensionService();
|
| - const Extension* extension = service->GetExtensionById(extension_id, false);
|
| -
|
| - if (!extension)
|
| - return false;
|
| -
|
| - if (extension->location() == Extension::COMPONENT)
|
| - return true;
|
| -
|
| - for (size_t i = 0; i < arraysize(kAllowedExtensionIds); i++) {
|
| - if (extension->id() == kAllowedExtensionIds[i])
|
| - return true;
|
| - }
|
| - return false;
|
| -}
|
| -
|
| const char* GetCroshPath() {
|
| if (chromeos::system::runtime_environment::IsRunningOnChromeOS())
|
| return kCroshCommand;
|
| @@ -75,7 +53,7 @@ void NotifyProcessOutput(Profile* profile,
|
| return;
|
| }
|
|
|
| - CHECK(AllowAccessToExtension(profile, extension_id));
|
| + CHECK(TerminalExtensionHelper::AllowAccessToExtension(profile, extension_id));
|
|
|
| base::ListValue args;
|
| args.Append(new base::FundamentalValue(pid));
|
| @@ -101,7 +79,8 @@ TerminalPrivateFunction::~TerminalPrivateFunction() {
|
| }
|
|
|
| bool TerminalPrivateFunction::RunImpl() {
|
| - if (!AllowAccessToExtension(profile_, extension_id())) {
|
| + if (!TerminalExtensionHelper::AllowAccessToExtension(profile_,
|
| + extension_id())) {
|
| error_ = kPermissionError;
|
| return false;
|
| }
|
|
|