OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extension_view_host_factory.h" | 5 #include "chrome/browser/extensions/extension_view_host_factory.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_service.h" | |
8 #include "chrome/browser/extensions/extension_util.h" | 7 #include "chrome/browser/extensions/extension_util.h" |
9 #include "chrome/browser/extensions/extension_view_host.h" | 8 #include "chrome/browser/extensions/extension_view_host.h" |
10 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
13 #include "extensions/browser/extension_system.h" | 12 #include "extensions/browser/extension_registry.h" |
14 #include "extensions/browser/process_manager.h" | 13 #include "extensions/browser/process_manager.h" |
15 #include "extensions/common/manifest_handlers/incognito_info.h" | 14 #include "extensions/common/manifest_handlers/incognito_info.h" |
16 #include "extensions/common/view_type.h" | 15 #include "extensions/common/view_type.h" |
17 | 16 |
18 #if defined(OS_MACOSX) | 17 #if defined(OS_MACOSX) |
19 #include "chrome/browser/extensions/extension_view_host_mac.h" | 18 #include "chrome/browser/extensions/extension_view_host_mac.h" |
20 #endif | 19 #endif |
21 | 20 |
22 namespace extensions { | 21 namespace extensions { |
23 | 22 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 69 } |
71 NOTREACHED() << | 70 NOTREACHED() << |
72 "We shouldn't be trying to create an incognito extension view unless " | 71 "We shouldn't be trying to create an incognito extension view unless " |
73 "it has been enabled for incognito."; | 72 "it has been enabled for incognito."; |
74 return NULL; | 73 return NULL; |
75 } | 74 } |
76 | 75 |
77 // Returns the extension associated with |url| in |profile|. Returns NULL if | 76 // Returns the extension associated with |url| in |profile|. Returns NULL if |
78 // the extension does not exist. | 77 // the extension does not exist. |
79 const Extension* GetExtensionForUrl(Profile* profile, const GURL& url) { | 78 const Extension* GetExtensionForUrl(Profile* profile, const GURL& url) { |
80 ExtensionService* service = | 79 ExtensionRegistry* registry = ExtensionRegistry::Get(profile); |
81 ExtensionSystem::Get(profile)->extension_service(); | 80 if (!registry) |
82 if (!service) | |
83 return NULL; | 81 return NULL; |
84 std::string extension_id = url.host(); | 82 std::string extension_id = url.host(); |
85 if (url.SchemeIs(content::kChromeUIScheme) && | 83 if (url.SchemeIs(content::kChromeUIScheme) && |
86 url.host() == chrome::kChromeUIExtensionInfoHost) | 84 url.host() == chrome::kChromeUIExtensionInfoHost) |
87 extension_id = url.path().substr(1); | 85 extension_id = url.path().substr(1); |
88 return service->extensions()->GetByID(extension_id); | 86 return registry->enabled_extensions().GetByID(extension_id); |
89 } | 87 } |
90 | 88 |
91 // Creates and initializes an ExtensionViewHost for the extension with |url|. | 89 // Creates and initializes an ExtensionViewHost for the extension with |url|. |
92 ExtensionViewHost* CreateViewHost(const GURL& url, | 90 ExtensionViewHost* CreateViewHost(const GURL& url, |
93 Profile* profile, | 91 Profile* profile, |
94 Browser* browser, | 92 Browser* browser, |
95 extensions::ViewType view_type) { | 93 extensions::ViewType view_type) { |
96 DCHECK(profile); | 94 DCHECK(profile); |
97 // A NULL browser may only be given for dialogs. | 95 // A NULL browser may only be given for dialogs. |
98 DCHECK(browser || view_type == VIEW_TYPE_EXTENSION_DIALOG); | 96 DCHECK(browser || view_type == VIEW_TYPE_EXTENSION_DIALOG); |
(...skipping 30 matching lines...) Expand all Loading... |
129 | 127 |
130 // static | 128 // static |
131 ExtensionViewHost* ExtensionViewHostFactory::CreateDialogHost( | 129 ExtensionViewHost* ExtensionViewHostFactory::CreateDialogHost( |
132 const GURL& url, | 130 const GURL& url, |
133 Profile* profile) { | 131 Profile* profile) { |
134 DCHECK(profile); | 132 DCHECK(profile); |
135 return CreateViewHost(url, profile, NULL, VIEW_TYPE_EXTENSION_DIALOG); | 133 return CreateViewHost(url, profile, NULL, VIEW_TYPE_EXTENSION_DIALOG); |
136 } | 134 } |
137 | 135 |
138 } // namespace extensions | 136 } // namespace extensions |
OLD | NEW |