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

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

Issue 9317013: Add a centralized mechanism for whitelisting access to extension permissions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: merge TerminalPrivate api changes 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_extension_helper.cc
diff --git a/chrome/browser/extensions/api/terminal/terminal_extension_helper.cc b/chrome/browser/extensions/api/terminal/terminal_extension_helper.cc
index 0c47819ce1d802fbea9c63ea5956117ca8906ada..0591c5d2178ed5ffde1ea7de1ba6c06bdaa81bbd 100644
--- a/chrome/browser/extensions/api/terminal/terminal_extension_helper.cc
+++ b/chrome/browser/extensions/api/terminal/terminal_extension_helper.cc
@@ -6,56 +6,20 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/extension.h"
namespace {
-const char* kAllowedExtensionIds[] = {
- // Keep official app first, so GetTerminalExtensionID checks it first.
- "pnhechapfaindjhompbnflcldabbghjo", // HTerm App
- "okddffdblfhhnmhodogpojmfkjmhinfp", // test SSH/Crosh Client
-};
-
-const char kExtensionSchema[] = "chrome-extension://";
const char kCroshExtensionEntryPoint[] = "/html/crosh.html";
} // namespace
-// Allow component and whitelisted extensions.
-bool TerminalExtensionHelper::AllowAccessToExtension(
- Profile* profile,
- const std::string& extension_id) {
+GURL TerminalExtensionHelper::GetCroshExtensionURL(Profile* profile) {
ExtensionService* service = profile->GetExtensionService();
- const Extension* extension = service->GetExtensionById(extension_id, false);
-
+ const Extension* extension =
+ service->GetExtensionById(extension_misc::kHTermAppId, false);
jstritar 2012/02/01 16:09:51 Do you ever really need to fall back to the test e
tbarzic 2012/02/01 18:32:44 Yeah,we'll need to fallback occasionally; test ext
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;
-}
-
-GURL TerminalExtensionHelper::GetCroshExtensionURL(Profile* profile) {
jstritar 2012/02/01 16:09:51 What does Crosh stand for? Chrome shell? Just wond
tbarzic 2012/02/01 18:32:44 It's chrome os shell
- const char* extension_id = GetTerminalExtensionId(profile);
- if (!extension_id)
return GURL();
- std::string crosh_url_str(kExtensionSchema);
- crosh_url_str.append(extension_id);
- crosh_url_str.append(kCroshExtensionEntryPoint);
- return GURL(crosh_url_str);
-}
-
-const char* TerminalExtensionHelper::GetTerminalExtensionId(Profile* profile) {
- ExtensionService* service = profile->GetExtensionService();
- for (size_t i = 0; i < arraysize(kAllowedExtensionIds); i++) {
- if (service->GetExtensionById(kAllowedExtensionIds[i], false) != 0)
- return kAllowedExtensionIds[i];
- }
- return NULL;
+ return extension->GetResourceURL(kCroshExtensionEntryPoint);
}

Powered by Google App Engine
This is Rietveld 408576698