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

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

Issue 2468673003: [Extensions] Remove ExtensionWebUI (Closed)
Patch Set: nit Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/extensions/extension_web_ui.h ('k') | chrome/browser/extensions/tab_helper.cc » ('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/extensions/extension_web_ui.h" 5 #include "chrome/browser/extensions/extension_web_ui.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage r_private_api.h"
19 #include "chrome/browser/extensions/extension_tab_util.h" 18 #include "chrome/browser/extensions/extension_tab_util.h"
20 #include "chrome/browser/extensions/extension_util.h" 19 #include "chrome/browser/extensions/extension_util.h"
21 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/extensions/extension_constants.h" 22 #include "chrome/common/extensions/extension_constants.h"
24 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
25 #include "components/favicon/core/favicon_service.h" 24 #include "components/favicon/core/favicon_service.h"
26 #include "components/favicon_base/favicon_util.h" 25 #include "components/favicon_base/favicon_util.h"
27 #include "components/pref_registry/pref_registry_syncable.h" 26 #include "components/pref_registry/pref_registry_syncable.h"
28 #include "components/prefs/pref_service.h" 27 #include "components/prefs/pref_service.h"
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } 324 }
326 callback.Run(list); 325 callback.Run(list);
327 } 326 }
328 } 327 }
329 328
330 } // namespace 329 } // namespace
331 330
332 const char ExtensionWebUI::kExtensionURLOverrides[] = 331 const char ExtensionWebUI::kExtensionURLOverrides[] =
333 "extensions.chrome_url_overrides"; 332 "extensions.chrome_url_overrides";
334 333
335 ExtensionWebUI::ExtensionWebUI(content::WebUI* web_ui, const GURL& url)
336 : WebUIController(web_ui) {
337 Profile* profile = Profile::FromWebUI(web_ui);
338 const Extension* extension = extensions::ExtensionRegistry::Get(
339 profile)->enabled_extensions().GetExtensionOrAppByURL(url);
340 DCHECK(extension);
341 DCHECK_EQ(extension_misc::kBookmarkManagerId, extension->id());
342
343 // The base class defaults to enabling WebUI bindings, but we don't need
344 // those (this is also reflected in ChromeWebUIControllerFactory::
345 // UseWebUIBindingsForURL).
346 int bindings = 0;
347 web_ui->SetBindings(bindings);
348
349 // Hack: A few things we specialize just for the bookmark manager.
350 bookmark_manager_private_drag_event_router_.reset(
351 new extensions::BookmarkManagerPrivateDragEventRouter(
352 profile, web_ui->GetWebContents()));
353
354 web_ui->SetLinkTransitionType(ui::PAGE_TRANSITION_AUTO_BOOKMARK);
355 }
356
357 ExtensionWebUI::~ExtensionWebUI() {}
358
359 // static
360 bool ExtensionWebUI::NeedsExtensionWebUI(
361 content::BrowserContext* browser_context,
362 const GURL& url) {
363 CHECK(browser_context);
364 const Extension* extension =
365 extensions::ExtensionRegistry::Get(browser_context)->enabled_extensions().
366 GetExtensionOrAppByURL(url);
367 // Only use bindings for the Bookmark Manager extension, which needs it as a
368 // hack (see ExtensionWebUI's constructor below).
369 return extension && extension->id() == extension_misc::kBookmarkManagerId;
370 }
371
372 ////////////////////////////////////////////////////////////////////////////////
373 // chrome:// URL overrides
374
375 // static 334 // static
376 void ExtensionWebUI::RegisterProfilePrefs( 335 void ExtensionWebUI::RegisterProfilePrefs(
377 user_prefs::PrefRegistrySyncable* registry) { 336 user_prefs::PrefRegistrySyncable* registry) {
378 registry->RegisterDictionaryPref(kExtensionURLOverrides); 337 registry->RegisterDictionaryPref(kExtensionURLOverrides);
379 } 338 }
380 339
381 // static 340 // static
382 bool ExtensionWebUI::HandleChromeURLOverride( 341 bool ExtensionWebUI::HandleChromeURLOverride(
383 GURL* url, 342 GURL* url,
384 content::BrowserContext* browser_context) { 343 content::BrowserContext* browser_context) {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, 525 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE,
567 gfx::Size(pixel_size, pixel_size), 526 gfx::Size(pixel_size, pixel_size),
568 resource_scale_factor)); 527 resource_scale_factor));
569 } 528 }
570 529
571 // LoadImagesAsync actually can run callback synchronously. We want to force 530 // LoadImagesAsync actually can run callback synchronously. We want to force
572 // async. 531 // async.
573 extensions::ImageLoader::Get(profile)->LoadImagesAsync( 532 extensions::ImageLoader::Get(profile)->LoadImagesAsync(
574 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); 533 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback));
575 } 534 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_web_ui.h ('k') | chrome/browser/extensions/tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698