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

Side by Side Diff: chrome/browser/extensions/api/terminal/terminal_extension_helper.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: rebase Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h"
6
7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/profiles/profile.h"
9
10 namespace {
11
12 const char* kAllowedExtensionIds[] = {
13 // Keep official app first, so GetTerminalExtensionID checks it first.
14 "pnhechapfaindjhompbnflcldabbghjo", // HTerm App
15 "okddffdblfhhnmhodogpojmfkjmhinfp", // test SSH/Crosh Client
16 };
17
18 const char kExtensionSchema[] = "chrome-extension://";
19 const char kCroshExtensionEntryPoint[] = "/html/crosh.html";
20
21 } // namespace
22
23 // Allow component and whitelisted extensions.
24 bool TerminalExtensionHelper::AllowAccessToExtension(
25 Profile* profile,
26 const std::string& extension_id) {
27 ExtensionService* service = profile->GetExtensionService();
28 const Extension* extension = service->GetExtensionById(extension_id, false);
29
30 if (!extension)
31 return false;
32
33 if (extension->location() == Extension::COMPONENT)
34 return true;
35
36 for (size_t i = 0; i < arraysize(kAllowedExtensionIds); i++) {
37 if (extension->id() == kAllowedExtensionIds[i])
38 return true;
39 }
40 return false;
41 }
42
43 GURL TerminalExtensionHelper::GetCroshExtensionURL(Profile* profile) {
44 const char* extension_id = GetTerminalExtensionId(profile);
45 if (!extension_id)
46 return GURL();
47
48 std::string crosh_url_str(kExtensionSchema);
49 crosh_url_str.append(extension_id);
50 crosh_url_str.append(kCroshExtensionEntryPoint);
51 return GURL(crosh_url_str);
52 }
53
54 const char* TerminalExtensionHelper::GetTerminalExtensionId(Profile* profile) {
55 ExtensionService* service = profile->GetExtensionService();
56 for (size_t i = 0; i < arraysize(kAllowedExtensionIds); i++) {
57 if (service->GetExtensionById(kAllowedExtensionIds[i], false) != 0)
58 return kAllowedExtensionIds[i];
59 }
60 return NULL;
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698