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

Side by Side Diff: chrome/browser/banners/app_banner_settings_helper.cc

Issue 2334613003: Re-write many calls to WrapUnique() with MakeUnique() (Closed)
Patch Set: Changes from review by sky Created 4 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/banners/app_banner_settings_helper.h" 5 #include "chrome/browser/banners/app_banner_settings_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // Defaults to the number of minutes in a day. 92 // Defaults to the number of minutes in a day.
93 unsigned int gMinimumMinutesBetweenVisits = kNumberOfMinutesInADay; 93 unsigned int gMinimumMinutesBetweenVisits = kNumberOfMinutesInADay;
94 94
95 // Total engagement score required before a banner will actually be triggered. 95 // Total engagement score required before a banner will actually be triggered.
96 double gTotalEngagementToTrigger = kDefaultTotalEngagementToTrigger; 96 double gTotalEngagementToTrigger = kDefaultTotalEngagementToTrigger;
97 97
98 std::unique_ptr<base::DictionaryValue> GetOriginDict( 98 std::unique_ptr<base::DictionaryValue> GetOriginDict(
99 HostContentSettingsMap* settings, 99 HostContentSettingsMap* settings,
100 const GURL& origin_url) { 100 const GURL& origin_url) {
101 if (!settings) 101 if (!settings)
102 return base::WrapUnique(new base::DictionaryValue()); 102 return base::MakeUnique<base::DictionaryValue>();
103 103
104 std::unique_ptr<base::DictionaryValue> dict = 104 std::unique_ptr<base::DictionaryValue> dict =
105 base::DictionaryValue::From(settings->GetWebsiteSetting( 105 base::DictionaryValue::From(settings->GetWebsiteSetting(
106 origin_url, origin_url, CONTENT_SETTINGS_TYPE_APP_BANNER, 106 origin_url, origin_url, CONTENT_SETTINGS_TYPE_APP_BANNER,
107 std::string(), NULL)); 107 std::string(), NULL));
108 if (!dict) 108 if (!dict)
109 return base::WrapUnique(new base::DictionaryValue()); 109 return base::MakeUnique<base::DictionaryValue>();
110 110
111 return dict; 111 return dict;
112 } 112 }
113 113
114 base::DictionaryValue* GetAppDict(base::DictionaryValue* origin_dict, 114 base::DictionaryValue* GetAppDict(base::DictionaryValue* origin_dict,
115 const std::string& key_name) { 115 const std::string& key_name) {
116 base::DictionaryValue* app_dict = nullptr; 116 base::DictionaryValue* app_dict = nullptr;
117 if (!origin_dict->GetDictionaryWithoutPathExpansion(key_name, &app_dict)) { 117 if (!origin_dict->GetDictionaryWithoutPathExpansion(key_name, &app_dict)) {
118 // Don't allow more than kMaxAppsPerSite dictionaries. 118 // Don't allow more than kMaxAppsPerSite dictionaries.
119 if (origin_dict->size() < kMaxAppsPerSite) { 119 if (origin_dict->size() < kMaxAppsPerSite) {
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 return true; 649 return true;
650 } 650 }
651 651
652 // Assume any value which is not "0" or "false" indicates that we should use 652 // Assume any value which is not "0" or "false" indicates that we should use
653 // site engagement. 653 // site engagement.
654 std::string param = variations::GetVariationParamValue( 654 std::string param = variations::GetVariationParamValue(
655 kBannerParamsKey, kBannerSiteEngagementParamsKey); 655 kBannerParamsKey, kBannerSiteEngagementParamsKey);
656 656
657 return (!param.empty() && param != "0" && param != "false"); 657 return (!param.empty() && param != "0" && param != "false");
658 } 658 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698