| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_dom_ui.h" | 5 #include "chrome/browser/extensions/extension_dom_ui.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "net/base/file_stream.h" | 9 #include "net/base/file_stream.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 Extension* extension_; | 113 Extension* extension_; |
| 114 | 114 |
| 115 DISALLOW_COPY_AND_ASSIGN(ExtensionDOMUIImageLoadingTracker); | 115 DISALLOW_COPY_AND_ASSIGN(ExtensionDOMUIImageLoadingTracker); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 } // namespace | 118 } // namespace |
| 119 | 119 |
| 120 const char ExtensionDOMUI::kExtensionURLOverrides[] = | 120 const char ExtensionDOMUI::kExtensionURLOverrides[] = |
| 121 "extensions.chrome_url_overrides"; | 121 "extensions.chrome_url_overrides"; |
| 122 | 122 |
| 123 ExtensionDOMUI::ExtensionDOMUI(TabContents* tab_contents) | 123 ExtensionDOMUI::ExtensionDOMUI(TabContents* tab_contents, GURL url) |
| 124 : DOMUI(tab_contents) { | 124 : DOMUI(tab_contents) { |
| 125 should_hide_url_ = true; | 125 ExtensionsService* service = tab_contents->profile()->GetExtensionsService(); |
| 126 Extension* extension = service->GetExtensionByURL(url); |
| 127 if (!extension) |
| 128 extension = service->GetExtensionByWebExtent(url); |
| 129 DCHECK(extension); |
| 130 // Only hide the url for internal pages (e.g. chrome-extension or packaged |
| 131 // component apps like bookmark manager. |
| 132 should_hide_url_ = !extension->is_app(); |
| 133 |
| 126 bindings_ = BindingsPolicy::EXTENSION; | 134 bindings_ = BindingsPolicy::EXTENSION; |
| 127 // Bind externalHost to Extension DOMUI loaded in Chrome Frame. | 135 // Bind externalHost to Extension DOMUI loaded in Chrome Frame. |
| 128 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 136 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 129 if (browser_command_line.HasSwitch(switches::kChromeFrame)) | 137 if (browser_command_line.HasSwitch(switches::kChromeFrame)) |
| 130 bindings_ |= BindingsPolicy::EXTERNAL_HOST; | 138 bindings_ |= BindingsPolicy::EXTERNAL_HOST; |
| 131 // For chrome:// overrides, some of the defaults are a little different. | 139 // For chrome:// overrides, some of the defaults are a little different. |
| 132 GURL url = tab_contents->GetURL(); | 140 GURL effective_url = tab_contents->GetURL(); |
| 133 if (url.SchemeIs(chrome::kChromeUIScheme) && | 141 if (effective_url.SchemeIs(chrome::kChromeUIScheme) && |
| 134 url.host() == chrome::kChromeUINewTabHost) { | 142 effective_url.host() == chrome::kChromeUINewTabHost) { |
| 135 focus_location_bar_by_default_ = true; | 143 focus_location_bar_by_default_ = true; |
| 136 } | 144 } |
| 137 } | 145 } |
| 138 | 146 |
| 139 void ExtensionDOMUI::ResetExtensionFunctionDispatcher( | 147 void ExtensionDOMUI::ResetExtensionFunctionDispatcher( |
| 140 RenderViewHost* render_view_host) { | 148 RenderViewHost* render_view_host) { |
| 141 // Use the NavigationController to get the URL rather than the TabContents | 149 // Use the NavigationController to get the URL rather than the TabContents |
| 142 // since this is the real underlying URL (see HandleChromeURLOverride). | 150 // since this is the real underlying URL (see HandleChromeURLOverride). |
| 143 NavigationController& controller = tab_contents()->controller(); | 151 NavigationController& controller = tab_contents()->controller(); |
| 144 const GURL& url = controller.GetActiveEntry()->url(); | 152 const GURL& url = controller.GetActiveEntry()->url(); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 } | 387 } |
| 380 | 388 |
| 381 // static | 389 // static |
| 382 void ExtensionDOMUI::GetFaviconForURL(Profile* profile, | 390 void ExtensionDOMUI::GetFaviconForURL(Profile* profile, |
| 383 FaviconService::GetFaviconRequest* request, const GURL& page_url) { | 391 FaviconService::GetFaviconRequest* request, const GURL& page_url) { |
| 384 // tracker deletes itself when done. | 392 // tracker deletes itself when done. |
| 385 ExtensionDOMUIImageLoadingTracker* tracker = | 393 ExtensionDOMUIImageLoadingTracker* tracker = |
| 386 new ExtensionDOMUIImageLoadingTracker(profile, request, page_url); | 394 new ExtensionDOMUIImageLoadingTracker(profile, request, page_url); |
| 387 tracker->Init(); | 395 tracker->Init(); |
| 388 } | 396 } |
| OLD | NEW |