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

Side by Side Diff: chrome/browser/extensions/api/developer_private/extension_info_generator.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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
OLDNEW
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> 7 #include <utility>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 FROM_HERE, base::Bind(callback, base::Passed(&list_))); 296 FROM_HERE, base::Bind(callback, base::Passed(&list_)));
297 list_.clear(); 297 list_.clear();
298 } else { 298 } else {
299 callback_ = callback; 299 callback_ = callback;
300 } 300 }
301 } 301 }
302 302
303 void ExtensionInfoGenerator::CreateExtensionInfoHelper( 303 void ExtensionInfoGenerator::CreateExtensionInfoHelper(
304 const Extension& extension, 304 const Extension& extension,
305 developer::ExtensionState state) { 305 developer::ExtensionState state) {
306 scoped_ptr<developer::ExtensionInfo> info(new developer::ExtensionInfo()); 306 std::unique_ptr<developer::ExtensionInfo> info(
307 new developer::ExtensionInfo());
307 308
308 // Don't consider the button hidden with the redesign, because "hidden" 309 // Don't consider the button hidden with the redesign, because "hidden"
309 // buttons are now just hidden in the wrench menu. 310 // buttons are now just hidden in the wrench menu.
310 info->action_button_hidden = 311 info->action_button_hidden =
311 !extension_action_api_->GetBrowserActionVisibility(extension.id()) && 312 !extension_action_api_->GetBrowserActionVisibility(extension.id()) &&
312 !FeatureSwitch::extension_action_redesign()->IsEnabled(); 313 !FeatureSwitch::extension_action_redesign()->IsEnabled();
313 314
314 // Blacklist text. 315 // Blacklist text.
315 int blacklist_text = -1; 316 int blacklist_text = -1;
316 switch (extension_prefs_->GetExtensionBlacklistState(extension.id())) { 317 switch (extension_prefs_->GetExtensionBlacklistState(extension.id())) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } 355 }
355 356
356 bool is_enabled = state == developer::EXTENSION_STATE_ENABLED; 357 bool is_enabled = state == developer::EXTENSION_STATE_ENABLED;
357 358
358 // Commands. 359 // Commands.
359 if (is_enabled) 360 if (is_enabled)
360 ConstructCommands(command_service_, extension.id(), &info->commands); 361 ConstructCommands(command_service_, extension.id(), &info->commands);
361 362
362 // Dependent extensions. 363 // Dependent extensions.
363 if (extension.is_shared_module()) { 364 if (extension.is_shared_module()) {
364 scoped_ptr<ExtensionSet> dependent_extensions = 365 std::unique_ptr<ExtensionSet> dependent_extensions =
365 extension_system_->extension_service()-> 366 extension_system_->extension_service()
366 shared_module_service()->GetDependentExtensions(&extension); 367 ->shared_module_service()
368 ->GetDependentExtensions(&extension);
367 for (const scoped_refptr<const Extension>& dependent : 369 for (const scoped_refptr<const Extension>& dependent :
368 *dependent_extensions) 370 *dependent_extensions)
369 info->dependent_extensions.push_back(dependent->id()); 371 info->dependent_extensions.push_back(dependent->id());
370 } 372 }
371 373
372 info->description = extension.description(); 374 info->description = extension.description();
373 375
374 // Disable reasons. 376 // Disable reasons.
375 int disable_reasons = extension_prefs_->GetDisableReasons(extension.id()); 377 int disable_reasons = extension_prefs_->GetDisableReasons(extension.id());
376 info->disable_reasons.suspicious_install = 378 info->disable_reasons.suspicious_install =
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 } 592 }
591 593
592 std::string base_64; 594 std::string base_64;
593 base::Base64Encode(base::StringPiece(data->front_as<char>(), data->size()), 595 base::Base64Encode(base::StringPiece(data->front_as<char>(), data->size()),
594 &base_64); 596 &base_64);
595 const char kDataUrlPrefix[] = "data:image/png;base64,"; 597 const char kDataUrlPrefix[] = "data:image/png;base64,";
596 return GURL(kDataUrlPrefix + base_64).spec(); 598 return GURL(kDataUrlPrefix + base_64).spec();
597 } 599 }
598 600
599 void ExtensionInfoGenerator::OnImageLoaded( 601 void ExtensionInfoGenerator::OnImageLoaded(
600 scoped_ptr<developer::ExtensionInfo> info, 602 std::unique_ptr<developer::ExtensionInfo> info,
601 const gfx::Image& icon) { 603 const gfx::Image& icon) {
602 if (!icon.IsEmpty()) { 604 if (!icon.IsEmpty()) {
603 info->icon_url = GetIconUrlFromImage( 605 info->icon_url = GetIconUrlFromImage(
604 icon, info->state != developer::EXTENSION_STATE_ENABLED); 606 icon, info->state != developer::EXTENSION_STATE_ENABLED);
605 } else { 607 } else {
606 bool is_app = 608 bool is_app =
607 info->type == developer::EXTENSION_TYPE_HOSTED_APP || 609 info->type == developer::EXTENSION_TYPE_HOSTED_APP ||
608 info->type == developer::EXTENSION_TYPE_LEGACY_PACKAGED_APP || 610 info->type == developer::EXTENSION_TYPE_LEGACY_PACKAGED_APP ||
609 info->type == developer::EXTENSION_TYPE_PLATFORM_APP; 611 info->type == developer::EXTENSION_TYPE_PLATFORM_APP;
610 info->icon_url = GetDefaultIconUrl( 612 info->icon_url = GetDefaultIconUrl(
611 is_app, info->state != developer::EXTENSION_STATE_ENABLED); 613 is_app, info->state != developer::EXTENSION_STATE_ENABLED);
612 } 614 }
613 615
614 list_.push_back(std::move(*info)); 616 list_.push_back(std::move(*info));
615 617
616 --pending_image_loads_; 618 --pending_image_loads_;
617 619
618 if (pending_image_loads_ == 0) { // All done! 620 if (pending_image_loads_ == 0) { // All done!
619 ExtensionInfoList list = std::move(list_); 621 ExtensionInfoList list = std::move(list_);
620 list_.clear(); 622 list_.clear();
621 base::ResetAndReturn(&callback_).Run(std::move(list)); 623 base::ResetAndReturn(&callback_).Run(std::move(list));
622 // WARNING: |this| is possibly deleted after this line! 624 // WARNING: |this| is possibly deleted after this line!
623 } 625 }
624 } 626 }
625 627
626 } // namespace extensions 628 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698