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

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

Issue 2452773002: [Extensions] Limit Extension WebUI (Closed)
Patch Set: Add TODOs 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } 325 }
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 // static
336 bool ExtensionWebUI::NeedsExtensionWebUI(
337 content::BrowserContext* browser_context,
338 const GURL& url) {
339 if (!browser_context)
Dan Beam 2016/10/26 21:44:19 can we really not have a browser_context validly?
Devlin 2016/10/26 21:54:50 I copied this from the old code, but I'd kind of h
Devlin 2016/10/29 17:42:24 So, not validly - but apparently yes in a unittest
340 return false;
341
342 const Extension* extension =
343 extensions::ExtensionRegistry::Get(browser_context)->enabled_extensions().
Dan Beam 2016/10/26 21:44:19 does this exist in all cases (i.e. guest mode)? i
Devlin 2016/10/26 21:54:50 ExtensionRegistry should always, always, always ex
344 GetExtensionOrAppByURL(url);
345 // Only use bindings for the Bookmark Manager extension, which needs it as a
346 // hack (see ExtensionWebUI's constructor below).
347 return extension && extension->id() == extension_misc::kBookmarkManagerId;
348 }
349
335 ExtensionWebUI::ExtensionWebUI(content::WebUI* web_ui, const GURL& url) 350 ExtensionWebUI::ExtensionWebUI(content::WebUI* web_ui, const GURL& url)
336 : WebUIController(web_ui), 351 : WebUIController(web_ui) {
337 url_(url) {
338 Profile* profile = Profile::FromWebUI(web_ui); 352 Profile* profile = Profile::FromWebUI(web_ui);
339 const Extension* extension = extensions::ExtensionRegistry::Get( 353 const Extension* extension = extensions::ExtensionRegistry::Get(
340 profile)->enabled_extensions().GetExtensionOrAppByURL(url); 354 profile)->enabled_extensions().GetExtensionOrAppByURL(url);
341 DCHECK(extension); 355 DCHECK(extension);
356 DCHECK_EQ(extension_misc::kBookmarkManagerId, extension->id());
Dan Beam 2016/10/26 21:44:19 should we rename this class then? to like Bookmar
Devlin 2016/10/26 21:54:50 Yes. But it's got too much unrelated stuff in it
342 357
343 // The base class defaults to enabling WebUI bindings, but we don't need 358 // The base class defaults to enabling WebUI bindings, but we don't need
344 // those (this is also reflected in ChromeWebUIControllerFactory:: 359 // those (this is also reflected in ChromeWebUIControllerFactory::
345 // UseWebUIBindingsForURL). 360 // UseWebUIBindingsForURL).
346 int bindings = 0; 361 int bindings = 0;
347 web_ui->SetBindings(bindings); 362 web_ui->SetBindings(bindings);
348 363
349 // Hack: A few things we specialize just for the bookmark manager. 364 // Hack: A few things we specialize just for the bookmark manager.
350 if (extension->id() == extension_misc::kBookmarkManagerId) { 365 bookmark_manager_private_drag_event_router_.reset(
351 bookmark_manager_private_drag_event_router_.reset( 366 new extensions::BookmarkManagerPrivateDragEventRouter(
352 new extensions::BookmarkManagerPrivateDragEventRouter( 367 profile, web_ui->GetWebContents()));
353 profile, web_ui->GetWebContents()));
354 368
355 web_ui->SetLinkTransitionType(ui::PAGE_TRANSITION_AUTO_BOOKMARK); 369 web_ui->SetLinkTransitionType(ui::PAGE_TRANSITION_AUTO_BOOKMARK);
356 }
357 } 370 }
358 371
359 ExtensionWebUI::~ExtensionWebUI() {} 372 ExtensionWebUI::~ExtensionWebUI() {}
360 373
361 extensions::BookmarkManagerPrivateDragEventRouter* 374 extensions::BookmarkManagerPrivateDragEventRouter*
362 ExtensionWebUI::bookmark_manager_private_drag_event_router() { 375 ExtensionWebUI::bookmark_manager_private_drag_event_router() {
363 return bookmark_manager_private_drag_event_router_.get(); 376 return bookmark_manager_private_drag_event_router_.get();
364 } 377 }
365 378
366 //////////////////////////////////////////////////////////////////////////////// 379 ////////////////////////////////////////////////////////////////////////////////
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, 573 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE,
561 gfx::Size(pixel_size, pixel_size), 574 gfx::Size(pixel_size, pixel_size),
562 resource_scale_factor)); 575 resource_scale_factor));
563 } 576 }
564 577
565 // LoadImagesAsync actually can run callback synchronously. We want to force 578 // LoadImagesAsync actually can run callback synchronously. We want to force
566 // async. 579 // async.
567 extensions::ImageLoader::Get(profile)->LoadImagesAsync( 580 extensions::ImageLoader::Get(profile)->LoadImagesAsync(
568 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); 581 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback));
569 } 582 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_web_ui.h ('k') | chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698