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

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

Issue 2463153003: Revert of [Extensions] Limit Extension WebUI (Closed)
Patch Set: 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
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>
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 callback.Run(list); 326 callback.Run(list);
327 } 327 }
328 } 328 }
329 329
330 } // namespace 330 } // namespace
331 331
332 const char ExtensionWebUI::kExtensionURLOverrides[] = 332 const char ExtensionWebUI::kExtensionURLOverrides[] =
333 "extensions.chrome_url_overrides"; 333 "extensions.chrome_url_overrides";
334 334
335 ExtensionWebUI::ExtensionWebUI(content::WebUI* web_ui, const GURL& url) 335 ExtensionWebUI::ExtensionWebUI(content::WebUI* web_ui, const GURL& url)
336 : WebUIController(web_ui) { 336 : WebUIController(web_ui),
337 url_(url) {
337 Profile* profile = Profile::FromWebUI(web_ui); 338 Profile* profile = Profile::FromWebUI(web_ui);
338 const Extension* extension = extensions::ExtensionRegistry::Get( 339 const Extension* extension = extensions::ExtensionRegistry::Get(
339 profile)->enabled_extensions().GetExtensionOrAppByURL(url); 340 profile)->enabled_extensions().GetExtensionOrAppByURL(url);
340 DCHECK(extension); 341 DCHECK(extension);
341 DCHECK_EQ(extension_misc::kBookmarkManagerId, extension->id());
342 342
343 // The base class defaults to enabling WebUI bindings, but we don't need 343 // The base class defaults to enabling WebUI bindings, but we don't need
344 // those (this is also reflected in ChromeWebUIControllerFactory:: 344 // those (this is also reflected in ChromeWebUIControllerFactory::
345 // UseWebUIBindingsForURL). 345 // UseWebUIBindingsForURL).
346 int bindings = 0; 346 int bindings = 0;
347 web_ui->SetBindings(bindings); 347 web_ui->SetBindings(bindings);
348 348
349 // Hack: A few things we specialize just for the bookmark manager. 349 // Hack: A few things we specialize just for the bookmark manager.
350 bookmark_manager_private_drag_event_router_.reset( 350 if (extension->id() == extension_misc::kBookmarkManagerId) {
351 new extensions::BookmarkManagerPrivateDragEventRouter( 351 bookmark_manager_private_drag_event_router_.reset(
352 profile, web_ui->GetWebContents())); 352 new extensions::BookmarkManagerPrivateDragEventRouter(
353 profile, web_ui->GetWebContents()));
353 354
354 web_ui->SetLinkTransitionType(ui::PAGE_TRANSITION_AUTO_BOOKMARK); 355 web_ui->SetLinkTransitionType(ui::PAGE_TRANSITION_AUTO_BOOKMARK);
356 }
355 } 357 }
356 358
357 ExtensionWebUI::~ExtensionWebUI() {} 359 ExtensionWebUI::~ExtensionWebUI() {}
358 360
359 // static 361 extensions::BookmarkManagerPrivateDragEventRouter*
360 bool ExtensionWebUI::NeedsExtensionWebUI( 362 ExtensionWebUI::bookmark_manager_private_drag_event_router() {
361 content::BrowserContext* browser_context, 363 return bookmark_manager_private_drag_event_router_.get();
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 } 364 }
371 365
372 //////////////////////////////////////////////////////////////////////////////// 366 ////////////////////////////////////////////////////////////////////////////////
373 // chrome:// URL overrides 367 // chrome:// URL overrides
374 368
375 // static 369 // static
376 void ExtensionWebUI::RegisterProfilePrefs( 370 void ExtensionWebUI::RegisterProfilePrefs(
377 user_prefs::PrefRegistrySyncable* registry) { 371 user_prefs::PrefRegistrySyncable* registry) {
378 registry->RegisterDictionaryPref(kExtensionURLOverrides); 372 registry->RegisterDictionaryPref(kExtensionURLOverrides);
379 } 373 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, 560 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE,
567 gfx::Size(pixel_size, pixel_size), 561 gfx::Size(pixel_size, pixel_size),
568 resource_scale_factor)); 562 resource_scale_factor));
569 } 563 }
570 564
571 // LoadImagesAsync actually can run callback synchronously. We want to force 565 // LoadImagesAsync actually can run callback synchronously. We want to force
572 // async. 566 // async.
573 extensions::ImageLoader::Get(profile)->LoadImagesAsync( 567 extensions::ImageLoader::Get(profile)->LoadImagesAsync(
574 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); 568 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback));
575 } 569 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_web_ui.h ('k') | chrome/browser/ui/views/bookmarks/bookmark_context_menu_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698