| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_web_ui.h" | 5 #include "chrome/browser/extensions/extension_web_ui.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 ExtensionWebUIImageLoadingTracker(Profile* profile, | 60 ExtensionWebUIImageLoadingTracker(Profile* profile, |
| 61 FaviconService::GetFaviconRequest* request, | 61 FaviconService::GetFaviconRequest* request, |
| 62 const GURL& page_url) | 62 const GURL& page_url) |
| 63 : ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)), | 63 : ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)), |
| 64 request_(request), | 64 request_(request), |
| 65 extension_(NULL) { | 65 extension_(NULL) { |
| 66 // Even when the extensions service is enabled by default, it's still | 66 // Even when the extensions service is enabled by default, it's still |
| 67 // disabled in incognito mode. | 67 // disabled in incognito mode. |
| 68 ExtensionService* service = profile->GetExtensionService(); | 68 ExtensionService* service = profile->GetExtensionService(); |
| 69 if (service) | 69 if (service) |
| 70 extension_ = service->GetExtensionByURL(page_url); | 70 extension_ = service->extensions()->GetByURL(ExtensionURLInfo(page_url)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void Init() { | 73 void Init() { |
| 74 if (extension_) { | 74 if (extension_) { |
| 75 ExtensionResource icon_resource = | 75 ExtensionResource icon_resource = |
| 76 extension_->GetIconResource(Extension::EXTENSION_ICON_BITTY, | 76 extension_->GetIconResource(Extension::EXTENSION_ICON_BITTY, |
| 77 ExtensionIconSet::MATCH_EXACTLY); | 77 ExtensionIconSet::MATCH_EXACTLY); |
| 78 | 78 |
| 79 tracker_.LoadImage(extension_, icon_resource, | 79 tracker_.LoadImage(extension_, icon_resource, |
| 80 gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize), | 80 gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize), |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 const char ExtensionWebUI::kExtensionURLOverrides[] = | 124 const char ExtensionWebUI::kExtensionURLOverrides[] = |
| 125 "extensions.chrome_url_overrides"; | 125 "extensions.chrome_url_overrides"; |
| 126 | 126 |
| 127 ExtensionWebUI::ExtensionWebUI(TabContents* tab_contents, const GURL& url) | 127 ExtensionWebUI::ExtensionWebUI(TabContents* tab_contents, const GURL& url) |
| 128 : ChromeWebUI(tab_contents), | 128 : ChromeWebUI(tab_contents), |
| 129 url_(url) { | 129 url_(url) { |
| 130 Profile* profile = | 130 Profile* profile = |
| 131 Profile::FromBrowserContext(tab_contents->browser_context()); | 131 Profile::FromBrowserContext(tab_contents->browser_context()); |
| 132 ExtensionService* service = profile->GetExtensionService(); | 132 ExtensionService* service = profile->GetExtensionService(); |
| 133 const Extension* extension = service->GetExtensionByURL(url); | 133 const Extension* extension = |
| 134 if (!extension) | 134 service->extensions()->GetByURL(ExtensionURLInfo(url)); |
| 135 extension = service->GetExtensionByWebExtent(url); | |
| 136 DCHECK(extension); | 135 DCHECK(extension); |
| 137 // Only hide the url for internal pages (e.g. chrome-extension or packaged | 136 // Only hide the url for internal pages (e.g. chrome-extension or packaged |
| 138 // component apps like bookmark manager. | 137 // component apps like bookmark manager. |
| 139 should_hide_url_ = !extension->is_hosted_app(); | 138 should_hide_url_ = !extension->is_hosted_app(); |
| 140 | 139 |
| 141 // The base class defaults to enabling web ui bindings, but we don't need | 140 // The base class defaults to enabling web ui bindings, but we don't need |
| 142 // those. | 141 // those. |
| 143 bindings_ = 0; | 142 bindings_ = 0; |
| 144 | 143 |
| 145 // Bind externalHost to Extension WebUI loaded in Chrome Frame. | 144 // Bind externalHost to Extension WebUI loaded in Chrome Frame. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 if (!url->ref().empty()) | 216 if (!url->ref().empty()) |
| 218 override += "#" + url->ref(); | 217 override += "#" + url->ref(); |
| 219 GURL extension_url(override); | 218 GURL extension_url(override); |
| 220 if (!extension_url.is_valid()) { | 219 if (!extension_url.is_valid()) { |
| 221 NOTREACHED(); | 220 NOTREACHED(); |
| 222 UnregisterChromeURLOverride(page, profile, val); | 221 UnregisterChromeURLOverride(page, profile, val); |
| 223 continue; | 222 continue; |
| 224 } | 223 } |
| 225 | 224 |
| 226 // Verify that the extension that's being referred to actually exists. | 225 // Verify that the extension that's being referred to actually exists. |
| 227 const Extension* extension = service->GetExtensionByURL(extension_url); | 226 const Extension* extension = |
| 227 service->extensions()->GetByURL(ExtensionURLInfo(extension_url)); |
| 228 if (!extension) { | 228 if (!extension) { |
| 229 // This can currently happen if you use --load-extension one run, and | 229 // This can currently happen if you use --load-extension one run, and |
| 230 // then don't use it the next. It could also happen if an extension | 230 // then don't use it the next. It could also happen if an extension |
| 231 // were deleted directly from the filesystem, etc. | 231 // were deleted directly from the filesystem, etc. |
| 232 LOG(WARNING) << "chrome URL override present for non-existant extension"; | 232 LOG(WARNING) << "chrome URL override present for non-existant extension"; |
| 233 UnregisterChromeURLOverride(page, profile, val); | 233 UnregisterChromeURLOverride(page, profile, val); |
| 234 continue; | 234 continue; |
| 235 } | 235 } |
| 236 | 236 |
| 237 // We can't handle chrome-extension URLs in incognito mode unless the | 237 // We can't handle chrome-extension URLs in incognito mode unless the |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 } | 401 } |
| 402 | 402 |
| 403 // static | 403 // static |
| 404 void ExtensionWebUI::GetFaviconForURL(Profile* profile, | 404 void ExtensionWebUI::GetFaviconForURL(Profile* profile, |
| 405 FaviconService::GetFaviconRequest* request, const GURL& page_url) { | 405 FaviconService::GetFaviconRequest* request, const GURL& page_url) { |
| 406 // tracker deletes itself when done. | 406 // tracker deletes itself when done. |
| 407 ExtensionWebUIImageLoadingTracker* tracker = | 407 ExtensionWebUIImageLoadingTracker* tracker = |
| 408 new ExtensionWebUIImageLoadingTracker(profile, request, page_url); | 408 new ExtensionWebUIImageLoadingTracker(profile, request, page_url); |
| 409 tracker->Init(); | 409 tracker->Init(); |
| 410 } | 410 } |
| OLD | NEW |