OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/api/developer_private/extension_info_generat
or.h" | 5 #include "chrome/browser/extensions/api/developer_private/extension_info_generat
or.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/base64.h" | 9 #include "base/base64.h" |
8 #include "base/location.h" | 10 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
11 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
12 #include "chrome/browser/extensions/api/commands/command_service.h" | 14 #include "chrome/browser/extensions/api/commands/command_service.h" |
13 #include "chrome/browser/extensions/api/developer_private/inspectable_views_find
er.h" | 15 #include "chrome/browser/extensions/api/developer_private/inspectable_views_find
er.h" |
14 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 16 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
15 #include "chrome/browser/extensions/error_console/error_console.h" | 17 #include "chrome/browser/extensions/error_console/error_console.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 if (icon.empty()) { | 541 if (icon.empty()) { |
540 info->icon_url = GetDefaultIconUrl(extension.is_app(), !is_enabled); | 542 info->icon_url = GetDefaultIconUrl(extension.is_app(), !is_enabled); |
541 list_.push_back(make_linked_ptr(info.release())); | 543 list_.push_back(make_linked_ptr(info.release())); |
542 } else { | 544 } else { |
543 ++pending_image_loads_; | 545 ++pending_image_loads_; |
544 // Max size of 128x128 is a random guess at a nice balance between being | 546 // Max size of 128x128 is a random guess at a nice balance between being |
545 // overly eager to resize and sending across gigantic data urls. (The icon | 547 // overly eager to resize and sending across gigantic data urls. (The icon |
546 // used by the url is 48x48). | 548 // used by the url is 48x48). |
547 gfx::Size max_size(128, 128); | 549 gfx::Size max_size(128, 128); |
548 image_loader_->LoadImageAsync( | 550 image_loader_->LoadImageAsync( |
549 &extension, | 551 &extension, icon, max_size, |
550 icon, | |
551 max_size, | |
552 base::Bind(&ExtensionInfoGenerator::OnImageLoaded, | 552 base::Bind(&ExtensionInfoGenerator::OnImageLoaded, |
553 weak_factory_.GetWeakPtr(), | 553 weak_factory_.GetWeakPtr(), base::Passed(std::move(info)))); |
554 base::Passed(info.Pass()))); | |
555 } | 554 } |
556 } | 555 } |
557 | 556 |
558 const std::string& ExtensionInfoGenerator::GetDefaultIconUrl( | 557 const std::string& ExtensionInfoGenerator::GetDefaultIconUrl( |
559 bool is_app, | 558 bool is_app, |
560 bool is_greyscale) { | 559 bool is_greyscale) { |
561 std::string* str; | 560 std::string* str; |
562 if (is_app) { | 561 if (is_app) { |
563 str = is_greyscale ? &default_disabled_app_icon_url_ : | 562 str = is_greyscale ? &default_disabled_app_icon_url_ : |
564 &default_app_icon_url_; | 563 &default_app_icon_url_; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 // that at the end of the method, any stored refs are destroyed. | 624 // that at the end of the method, any stored refs are destroyed. |
626 ExtensionInfoList list; | 625 ExtensionInfoList list; |
627 list.swap(list_); | 626 list.swap(list_); |
628 ExtensionInfosCallback callback = callback_; | 627 ExtensionInfosCallback callback = callback_; |
629 callback_.Reset(); | 628 callback_.Reset(); |
630 callback.Run(list); // WARNING: |this| is possibly deleted after this line! | 629 callback.Run(list); // WARNING: |this| is possibly deleted after this line! |
631 } | 630 } |
632 } | 631 } |
633 | 632 |
634 } // namespace extensions | 633 } // namespace extensions |
OLD | NEW |