| OLD | NEW |
| 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 Loading... |
| 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 CHECK(browser_context); |
| 340 const Extension* extension = |
| 341 extensions::ExtensionRegistry::Get(browser_context)->enabled_extensions(). |
| 342 GetExtensionOrAppByURL(url); |
| 343 // Only use bindings for the Bookmark Manager extension, which needs it as a |
| 344 // hack (see ExtensionWebUI's constructor below). |
| 345 return extension && extension->id() == extension_misc::kBookmarkManagerId; |
| 346 } |
| 347 |
| 335 ExtensionWebUI::ExtensionWebUI(content::WebUI* web_ui, const GURL& url) | 348 ExtensionWebUI::ExtensionWebUI(content::WebUI* web_ui, const GURL& url) |
| 336 : WebUIController(web_ui), | 349 : WebUIController(web_ui) { |
| 337 url_(url) { | |
| 338 Profile* profile = Profile::FromWebUI(web_ui); | 350 Profile* profile = Profile::FromWebUI(web_ui); |
| 339 const Extension* extension = extensions::ExtensionRegistry::Get( | 351 const Extension* extension = extensions::ExtensionRegistry::Get( |
| 340 profile)->enabled_extensions().GetExtensionOrAppByURL(url); | 352 profile)->enabled_extensions().GetExtensionOrAppByURL(url); |
| 341 DCHECK(extension); | 353 DCHECK(extension); |
| 354 DCHECK_EQ(extension_misc::kBookmarkManagerId, extension->id()); |
| 342 | 355 |
| 343 // The base class defaults to enabling WebUI bindings, but we don't need | 356 // The base class defaults to enabling WebUI bindings, but we don't need |
| 344 // those (this is also reflected in ChromeWebUIControllerFactory:: | 357 // those (this is also reflected in ChromeWebUIControllerFactory:: |
| 345 // UseWebUIBindingsForURL). | 358 // UseWebUIBindingsForURL). |
| 346 int bindings = 0; | 359 int bindings = 0; |
| 347 web_ui->SetBindings(bindings); | 360 web_ui->SetBindings(bindings); |
| 348 | 361 |
| 349 // Hack: A few things we specialize just for the bookmark manager. | 362 // Hack: A few things we specialize just for the bookmark manager. |
| 350 if (extension->id() == extension_misc::kBookmarkManagerId) { | 363 bookmark_manager_private_drag_event_router_.reset( |
| 351 bookmark_manager_private_drag_event_router_.reset( | 364 new extensions::BookmarkManagerPrivateDragEventRouter( |
| 352 new extensions::BookmarkManagerPrivateDragEventRouter( | 365 profile, web_ui->GetWebContents())); |
| 353 profile, web_ui->GetWebContents())); | |
| 354 | 366 |
| 355 web_ui->SetLinkTransitionType(ui::PAGE_TRANSITION_AUTO_BOOKMARK); | 367 web_ui->SetLinkTransitionType(ui::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 356 } | |
| 357 } | 368 } |
| 358 | 369 |
| 359 ExtensionWebUI::~ExtensionWebUI() {} | 370 ExtensionWebUI::~ExtensionWebUI() {} |
| 360 | 371 |
| 361 extensions::BookmarkManagerPrivateDragEventRouter* | 372 extensions::BookmarkManagerPrivateDragEventRouter* |
| 362 ExtensionWebUI::bookmark_manager_private_drag_event_router() { | 373 ExtensionWebUI::bookmark_manager_private_drag_event_router() { |
| 363 return bookmark_manager_private_drag_event_router_.get(); | 374 return bookmark_manager_private_drag_event_router_.get(); |
| 364 } | 375 } |
| 365 | 376 |
| 366 //////////////////////////////////////////////////////////////////////////////// | 377 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, | 571 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, |
| 561 gfx::Size(pixel_size, pixel_size), | 572 gfx::Size(pixel_size, pixel_size), |
| 562 resource_scale_factor)); | 573 resource_scale_factor)); |
| 563 } | 574 } |
| 564 | 575 |
| 565 // LoadImagesAsync actually can run callback synchronously. We want to force | 576 // LoadImagesAsync actually can run callback synchronously. We want to force |
| 566 // async. | 577 // async. |
| 567 extensions::ImageLoader::Get(profile)->LoadImagesAsync( | 578 extensions::ImageLoader::Get(profile)->LoadImagesAsync( |
| 568 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); | 579 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); |
| 569 } | 580 } |
| OLD | NEW |