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

Side by Side Diff: chrome/browser/ui/search_engines/template_url_table_model.cc

Issue 2290503003: Remove use of stl_util in search_engines. (Closed)
Patch Set: ios for reals 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 (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/ui/search_engines/template_url_table_model.h" 5 #include "chrome/browser/ui/search_engines/template_url_table_model.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h"
12 #include "base/task/cancelable_task_tracker.h" 13 #include "base/task/cancelable_task_tracker.h"
13 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
14 #include "components/favicon/core/favicon_service.h" 15 #include "components/favicon/core/favicon_service.h"
15 #include "components/favicon_base/favicon_types.h" 16 #include "components/favicon_base/favicon_types.h"
16 #include "components/search_engines/template_url.h" 17 #include "components/search_engines/template_url.h"
17 #include "components/search_engines/template_url_service.h" 18 #include "components/search_engines/template_url_service.h"
18 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/models/table_model_observer.h" 20 #include "ui/base/models/table_model_observer.h"
20 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/gfx/image/image_skia.h" 22 #include "ui/gfx/image/image_skia.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 const base::string16& short_name, 260 const base::string16& short_name,
260 const base::string16& keyword, 261 const base::string16& keyword,
261 const std::string& url) { 262 const std::string& url) {
262 DCHECK(index >= 0 && index <= RowCount()); 263 DCHECK(index >= 0 && index <= RowCount());
263 DCHECK(!url.empty()); 264 DCHECK(!url.empty());
264 template_url_service_->RemoveObserver(this); 265 template_url_service_->RemoveObserver(this);
265 TemplateURLData data; 266 TemplateURLData data;
266 data.SetShortName(short_name); 267 data.SetShortName(short_name);
267 data.SetKeyword(keyword); 268 data.SetKeyword(keyword);
268 data.SetURL(url); 269 data.SetURL(url);
269 TemplateURL* turl = new TemplateURL(data); 270 std::unique_ptr<TemplateURL> turl_ptr = base::MakeUnique<TemplateURL>(data);
270 template_url_service_->Add(turl); 271 TemplateURL* turl = turl_ptr.get();
272 template_url_service_->Add(std::move(turl_ptr));
Peter Kasting 2016/08/31 04:12:56 Nit: Just use the old code and add a WrapUnique()
Avi (use Gerrit) 2016/09/01 00:34:26 fixed
271 std::unique_ptr<ModelEntry> entry(new ModelEntry(this, turl)); 273 std::unique_ptr<ModelEntry> entry(new ModelEntry(this, turl));
272 template_url_service_->AddObserver(this); 274 template_url_service_->AddObserver(this);
273 AddEntry(index, std::move(entry)); 275 AddEntry(index, std::move(entry));
274 } 276 }
275 277
276 void TemplateURLTableModel::ModifyTemplateURL(int index, 278 void TemplateURLTableModel::ModifyTemplateURL(int index,
277 const base::string16& title, 279 const base::string16& title,
278 const base::string16& keyword, 280 const base::string16& keyword,
279 const std::string& url) { 281 const std::string& url) {
280 DCHECK(index >= 0 && index <= RowCount()); 282 DCHECK(index >= 0 && index <= RowCount());
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 } 389 }
388 390
389 void TemplateURLTableModel::AddEntry(int index, 391 void TemplateURLTableModel::AddEntry(int index,
390 std::unique_ptr<ModelEntry> entry) { 392 std::unique_ptr<ModelEntry> entry) {
391 entries_.insert(entries_.begin() + index, entry.release()); 393 entries_.insert(entries_.begin() + index, entry.release());
392 if (index <= last_other_engine_index_) 394 if (index <= last_other_engine_index_)
393 ++last_other_engine_index_; 395 ++last_other_engine_index_;
394 if (observer_) 396 if (observer_)
395 observer_->OnItemsAdded(index, 1); 397 observer_->OnItemsAdded(index, 1);
396 } 398 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698