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 <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/prefs/scoped_user_pref_update.h" | 12 #include "base/prefs/scoped_user_pref_update.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage
r_private_api.h" | 15 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage
r_private_api.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/extensions/extension_tab_util.h" | 17 #include "chrome/browser/extensions/extension_tab_util.h" |
18 #include "chrome/browser/extensions/extension_util.h" | 18 #include "chrome/browser/extensions/extension_util.h" |
19 #include "chrome/browser/extensions/image_loader.h" | 19 #include "chrome/browser/extensions/image_loader.h" |
| 20 #include "chrome/browser/favicon/favicon_service.h" |
20 #include "chrome/browser/favicon/favicon_util.h" | 21 #include "chrome/browser/favicon/favicon_util.h" |
21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
23 #include "chrome/common/extensions/extension_constants.h" | 24 #include "chrome/common/extensions/extension_constants.h" |
24 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
25 #include "components/pref_registry/pref_registry_syncable.h" | 26 #include "components/pref_registry/pref_registry_syncable.h" |
26 #include "content/public/browser/navigation_controller.h" | 27 #include "content/public/browser/navigation_controller.h" |
27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
28 #include "content/public/browser/web_ui.h" | 29 #include "content/public/browser/web_ui.h" |
29 #include "content/public/common/bindings_policy.h" | 30 #include "content/public/common/bindings_policy.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Don't use Reload() since |url| isn't the same as the internal URL that | 81 // Don't use Reload() since |url| isn't the same as the internal URL that |
81 // NavigationController has. | 82 // NavigationController has. |
82 web_contents->GetController().LoadURL( | 83 web_contents->GetController().LoadURL( |
83 url, content::Referrer(url, blink::WebReferrerPolicyDefault), | 84 url, content::Referrer(url, blink::WebReferrerPolicyDefault), |
84 content::PAGE_TRANSITION_RELOAD, std::string()); | 85 content::PAGE_TRANSITION_RELOAD, std::string()); |
85 } | 86 } |
86 | 87 |
87 // Run favicon callbck with image result. If no favicon was available then | 88 // Run favicon callbck with image result. If no favicon was available then |
88 // |image| will be empty. | 89 // |image| will be empty. |
89 void RunFaviconCallbackAsync( | 90 void RunFaviconCallbackAsync( |
90 const FaviconService::FaviconResultsCallback& callback, | 91 const favicon_base::FaviconResultsCallback& callback, |
91 const gfx::Image& image) { | 92 const gfx::Image& image) { |
92 std::vector<favicon_base::FaviconBitmapResult>* favicon_bitmap_results = | 93 std::vector<favicon_base::FaviconBitmapResult>* favicon_bitmap_results = |
93 new std::vector<favicon_base::FaviconBitmapResult>(); | 94 new std::vector<favicon_base::FaviconBitmapResult>(); |
94 | 95 |
95 const std::vector<gfx::ImageSkiaRep>& image_reps = | 96 const std::vector<gfx::ImageSkiaRep>& image_reps = |
96 image.AsImageSkia().image_reps(); | 97 image.AsImageSkia().image_reps(); |
97 for (size_t i = 0; i < image_reps.size(); ++i) { | 98 for (size_t i = 0; i < image_reps.size(); ++i) { |
98 const gfx::ImageSkiaRep& image_rep = image_reps[i]; | 99 const gfx::ImageSkiaRep& image_rep = image_reps[i]; |
99 scoped_refptr<base::RefCountedBytes> bitmap_data( | 100 scoped_refptr<base::RefCountedBytes> bitmap_data( |
100 new base::RefCountedBytes()); | 101 new base::RefCountedBytes()); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 UnregisterAndReplaceOverride(iter->first, profile, | 399 UnregisterAndReplaceOverride(iter->first, profile, |
399 page_overrides, &override); | 400 page_overrides, &override); |
400 } | 401 } |
401 } | 402 } |
402 } | 403 } |
403 | 404 |
404 // static | 405 // static |
405 void ExtensionWebUI::GetFaviconForURL( | 406 void ExtensionWebUI::GetFaviconForURL( |
406 Profile* profile, | 407 Profile* profile, |
407 const GURL& page_url, | 408 const GURL& page_url, |
408 const FaviconService::FaviconResultsCallback& callback) { | 409 const favicon_base::FaviconResultsCallback& callback) { |
409 // Even when the extensions service is enabled by default, it's still | 410 // Even when the extensions service is enabled by default, it's still |
410 // disabled in incognito mode. | 411 // disabled in incognito mode. |
411 ExtensionService* service = profile->GetExtensionService(); | 412 ExtensionService* service = profile->GetExtensionService(); |
412 if (!service) { | 413 if (!service) { |
413 RunFaviconCallbackAsync(callback, gfx::Image()); | 414 RunFaviconCallbackAsync(callback, gfx::Image()); |
414 return; | 415 return; |
415 } | 416 } |
416 const Extension* extension = service->extensions()->GetByID(page_url.host()); | 417 const Extension* extension = service->extensions()->GetByID(page_url.host()); |
417 if (!extension) { | 418 if (!extension) { |
418 RunFaviconCallbackAsync(callback, gfx::Image()); | 419 RunFaviconCallbackAsync(callback, gfx::Image()); |
(...skipping 21 matching lines...) Expand all Loading... |
440 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, | 441 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, |
441 gfx::Size(pixel_size, pixel_size), | 442 gfx::Size(pixel_size, pixel_size), |
442 scale_factors[i])); | 443 scale_factors[i])); |
443 } | 444 } |
444 | 445 |
445 // LoadImagesAsync actually can run callback synchronously. We want to force | 446 // LoadImagesAsync actually can run callback synchronously. We want to force |
446 // async. | 447 // async. |
447 extensions::ImageLoader::Get(profile)->LoadImagesAsync( | 448 extensions::ImageLoader::Get(profile)->LoadImagesAsync( |
448 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); | 449 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); |
449 } | 450 } |
OLD | NEW |