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

Side by Side Diff: chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc

Issue 105623002: Debug UI for DOM distiller supports distillation and lists articles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix strings and dependencies for ios Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « build/ios/grit_whitelist.txt ('k') | components/dom_distiller.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ui/webui/chrome_web_ui_controller_factory.h" 5 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "chrome/browser/about_flags.h" 12 #include "chrome/browser/about_flags.h"
13 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" 13 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h"
14 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
14 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/extensions/extension_web_ui.h" 16 #include "chrome/browser/extensions/extension_web_ui.h"
16 #include "chrome/browser/history/history_types.h" 17 #include "chrome/browser/history/history_types.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
19 #include "chrome/browser/ui/webui/about_ui.h" 20 #include "chrome/browser/ui/webui/about_ui.h"
20 #include "chrome/browser/ui/webui/app_launcher_page_ui.h" 21 #include "chrome/browser/ui/webui/app_launcher_page_ui.h"
21 #include "chrome/browser/ui/webui/bookmarks_ui.h" 22 #include "chrome/browser/ui/webui/bookmarks_ui.h"
22 #include "chrome/browser/ui/webui/components_ui.h" 23 #include "chrome/browser/ui/webui/components_ui.h"
23 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" 24 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
(...skipping 25 matching lines...) Expand all
49 #include "chrome/browser/ui/webui/signin_internals_ui.h" 50 #include "chrome/browser/ui/webui/signin_internals_ui.h"
50 #include "chrome/browser/ui/webui/sync_internals_ui.h" 51 #include "chrome/browser/ui/webui/sync_internals_ui.h"
51 #include "chrome/browser/ui/webui/translate_internals/translate_internals_ui.h" 52 #include "chrome/browser/ui/webui/translate_internals/translate_internals_ui.h"
52 #include "chrome/browser/ui/webui/user_actions/user_actions_ui.h" 53 #include "chrome/browser/ui/webui/user_actions/user_actions_ui.h"
53 #include "chrome/browser/ui/webui/version_ui.h" 54 #include "chrome/browser/ui/webui/version_ui.h"
54 #include "chrome/common/chrome_switches.h" 55 #include "chrome/common/chrome_switches.h"
55 #include "chrome/common/extensions/extension_constants.h" 56 #include "chrome/common/extensions/extension_constants.h"
56 #include "chrome/common/pref_names.h" 57 #include "chrome/common/pref_names.h"
57 #include "chrome/common/url_constants.h" 58 #include "chrome/common/url_constants.h"
58 #include "components/dom_distiller/core/dom_distiller_constants.h" 59 #include "components/dom_distiller/core/dom_distiller_constants.h"
60 #include "components/dom_distiller/core/dom_distiller_service.h"
59 #include "components/dom_distiller/webui/dom_distiller_ui.h" 61 #include "components/dom_distiller/webui/dom_distiller_ui.h"
60 #include "content/public/browser/web_contents.h" 62 #include "content/public/browser/web_contents.h"
61 #include "content/public/browser/web_ui.h" 63 #include "content/public/browser/web_ui.h"
62 #include "content/public/common/content_client.h" 64 #include "content/public/common/content_client.h"
63 #include "content/public/common/url_utils.h" 65 #include "content/public/common/url_utils.h"
64 #include "extensions/common/constants.h" 66 #include "extensions/common/constants.h"
65 #include "extensions/common/feature_switch.h" 67 #include "extensions/common/feature_switch.h"
66 #include "ui/gfx/favicon_size.h" 68 #include "ui/gfx/favicon_size.h"
67 #include "ui/web_dialogs/web_dialog_ui.h" 69 #include "ui/web_dialogs/web_dialog_ui.h"
68 #include "url/gurl.h" 70 #include "url/gurl.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 return new AboutUI(web_ui, url.host()); 182 return new AboutUI(web_ui, url.host());
181 } 183 }
182 184
183 #if defined(OS_CHROMEOS) 185 #if defined(OS_CHROMEOS)
184 template<> 186 template<>
185 WebUIController* NewWebUI<chromeos::OobeUI>(WebUI* web_ui, const GURL& url) { 187 WebUIController* NewWebUI<chromeos::OobeUI>(WebUI* web_ui, const GURL& url) {
186 return new chromeos::OobeUI(web_ui, url); 188 return new chromeos::OobeUI(web_ui, url);
187 } 189 }
188 #endif 190 #endif
189 191
192 // Special cases for DOM distiller.
193 template<>
194 WebUIController* NewWebUI<dom_distiller::DomDistillerUi>(WebUI* web_ui,
195 const GURL& url) {
196 // The DomDistillerUi can not depend on components/dom_distiller/content,
197 // so inject the correct DomDistillerService from chrome/.
198 content::BrowserContext* browser_context =
199 web_ui->GetWebContents()->GetBrowserContext();
200 dom_distiller::DomDistillerService* service =
201 dom_distiller::DomDistillerServiceFactory::GetForBrowserContext(
202 browser_context);
203 // TODO(nyquist): Add real scheme.
204 return new dom_distiller::DomDistillerUi(web_ui, service, "dummy");
205 }
206
190 // Only create ExtensionWebUI for URLs that are allowed extension bindings, 207 // Only create ExtensionWebUI for URLs that are allowed extension bindings,
191 // hosted by actual tabs. 208 // hosted by actual tabs.
192 bool NeedsExtensionWebUI(Profile* profile, const GURL& url) { 209 bool NeedsExtensionWebUI(Profile* profile, const GURL& url) {
193 ExtensionService* service = profile ? profile->GetExtensionService() : NULL; 210 ExtensionService* service = profile ? profile->GetExtensionService() : NULL;
194 return service && service->ExtensionBindingsAllowed(url); 211 return service && service->ExtensionBindingsAllowed(url);
195 } 212 }
196 213
197 // Returns a function that can be used to create the right type of WebUI for a 214 // Returns a function that can be used to create the right type of WebUI for a
198 // tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated 215 // tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated
199 // with it. 216 // with it.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 return &NewWebUI<ConstrainedWebDialogUI>; 256 return &NewWebUI<ConstrainedWebDialogUI>;
240 if (url.host() == chrome::kChromeUICrashesHost) 257 if (url.host() == chrome::kChromeUICrashesHost)
241 return &NewWebUI<CrashesUI>; 258 return &NewWebUI<CrashesUI>;
242 #if defined(ENABLE_MDNS) 259 #if defined(ENABLE_MDNS)
243 if (url.host() == chrome::kChromeUIDevicesHost && 260 if (url.host() == chrome::kChromeUIDevicesHost &&
244 !CommandLine::ForCurrentProcess()->HasSwitch( 261 !CommandLine::ForCurrentProcess()->HasSwitch(
245 switches::kDisableDeviceDiscovery)) { 262 switches::kDisableDeviceDiscovery)) {
246 return &NewWebUI<LocalDiscoveryUI>; 263 return &NewWebUI<LocalDiscoveryUI>;
247 } 264 }
248 #endif 265 #endif
249 if (IsEnableDomDistillerSet() &&
250 url.host() == dom_distiller::kChromeUIDomDistillerHost) {
251 return &NewWebUI<dom_distiller::DomDistillerUI>;
252 }
253 if (url.host() == chrome::kChromeUIFlagsHost) 266 if (url.host() == chrome::kChromeUIFlagsHost)
254 return &NewWebUI<FlagsUI>; 267 return &NewWebUI<FlagsUI>;
255 if (url.host() == chrome::kChromeUIHistoryFrameHost) 268 if (url.host() == chrome::kChromeUIHistoryFrameHost)
256 return &NewWebUI<HistoryUI>; 269 return &NewWebUI<HistoryUI>;
257 if (url.host() == chrome::kChromeUIInstantHost) 270 if (url.host() == chrome::kChromeUIInstantHost)
258 return &NewWebUI<InstantUI>; 271 return &NewWebUI<InstantUI>;
259 if (url.host() == chrome::kChromeUIManagedUserPassphrasePageHost) 272 if (url.host() == chrome::kChromeUIManagedUserPassphrasePageHost)
260 return &NewWebUI<ConstrainedWebDialogUI>; 273 return &NewWebUI<ConstrainedWebDialogUI>;
261 if (url.host() == chrome::kChromeUIMemoryInternalsHost) 274 if (url.host() == chrome::kChromeUIMemoryInternalsHost)
262 return &NewWebUI<MemoryInternalsUI>; 275 return &NewWebUI<MemoryInternalsUI>;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 486 }
474 if (url.host() == chrome::kChromeUIExtensionsFrameHost) 487 if (url.host() == chrome::kChromeUIExtensionsFrameHost)
475 return &NewWebUI<extensions::ExtensionsUI>; 488 return &NewWebUI<extensions::ExtensionsUI>;
476 #endif 489 #endif
477 #if defined(ENABLE_FULL_PRINTING) 490 #if defined(ENABLE_FULL_PRINTING)
478 if (url.host() == chrome::kChromeUIPrintHost && 491 if (url.host() == chrome::kChromeUIPrintHost &&
479 !profile->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled)) 492 !profile->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled))
480 return &NewWebUI<PrintPreviewUI>; 493 return &NewWebUI<PrintPreviewUI>;
481 #endif 494 #endif
482 495
496 if (IsEnableDomDistillerSet() &&
497 url.host() == dom_distiller::kChromeUIDomDistillerHost) {
498 return &NewWebUI<dom_distiller::DomDistillerUi>;
499 }
500
483 return NULL; 501 return NULL;
484 } 502 }
485 503
486 void RunFaviconCallbackAsync( 504 void RunFaviconCallbackAsync(
487 const FaviconService::FaviconResultsCallback& callback, 505 const FaviconService::FaviconResultsCallback& callback,
488 const std::vector<chrome::FaviconBitmapResult>* results) { 506 const std::vector<chrome::FaviconBitmapResult>* results) {
489 base::MessageLoopProxy::current()->PostTask( 507 base::MessageLoopProxy::current()->PostTask(
490 FROM_HERE, 508 FROM_HERE,
491 base::Bind(&FaviconService::FaviconResultsCallbackRunner, 509 base::Bind(&FaviconService::FaviconResultsCallbackRunner,
492 callback, base::Owned(results))); 510 callback, base::Owned(results)));
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 if (page_url.host() == chrome::kChromeUIPluginsHost) 664 if (page_url.host() == chrome::kChromeUIPluginsHost)
647 return PluginsUI::GetFaviconResourceBytes(scale_factor); 665 return PluginsUI::GetFaviconResourceBytes(scale_factor);
648 666
649 // Android doesn't use the components pages. 667 // Android doesn't use the components pages.
650 if (page_url.host() == chrome::kChromeUIComponentsHost) 668 if (page_url.host() == chrome::kChromeUIComponentsHost)
651 return ComponentsUI::GetFaviconResourceBytes(scale_factor); 669 return ComponentsUI::GetFaviconResourceBytes(scale_factor);
652 #endif 670 #endif
653 671
654 return NULL; 672 return NULL;
655 } 673 }
OLDNEW
« no previous file with comments | « build/ios/grit_whitelist.txt ('k') | components/dom_distiller.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698