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

Side by Side Diff: ios/chrome/browser/ui/webui/history/browsing_history_handler.cc

Issue 1861593005: Convert //ios from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase? 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/chrome/browser/ui/webui/history/browsing_history_handler.h" 5 #include "ios/chrome/browser/ui/webui/history/browsing_history_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 void GetDeviceNameAndType(const ProfileSyncService* sync_service, 103 void GetDeviceNameAndType(const ProfileSyncService* sync_service,
104 const std::string& client_id, 104 const std::string& client_id,
105 std::string* name, 105 std::string* name,
106 std::string* type) { 106 std::string* type) {
107 // DeviceInfoTracker must be syncing in order for remote history entries to 107 // DeviceInfoTracker must be syncing in order for remote history entries to
108 // be available. 108 // be available.
109 DCHECK(sync_service); 109 DCHECK(sync_service);
110 DCHECK(sync_service->GetDeviceInfoTracker()); 110 DCHECK(sync_service->GetDeviceInfoTracker());
111 DCHECK(sync_service->GetDeviceInfoTracker()->IsSyncing()); 111 DCHECK(sync_service->GetDeviceInfoTracker()->IsSyncing());
112 112
113 scoped_ptr<sync_driver::DeviceInfo> device_info = 113 std::unique_ptr<sync_driver::DeviceInfo> device_info =
114 sync_service->GetDeviceInfoTracker()->GetDeviceInfo(client_id); 114 sync_service->GetDeviceInfoTracker()->GetDeviceInfo(client_id);
115 if (device_info.get()) { 115 if (device_info.get()) {
116 *name = device_info->client_name(); 116 *name = device_info->client_name();
117 switch (device_info->device_type()) { 117 switch (device_info->device_type()) {
118 case sync_pb::SyncEnums::TYPE_PHONE: 118 case sync_pb::SyncEnums::TYPE_PHONE:
119 *type = kDeviceTypePhone; 119 *type = kDeviceTypePhone;
120 break; 120 break;
121 case sync_pb::SyncEnums::TYPE_TABLET: 121 case sync_pb::SyncEnums::TYPE_TABLET:
122 *type = kDeviceTypeTablet; 122 *type = kDeviceTypeTablet;
123 break; 123 break;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // left to right strings. 175 // left to right strings.
176 if (base::i18n::IsRTL()) { 176 if (base::i18n::IsRTL()) {
177 if (using_url_as_the_title) 177 if (using_url_as_the_title)
178 base::i18n::WrapStringWithLTRFormatting(&title_to_set); 178 base::i18n::WrapStringWithLTRFormatting(&title_to_set);
179 else 179 else
180 base::i18n::AdjustStringForLocaleDirection(&title_to_set); 180 base::i18n::AdjustStringForLocaleDirection(&title_to_set);
181 } 181 }
182 result->SetString("title", title_to_set); 182 result->SetString("title", title_to_set);
183 } 183 }
184 184
185 scoped_ptr<base::DictionaryValue> BrowsingHistoryHandler::HistoryEntry::ToValue( 185 std::unique_ptr<base::DictionaryValue>
186 BrowsingHistoryHandler::HistoryEntry::ToValue(
186 BookmarkModel* bookmark_model, 187 BookmarkModel* bookmark_model,
187 SupervisedUserService* supervised_user_service, 188 SupervisedUserService* supervised_user_service,
188 const ProfileSyncService* sync_service) const { 189 const ProfileSyncService* sync_service) const {
189 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); 190 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
190 SetUrlAndTitle(result.get()); 191 SetUrlAndTitle(result.get());
191 192
192 base::string16 domain = url_formatter::IDNToUnicode(url.host()); 193 base::string16 domain = url_formatter::IDNToUnicode(url.host());
193 // When the domain is empty, use the scheme instead. This allows for a 194 // When the domain is empty, use the scheme instead. This allows for a
194 // sensible treatment of e.g. file: URLs when group by domain is on. 195 // sensible treatment of e.g. file: URLs when group by domain is on.
195 if (domain.empty()) 196 if (domain.empty())
196 domain = base::UTF8ToUTF16(url.scheme() + ":"); 197 domain = base::UTF8ToUTF16(url.scheme() + ":");
197 198
198 // The items which are to be written into result are also described in 199 // The items which are to be written into result are also described in
199 // chrome/browser/resources/history/history.js in @typedef for 200 // chrome/browser/resources/history/history.js in @typedef for
200 // HistoryEntry. Please update it whenever you add or remove 201 // HistoryEntry. Please update it whenever you add or remove
201 // any keys in result. 202 // any keys in result.
202 result->SetString("domain", domain); 203 result->SetString("domain", domain);
203 result->SetDouble("time", time.ToJsTime()); 204 result->SetDouble("time", time.ToJsTime());
204 205
205 // Pass the timestamps in a list. 206 // Pass the timestamps in a list.
206 scoped_ptr<base::ListValue> timestamps(new base::ListValue); 207 std::unique_ptr<base::ListValue> timestamps(new base::ListValue);
207 for (int64_t timestamp : all_timestamps) { 208 for (int64_t timestamp : all_timestamps) {
208 timestamps->AppendDouble( 209 timestamps->AppendDouble(
209 base::Time::FromInternalValue(timestamp).ToJsTime()); 210 base::Time::FromInternalValue(timestamp).ToJsTime());
210 } 211 }
211 result->Set("allTimestamps", timestamps.release()); 212 result->Set("allTimestamps", timestamps.release());
212 213
213 // Always pass the short date since it is needed both in the search and in 214 // Always pass the short date since it is needed both in the search and in
214 // the monthly view. 215 // the monthly view.
215 result->SetString("dateShort", base::TimeFormatShortDate(time)); 216 result->SetString("dateShort", base::TimeFormatShortDate(time));
216 217
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 int missing_count = std::count_if( 583 int missing_count = std::count_if(
583 query_results_.begin(), query_results_.end(), IsLocalOnlyResult); 584 query_results_.begin(), query_results_.end(), IsLocalOnlyResult);
584 UMA_HISTOGRAM_PERCENTAGE("WebHistory.LocalResultMissingOnServer", 585 UMA_HISTOGRAM_PERCENTAGE("WebHistory.LocalResultMissingOnServer",
585 missing_count * 100.0 / local_result_count); 586 missing_count * 100.0 / local_result_count);
586 } 587 }
587 } 588 }
588 589
589 // Convert the result vector into a ListValue. 590 // Convert the result vector into a ListValue.
590 base::ListValue results_value; 591 base::ListValue results_value;
591 for (const BrowsingHistoryHandler::HistoryEntry& entry : query_results_) { 592 for (const BrowsingHistoryHandler::HistoryEntry& entry : query_results_) {
592 scoped_ptr<base::Value> value( 593 std::unique_ptr<base::Value> value(
593 entry.ToValue(bookmark_model, nullptr, sync_service)); 594 entry.ToValue(bookmark_model, nullptr, sync_service));
594 results_value.Append(value.release()); 595 results_value.Append(value.release());
595 } 596 }
596 597
597 web_ui()->CallJavascriptFunction("historyResult", results_info_value_, 598 web_ui()->CallJavascriptFunction("historyResult", results_info_value_,
598 results_value); 599 results_value);
599 results_info_value_.Clear(); 600 results_info_value_.Clear();
600 query_results_.clear(); 601 query_results_.clear();
601 web_history_query_results_.clear(); 602 web_history_query_results_.clear();
602 } 603 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 799
799 void BrowsingHistoryHandler::OnURLsDeleted( 800 void BrowsingHistoryHandler::OnURLsDeleted(
800 history::HistoryService* history_service, 801 history::HistoryService* history_service,
801 bool all_history, 802 bool all_history,
802 bool expired, 803 bool expired,
803 const history::URLRows& deleted_rows, 804 const history::URLRows& deleted_rows,
804 const std::set<GURL>& favicon_urls) { 805 const std::set<GURL>& favicon_urls) {
805 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) 806 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_))
806 web_ui()->CallJavascriptFunction("historyDeleted"); 807 web_ui()->CallJavascriptFunction("historyDeleted");
807 } 808 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698