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

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

Issue 1635663002: [Extensions] Fix override urls' visible urls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months 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
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_web_ui_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 10 #include <vector>
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 Profile* profile = Profile::FromBrowserContext(browser_context); 441 Profile* profile = Profile::FromBrowserContext(browser_context);
442 const base::DictionaryValue* overrides = 442 const base::DictionaryValue* overrides =
443 profile->GetPrefs()->GetDictionary(kExtensionURLOverrides); 443 profile->GetPrefs()->GetDictionary(kExtensionURLOverrides);
444 if (!overrides) 444 if (!overrides)
445 return false; 445 return false;
446 446
447 // Find the reverse mapping based on the given URL. For example this maps the 447 // Find the reverse mapping based on the given URL. For example this maps the
448 // internal URL 448 // internal URL
449 // chrome-extension://eemcgdkfndhakfknompkggombfjjjeno/main.html#1 to 449 // chrome-extension://eemcgdkfndhakfknompkggombfjjjeno/main.html#1 to
450 // chrome://bookmarks/#1 for display in the omnibox. 450 // chrome://bookmarks/#1 for display in the omnibox.
451 for (base::DictionaryValue::Iterator it(*overrides); !it.IsAtEnd(); 451 for (base::DictionaryValue::Iterator dict_iter(*overrides);
452 it.Advance()) { 452 !dict_iter.IsAtEnd(); dict_iter.Advance()) {
453 const base::ListValue* url_list = NULL; 453 const base::ListValue* url_list = nullptr;
454 if (!it.value().GetAsList(&url_list)) 454 if (!dict_iter.value().GetAsList(&url_list))
455 continue; 455 continue;
456 456
457 for (base::ListValue::const_iterator it2 = url_list->begin(); 457 for (base::ListValue::const_iterator list_iter = url_list->begin();
458 it2 != url_list->end(); ++it2) { 458 list_iter != url_list->end(); ++list_iter) {
459 const base::DictionaryValue* dict = nullptr;
460 if (!(*list_iter)->GetAsDictionary(&dict))
461 continue;
459 std::string override; 462 std::string override;
460 if (!(*it2)->GetAsString(&override)) 463 if (!dict->GetString(kEntry, &override))
461 continue; 464 continue;
462 if (base::StartsWith(url->spec(), override, 465 if (base::StartsWith(url->spec(), override,
463 base::CompareCase::SENSITIVE)) { 466 base::CompareCase::SENSITIVE)) {
464 GURL original_url(content::kChromeUIScheme + std::string("://") + 467 GURL original_url(content::kChromeUIScheme + std::string("://") +
465 it.key() + url->spec().substr(override.length())); 468 dict_iter.key() +
469 url->spec().substr(override.length()));
466 *url = original_url; 470 *url = original_url;
467 return true; 471 return true;
468 } 472 }
469 } 473 }
470 } 474 }
471 475
472 return false; 476 return false;
473 } 477 }
474 478
475 // static 479 // static
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, 556 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE,
553 gfx::Size(pixel_size, pixel_size), 557 gfx::Size(pixel_size, pixel_size),
554 resource_scale_factor)); 558 resource_scale_factor));
555 } 559 }
556 560
557 // LoadImagesAsync actually can run callback synchronously. We want to force 561 // LoadImagesAsync actually can run callback synchronously. We want to force
558 // async. 562 // async.
559 extensions::ImageLoader::Get(profile)->LoadImagesAsync( 563 extensions::ImageLoader::Get(profile)->LoadImagesAsync(
560 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); 564 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback));
561 } 565 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_web_ui_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698