OLD | NEW |
| (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/ui/views/ash/launcher/launcher_app_tab_helper.h" | |
6 | |
7 #include "chrome/browser/extensions/extension_service.h" | |
8 #include "chrome/browser/profiles/profile.h" | |
9 #include "chrome/browser/ui/tab_contents/tab_contents.h" | |
10 #include "chrome/common/extensions/extension.h" | |
11 #include "content/public/browser/web_contents.h" | |
12 | |
13 namespace { | |
14 | |
15 const extensions::Extension* GetExtensionForTab(Profile* profile, | |
16 TabContents* tab) { | |
17 ExtensionService* extension_service = profile->GetExtensionService(); | |
18 if (!extension_service) | |
19 return NULL; | |
20 return extension_service->GetInstalledApp(tab->web_contents()->GetURL()); | |
21 } | |
22 | |
23 const extensions::Extension* GetExtensionByID(Profile* profile, | |
24 const std::string& id) { | |
25 ExtensionService* service = profile->GetExtensionService(); | |
26 if (!service) | |
27 return NULL; | |
28 return service->extensions()->GetByID(id); | |
29 } | |
30 | |
31 } // namespace | |
32 | |
33 LauncherAppTabHelper::LauncherAppTabHelper(Profile* profile) | |
34 : profile_(profile) { | |
35 } | |
36 | |
37 LauncherAppTabHelper::~LauncherAppTabHelper() { | |
38 } | |
39 | |
40 std::string LauncherAppTabHelper::GetAppID(TabContents* tab) { | |
41 const extensions::Extension* extension = GetExtensionForTab(profile_, tab); | |
42 return extension ? extension->id() : std::string(); | |
43 } | |
44 | |
45 bool LauncherAppTabHelper::IsValidID(const std::string& id) { | |
46 return GetExtensionByID(profile_, id) != NULL; | |
47 } | |
OLD | NEW |