Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2184)

Unified Diff: chrome/browser/extensions/api/terminal/terminal_private_api.cc

Issue 9297008: [HTerm-Crosh] Add key shortcut for opening Crosh on ChromeOS Aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review.. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698