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.
5 #include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/common/extensions/extension_constants.h"
9 #include "extensions/browser/extension_registry.h"
10 #include "extensions/common/extension.h"
12 namespace extensions
{
16 const char kCroshExtensionEntryPoint
[] = "/html/crosh.html";
18 const Extension
* GetTerminalExtension(Profile
* profile
) {
19 // Search order for terminal extensions.
20 // We prefer hterm-dev, then hterm, then the builtin crosh extension.
21 static const char* const kPossibleAppIds
[] = {
22 extension_misc::kHTermDevAppId
,
23 extension_misc::kHTermAppId
,
24 extension_misc::kCroshBuiltinAppId
,
27 // The hterm-dev should be first in the list.
28 DCHECK_EQ(kPossibleAppIds
[0], extension_misc::kHTermDevAppId
);
30 const ExtensionSet
& extensions
=
31 ExtensionRegistry::Get(profile
)->enabled_extensions();
32 for (size_t i
= 0; i
< arraysize(kPossibleAppIds
); ++i
) {
33 const extensions::Extension
* extension
=
34 extensions
.GetByID(kPossibleAppIds
[i
]);
44 GURL
TerminalExtensionHelper::GetCroshExtensionURL(Profile
* profile
) {
46 const extensions::Extension
* extension
= GetTerminalExtension(profile
);
48 url
= extension
->GetResourceURL(kCroshExtensionEntryPoint
);
52 } // namespace extensions