| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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) { | |
| 338 Profile* profile = Profile::FromWebUI(web_ui); | 337 Profile* profile = Profile::FromWebUI(web_ui); |
| 339 const Extension* extension = extensions::ExtensionRegistry::Get( | 338 const Extension* extension = extensions::ExtensionRegistry::Get( |
| 340 profile)->enabled_extensions().GetExtensionOrAppByURL(url); | 339 profile)->enabled_extensions().GetExtensionOrAppByURL(url); |
| 341 DCHECK(extension); | 340 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 if (extension->id() == extension_misc::kBookmarkManagerId) { | 350 bookmark_manager_private_drag_event_router_.reset( |
| 351 bookmark_manager_private_drag_event_router_.reset( | 351 new extensions::BookmarkManagerPrivateDragEventRouter( |
| 352 new extensions::BookmarkManagerPrivateDragEventRouter( | 352 profile, web_ui->GetWebContents())); |
| 353 profile, web_ui->GetWebContents())); | |
| 354 | 353 |
| 355 web_ui->SetLinkTransitionType(ui::PAGE_TRANSITION_AUTO_BOOKMARK); | 354 web_ui->SetLinkTransitionType(ui::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 356 } | |
| 357 } | 355 } |
| 358 | 356 |
| 359 ExtensionWebUI::~ExtensionWebUI() {} | 357 ExtensionWebUI::~ExtensionWebUI() {} |
| 360 | 358 |
| 361 extensions::BookmarkManagerPrivateDragEventRouter* | 359 // static |
| 362 ExtensionWebUI::bookmark_manager_private_drag_event_router() { | 360 bool ExtensionWebUI::NeedsExtensionWebUI( |
| 363 return bookmark_manager_private_drag_event_router_.get(); | 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; |
| 364 } | 370 } |
| 365 | 371 |
| 366 //////////////////////////////////////////////////////////////////////////////// | 372 //////////////////////////////////////////////////////////////////////////////// |
| 367 // chrome:// URL overrides | 373 // chrome:// URL overrides |
| 368 | 374 |
| 369 // static | 375 // static |
| 370 void ExtensionWebUI::RegisterProfilePrefs( | 376 void ExtensionWebUI::RegisterProfilePrefs( |
| 371 user_prefs::PrefRegistrySyncable* registry) { | 377 user_prefs::PrefRegistrySyncable* registry) { |
| 372 registry->RegisterDictionaryPref(kExtensionURLOverrides); | 378 registry->RegisterDictionaryPref(kExtensionURLOverrides); |
| 373 } | 379 } |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, | 566 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, |
| 561 gfx::Size(pixel_size, pixel_size), | 567 gfx::Size(pixel_size, pixel_size), |
| 562 resource_scale_factor)); | 568 resource_scale_factor)); |
| 563 } | 569 } |
| 564 | 570 |
| 565 // LoadImagesAsync actually can run callback synchronously. We want to force | 571 // LoadImagesAsync actually can run callback synchronously. We want to force |
| 566 // async. | 572 // async. |
| 567 extensions::ImageLoader::Get(profile)->LoadImagesAsync( | 573 extensions::ImageLoader::Get(profile)->LoadImagesAsync( |
| 568 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); | 574 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); |
| 569 } | 575 } |
| OLD | NEW |