OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 "extensions.chrome_url_overrides"; | 124 "extensions.chrome_url_overrides"; |
125 | 125 |
126 ExtensionWebUI::ExtensionWebUI(content::WebUI* web_ui, const GURL& url) | 126 ExtensionWebUI::ExtensionWebUI(content::WebUI* web_ui, const GURL& url) |
127 : WebUIController(web_ui), | 127 : WebUIController(web_ui), |
128 url_(url) { | 128 url_(url) { |
129 Profile* profile = Profile::FromWebUI(web_ui); | 129 Profile* profile = Profile::FromWebUI(web_ui); |
130 ExtensionService* service = profile->GetExtensionService(); | 130 ExtensionService* service = profile->GetExtensionService(); |
131 const Extension* extension = | 131 const Extension* extension = |
132 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url)); | 132 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url)); |
133 DCHECK(extension); | 133 DCHECK(extension); |
134 // Only hide the url for internal pages (e.g. chrome-extension or packaged | |
135 // component apps like bookmark manager. | |
136 bool should_hide_url = !extension->is_hosted_app(); | |
137 | 134 |
138 // The base class defaults to enabling WebUI bindings, but we don't need | 135 // The base class defaults to enabling WebUI bindings, but we don't need |
139 // those (this is also reflected in ChromeWebUIControllerFactory:: | 136 // those (this is also reflected in ChromeWebUIControllerFactory:: |
140 // UseWebUIBindingsForURL). | 137 // UseWebUIBindingsForURL). |
141 int bindings = 0; | 138 int bindings = 0; |
142 | 139 |
143 // Bind externalHost to Extension WebUI loaded in Chrome Frame. | 140 // Bind externalHost to Extension WebUI loaded in Chrome Frame. |
144 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 141 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
145 if (browser_command_line.HasSwitch(switches::kChromeFrame)) | 142 if (browser_command_line.HasSwitch(switches::kChromeFrame)) |
146 bindings |= content::BINDINGS_POLICY_EXTERNAL_HOST; | 143 bindings |= content::BINDINGS_POLICY_EXTERNAL_HOST; |
147 // For chrome:// overrides, some of the defaults are a little different. | 144 // For chrome:// overrides, some of the defaults are a little different. |
148 GURL effective_url = web_ui->GetWebContents()->GetURL(); | 145 GURL effective_url = web_ui->GetWebContents()->GetURL(); |
149 if (effective_url.SchemeIs(chrome::kChromeUIScheme)) { | 146 if (effective_url.SchemeIs(chrome::kChromeUIScheme)) { |
150 if (effective_url.host() == chrome::kChromeUINewTabHost) { | 147 if (effective_url.host() == chrome::kChromeUINewTabHost) { |
151 web_ui->FocusLocationBarByDefault(); | 148 web_ui->FocusLocationBarByDefault(); |
152 } else { | |
153 // Current behavior of other chrome:// pages is to display the URL. | |
154 should_hide_url = false; | |
155 } | 149 } |
156 } | 150 } |
157 | 151 |
158 if (should_hide_url) | |
159 web_ui->HideURL(); | |
160 | |
161 web_ui->SetBindings(bindings); | 152 web_ui->SetBindings(bindings); |
162 | 153 |
163 // Hack: A few things we specialize just for the bookmark manager. | 154 // Hack: A few things we specialize just for the bookmark manager. |
164 if (extension->id() == extension_misc::kBookmarkManagerId) { | 155 if (extension->id() == extension_misc::kBookmarkManagerId) { |
165 bookmark_manager_private_event_router_.reset( | 156 bookmark_manager_private_event_router_.reset( |
166 new extensions::BookmarkManagerPrivateEventRouter( | 157 new extensions::BookmarkManagerPrivateEventRouter( |
167 profile, web_ui->GetWebContents())); | 158 profile, web_ui->GetWebContents())); |
168 | 159 |
169 web_ui->SetLinkTransitionType(content::PAGE_TRANSITION_AUTO_BOOKMARK); | 160 web_ui->SetLinkTransitionType(content::PAGE_TRANSITION_AUTO_BOOKMARK); |
170 } | 161 } |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, | 422 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, |
432 gfx::Size(pixel_size, pixel_size), | 423 gfx::Size(pixel_size, pixel_size), |
433 scale_factors[i])); | 424 scale_factors[i])); |
434 } | 425 } |
435 | 426 |
436 // LoadImagesAsync actually can run callback synchronously. We want to force | 427 // LoadImagesAsync actually can run callback synchronously. We want to force |
437 // async. | 428 // async. |
438 extensions::ImageLoader::Get(profile)->LoadImagesAsync( | 429 extensions::ImageLoader::Get(profile)->LoadImagesAsync( |
439 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); | 430 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); |
440 } | 431 } |
OLD | NEW |