Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/extensions/extension_web_ui.cc

Issue 12463042: Shows chrome-extension urls and greys out the whole url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed the correct extra newline Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 134 // Only grey out the entire url for internal pages (e.g. chrome-extension or
135 // component apps like bookmark manager. 135 // packaged component apps like bookmark manager).
136 bool should_hide_url = !extension->is_hosted_app(); 136 bool should_grey_out_url = !extension->is_hosted_app();
137 137
138 // The base class defaults to enabling WebUI bindings, but we don't need 138 // The base class defaults to enabling WebUI bindings, but we don't need
139 // those (this is also reflected in ChromeWebUIControllerFactory:: 139 // those (this is also reflected in ChromeWebUIControllerFactory::
140 // UseWebUIBindingsForURL). 140 // UseWebUIBindingsForURL).
141 int bindings = 0; 141 int bindings = 0;
142 142
143 // Bind externalHost to Extension WebUI loaded in Chrome Frame. 143 // Bind externalHost to Extension WebUI loaded in Chrome Frame.
144 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 144 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
145 if (browser_command_line.HasSwitch(switches::kChromeFrame)) 145 if (browser_command_line.HasSwitch(switches::kChromeFrame))
146 bindings |= content::BINDINGS_POLICY_EXTERNAL_HOST; 146 bindings |= content::BINDINGS_POLICY_EXTERNAL_HOST;
147 // For chrome:// overrides, some of the defaults are a little different. 147 // For chrome:// overrides, some of the defaults are a little different.
148 GURL effective_url = web_ui->GetWebContents()->GetURL(); 148 GURL effective_url = web_ui->GetWebContents()->GetURL();
149 if (effective_url.SchemeIs(chrome::kChromeUIScheme)) { 149 if (effective_url.SchemeIs(chrome::kChromeUIScheme)) {
150 if (effective_url.host() == chrome::kChromeUINewTabHost) { 150 if (effective_url.host() == chrome::kChromeUINewTabHost) {
151 web_ui->FocusLocationBarByDefault(); 151 web_ui->FocusLocationBarByDefault();
152 } else { 152 } else {
153 // Current behavior of other chrome:// pages is to display the URL. 153 // Current behavior of other chrome:// pages is to emphasize host,
Devlin 2013/04/01 20:35:28 "emphasize the host"
Patrick Riordan 2013/04/03 00:19:00 Done.
154 should_hide_url = false; 154 // which means we shouldn't grey out the entire url.
155 should_grey_out_url = false;
155 } 156 }
156 } 157 }
157 158
158 if (should_hide_url) 159 if (should_grey_out_url)
159 web_ui->HideURL(); 160 web_ui->GreyOutURL();
160 161
161 web_ui->SetBindings(bindings); 162 web_ui->SetBindings(bindings);
162 163
163 // Hack: A few things we specialize just for the bookmark manager. 164 // Hack: A few things we specialize just for the bookmark manager.
164 if (extension->id() == extension_misc::kBookmarkManagerId) { 165 if (extension->id() == extension_misc::kBookmarkManagerId) {
165 bookmark_manager_private_event_router_.reset( 166 bookmark_manager_private_event_router_.reset(
166 new extensions::BookmarkManagerPrivateEventRouter( 167 new extensions::BookmarkManagerPrivateEventRouter(
167 profile, web_ui->GetWebContents())); 168 profile, web_ui->GetWebContents()));
168 169
169 web_ui->SetLinkTransitionType(content::PAGE_TRANSITION_AUTO_BOOKMARK); 170 web_ui->SetLinkTransitionType(content::PAGE_TRANSITION_AUTO_BOOKMARK);
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, 432 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE,
432 gfx::Size(pixel_size, pixel_size), 433 gfx::Size(pixel_size, pixel_size),
433 scale_factors[i])); 434 scale_factors[i]));
434 } 435 }
435 436
436 // LoadImagesAsync actually can run callback synchronously. We want to force 437 // LoadImagesAsync actually can run callback synchronously. We want to force
437 // async. 438 // async.
438 extensions::ImageLoader::Get(profile)->LoadImagesAsync( 439 extensions::ImageLoader::Get(profile)->LoadImagesAsync(
439 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); 440 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback));
440 } 441 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698