OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h" | 5 #include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 const char kCroshExtensionEntryPoint[] = "/html/crosh.html"; | 13 const char kCroshExtensionEntryPoint[] = "/html/crosh.html"; |
14 | 14 |
15 const Extension* GetTerminalExtension(Profile* profile) { | 15 const Extension* GetTerminalExtension(Profile* profile) { |
16 // Search order for terminal extensions. | |
17 // We prefer hterm-dev, then hterm, then the builtin crosh extension. | |
16 static const char* kPossibleAppIds[] = { | 18 static const char* kPossibleAppIds[] = { |
19 extension_misc::kHTermDevAppId, | |
17 extension_misc::kHTermAppId, | 20 extension_misc::kHTermAppId, |
18 extension_misc::kHTermDevAppId | 21 extension_misc::kCroshBuiltinAppId, |
19 }; | 22 }; |
20 | 23 |
21 // The production app should be first in the list. | 24 // The hterm-dev should be first in the list. |
22 DCHECK_EQ(kPossibleAppIds[0], extension_misc::kHTermAppId); | 25 DCHECK_EQ(kPossibleAppIds[0], extension_misc::kHTermDevAppId); |
23 | 26 |
24 ExtensionService* service = profile->GetExtensionService(); | 27 ExtensionService* service = profile->GetExtensionService(); |
25 for (size_t x = 0; x < arraysize(kPossibleAppIds); ++x) { | 28 for (size_t x = 0; x < arraysize(kPossibleAppIds); ++x) { |
26 const Extension* extension = service->GetExtensionById( | 29 const Extension* extension = service->GetExtensionById( |
27 kPossibleAppIds[x], false); | 30 kPossibleAppIds[x], false); |
28 if (extension) | 31 if (extension && service->IsExtensionEnabled(kPossibleAppIds[x])) |
tonibarzic
2012/03/22 23:53:56
false in GetExtensionById(id, false) is for "inclu
rginda
2012/03/23 00:03:17
Done.
| |
29 return extension; | 32 return extension; |
30 } | 33 } |
31 | 34 |
32 return NULL; | 35 return NULL; |
33 } | 36 } |
34 | 37 |
35 } // namespace | 38 } // namespace |
36 | 39 |
37 GURL TerminalExtensionHelper::GetCroshExtensionURL(Profile* profile) { | 40 GURL TerminalExtensionHelper::GetCroshExtensionURL(Profile* profile) { |
38 const Extension* extension = GetTerminalExtension(profile); | 41 const Extension* extension = GetTerminalExtension(profile); |
39 if (!extension) | 42 if (!extension) |
40 return GURL(); | 43 return GURL(); |
41 | 44 |
42 return extension->GetResourceURL(kCroshExtensionEntryPoint); | 45 return extension->GetResourceURL(kCroshExtensionEntryPoint); |
43 } | 46 } |
OLD | NEW |