| 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 <vector> | 10 #include <vector> |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 registry->RegisterDictionaryPref(kExtensionURLOverrides); | 370 registry->RegisterDictionaryPref(kExtensionURLOverrides); |
| 371 } | 371 } |
| 372 | 372 |
| 373 // static | 373 // static |
| 374 bool ExtensionWebUI::HandleChromeURLOverride( | 374 bool ExtensionWebUI::HandleChromeURLOverride( |
| 375 GURL* url, | 375 GURL* url, |
| 376 content::BrowserContext* browser_context) { | 376 content::BrowserContext* browser_context) { |
| 377 if (!url->SchemeIs(content::kChromeUIScheme)) | 377 if (!url->SchemeIs(content::kChromeUIScheme)) |
| 378 return false; | 378 return false; |
| 379 | 379 |
| 380 if (!browser_context) |
| 381 return false; |
| 382 |
| 380 Profile* profile = Profile::FromBrowserContext(browser_context); | 383 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 381 const base::DictionaryValue* overrides = | 384 const base::DictionaryValue* overrides = |
| 382 profile->GetPrefs()->GetDictionary(kExtensionURLOverrides); | 385 profile->GetPrefs()->GetDictionary(kExtensionURLOverrides); |
| 383 | 386 |
| 384 std::string url_host = url->host(); | 387 std::string url_host = url->host(); |
| 385 const base::ListValue* url_list = NULL; | 388 const base::ListValue* url_list = NULL; |
| 386 if (!overrides || !overrides->GetList(url_host, &url_list)) | 389 if (!overrides || !overrides->GetList(url_host, &url_list)) |
| 387 return false; | 390 return false; |
| 388 | 391 |
| 389 extensions::ExtensionRegistry* registry = | 392 extensions::ExtensionRegistry* registry = |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 *url = component_url; | 436 *url = component_url; |
| 434 return true; | 437 return true; |
| 435 } | 438 } |
| 436 | 439 |
| 437 return false; | 440 return false; |
| 438 } | 441 } |
| 439 | 442 |
| 440 // static | 443 // static |
| 441 bool ExtensionWebUI::HandleChromeURLOverrideReverse( | 444 bool ExtensionWebUI::HandleChromeURLOverrideReverse( |
| 442 GURL* url, content::BrowserContext* browser_context) { | 445 GURL* url, content::BrowserContext* browser_context) { |
| 446 if (!browser_context) |
| 447 return false; |
| 448 |
| 443 Profile* profile = Profile::FromBrowserContext(browser_context); | 449 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 444 const base::DictionaryValue* overrides = | 450 const base::DictionaryValue* overrides = |
| 445 profile->GetPrefs()->GetDictionary(kExtensionURLOverrides); | 451 profile->GetPrefs()->GetDictionary(kExtensionURLOverrides); |
| 446 if (!overrides) | 452 if (!overrides) |
| 447 return false; | 453 return false; |
| 448 | 454 |
| 449 // Find the reverse mapping based on the given URL. For example this maps the | 455 // Find the reverse mapping based on the given URL. For example this maps the |
| 450 // internal URL | 456 // internal URL |
| 451 // chrome-extension://eemcgdkfndhakfknompkggombfjjjeno/main.html#1 to | 457 // chrome-extension://eemcgdkfndhakfknompkggombfjjjeno/main.html#1 to |
| 452 // chrome://bookmarks/#1 for display in the omnibox. | 458 // chrome://bookmarks/#1 for display in the omnibox. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, | 564 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, |
| 559 gfx::Size(pixel_size, pixel_size), | 565 gfx::Size(pixel_size, pixel_size), |
| 560 resource_scale_factor)); | 566 resource_scale_factor)); |
| 561 } | 567 } |
| 562 | 568 |
| 563 // LoadImagesAsync actually can run callback synchronously. We want to force | 569 // LoadImagesAsync actually can run callback synchronously. We want to force |
| 564 // async. | 570 // async. |
| 565 extensions::ImageLoader::Get(profile)->LoadImagesAsync( | 571 extensions::ImageLoader::Get(profile)->LoadImagesAsync( |
| 566 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); | 572 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); |
| 567 } | 573 } |
| OLD | NEW |