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_util.h" | 7 #include "chrome/browser/extensions/extension_util.h" |
8 #include "chrome/browser/extensions/extension_view_host.h" | 8 #include "chrome/browser/extensions/extension_view_host.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 return NULL; | 73 return NULL; |
74 } | 74 } |
75 | 75 |
76 // Returns the extension associated with |url| in |profile|. Returns NULL if | 76 // Returns the extension associated with |url| in |profile|. Returns NULL if |
77 // the extension does not exist. | 77 // the extension does not exist. |
78 const Extension* GetExtensionForUrl(Profile* profile, const GURL& url) { | 78 const Extension* GetExtensionForUrl(Profile* profile, const GURL& url) { |
79 ExtensionRegistry* registry = ExtensionRegistry::Get(profile); | 79 ExtensionRegistry* registry = ExtensionRegistry::Get(profile); |
80 if (!registry) | 80 if (!registry) |
81 return NULL; | 81 return NULL; |
82 std::string extension_id = url.host(); | 82 std::string extension_id = url.host(); |
83 if (url.SchemeIs(content::kChromeUIScheme) && | |
84 url.host() == chrome::kChromeUIExtensionInfoHost) | |
85 extension_id = url.path().substr(1); | |
86 return registry->enabled_extensions().GetByID(extension_id); | 83 return registry->enabled_extensions().GetByID(extension_id); |
87 } | 84 } |
88 | 85 |
89 // Creates and initializes an ExtensionViewHost for the extension with |url|. | 86 // Creates and initializes an ExtensionViewHost for the extension with |url|. |
90 ExtensionViewHost* CreateViewHost(const GURL& url, | 87 ExtensionViewHost* CreateViewHost(const GURL& url, |
91 Profile* profile, | 88 Profile* profile, |
92 Browser* browser, | 89 Browser* browser, |
93 extensions::ViewType view_type) { | 90 extensions::ViewType view_type) { |
94 DCHECK(profile); | 91 DCHECK(profile); |
95 // A NULL browser may only be given for dialogs. | 92 // A NULL browser may only be given for dialogs. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 124 |
128 // static | 125 // static |
129 ExtensionViewHost* ExtensionViewHostFactory::CreateDialogHost( | 126 ExtensionViewHost* ExtensionViewHostFactory::CreateDialogHost( |
130 const GURL& url, | 127 const GURL& url, |
131 Profile* profile) { | 128 Profile* profile) { |
132 DCHECK(profile); | 129 DCHECK(profile); |
133 return CreateViewHost(url, profile, NULL, VIEW_TYPE_EXTENSION_DIALOG); | 130 return CreateViewHost(url, profile, NULL, VIEW_TYPE_EXTENSION_DIALOG); |
134 } | 131 } |
135 | 132 |
136 } // namespace extensions | 133 } // namespace extensions |
OLD | NEW |