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

Side by Side Diff: components/undo/bookmark_undo_service.cc

Issue 1917673002: Convert //components/[u-z]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build fix 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/undo/bookmark_undo_service.h" 5 #include "components/undo/bookmark_undo_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9
10 #include <memory>
danakj 2016/04/25 18:32:58 dont need then
dcheng 2016/04/25 19:55:06 See previous.
9 #include <utility> 11 #include <utility>
10 12
11 #include "base/macros.h" 13 #include "base/macros.h"
12 #include "components/bookmarks/browser/bookmark_model.h" 14 #include "components/bookmarks/browser/bookmark_model.h"
13 #include "components/bookmarks/browser/bookmark_node_data.h" 15 #include "components/bookmarks/browser/bookmark_node_data.h"
14 #include "components/bookmarks/browser/bookmark_undo_provider.h" 16 #include "components/bookmarks/browser/bookmark_undo_provider.h"
15 #include "components/bookmarks/browser/bookmark_utils.h" 17 #include "components/bookmarks/browser/bookmark_utils.h"
16 #include "components/bookmarks/browser/scoped_group_bookmark_actions.h" 18 #include "components/bookmarks/browser/scoped_group_bookmark_actions.h"
17 #include "components/undo/undo_operation.h" 19 #include "components/undo/undo_operation.h"
18 #include "grit/components_strings.h" 20 #include "grit/components_strings.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // Handles the undo of the deletion of a bookmark node. For a bookmark folder, 95 // Handles the undo of the deletion of a bookmark node. For a bookmark folder,
94 // the information for all descendant bookmark nodes is maintained. 96 // the information for all descendant bookmark nodes is maintained.
95 // 97 //
96 // The BookmarkModel allows only single bookmark node to be removed. 98 // The BookmarkModel allows only single bookmark node to be removed.
97 class BookmarkRemoveOperation : public BookmarkUndoOperation { 99 class BookmarkRemoveOperation : public BookmarkUndoOperation {
98 public: 100 public:
99 BookmarkRemoveOperation(BookmarkModel* model, 101 BookmarkRemoveOperation(BookmarkModel* model,
100 BookmarkUndoProvider* undo_provider, 102 BookmarkUndoProvider* undo_provider,
101 const BookmarkNode* parent, 103 const BookmarkNode* parent,
102 int index, 104 int index,
103 scoped_ptr<BookmarkNode> node); 105 std::unique_ptr<BookmarkNode> node);
104 ~BookmarkRemoveOperation() override; 106 ~BookmarkRemoveOperation() override;
105 107
106 // UndoOperation: 108 // UndoOperation:
107 void Undo() override; 109 void Undo() override;
108 int GetUndoLabelId() const override; 110 int GetUndoLabelId() const override;
109 int GetRedoLabelId() const override; 111 int GetRedoLabelId() const override;
110 112
111 private: 113 private:
112 BookmarkUndoProvider* undo_provider_; 114 BookmarkUndoProvider* undo_provider_;
113 const int64_t parent_node_id_; 115 const int64_t parent_node_id_;
114 const int index_; 116 const int index_;
115 scoped_ptr<BookmarkNode> node_; 117 std::unique_ptr<BookmarkNode> node_;
116 118
117 DISALLOW_COPY_AND_ASSIGN(BookmarkRemoveOperation); 119 DISALLOW_COPY_AND_ASSIGN(BookmarkRemoveOperation);
118 }; 120 };
119 121
120 BookmarkRemoveOperation::BookmarkRemoveOperation( 122 BookmarkRemoveOperation::BookmarkRemoveOperation(
121 BookmarkModel* model, 123 BookmarkModel* model,
122 BookmarkUndoProvider* undo_provider, 124 BookmarkUndoProvider* undo_provider,
123 const BookmarkNode* parent, 125 const BookmarkNode* parent,
124 int index, 126 int index,
125 scoped_ptr<BookmarkNode> node) 127 std::unique_ptr<BookmarkNode> node)
126 : BookmarkUndoOperation(model), 128 : BookmarkUndoOperation(model),
127 undo_provider_(undo_provider), 129 undo_provider_(undo_provider),
128 parent_node_id_(parent->id()), 130 parent_node_id_(parent->id()),
129 index_(index), 131 index_(index),
130 node_(std::move(node)) {} 132 node_(std::move(node)) {}
131 133
132 BookmarkRemoveOperation::~BookmarkRemoveOperation() { 134 BookmarkRemoveOperation::~BookmarkRemoveOperation() {
133 } 135 }
134 136
135 void BookmarkRemoveOperation::Undo() { 137 void BookmarkRemoveOperation::Undo() {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 359
358 void BookmarkUndoService::BookmarkModelBeingDeleted(BookmarkModel* model) { 360 void BookmarkUndoService::BookmarkModelBeingDeleted(BookmarkModel* model) {
359 undo_manager_.RemoveAllOperations(); 361 undo_manager_.RemoveAllOperations();
360 } 362 }
361 363
362 void BookmarkUndoService::BookmarkNodeMoved(BookmarkModel* model, 364 void BookmarkUndoService::BookmarkNodeMoved(BookmarkModel* model,
363 const BookmarkNode* old_parent, 365 const BookmarkNode* old_parent,
364 int old_index, 366 int old_index,
365 const BookmarkNode* new_parent, 367 const BookmarkNode* new_parent,
366 int new_index) { 368 int new_index) {
367 scoped_ptr<UndoOperation> op(new BookmarkMoveOperation( 369 std::unique_ptr<UndoOperation> op(new BookmarkMoveOperation(
368 model, old_parent, old_index, new_parent, new_index)); 370 model, old_parent, old_index, new_parent, new_index));
369 undo_manager()->AddUndoOperation(std::move(op)); 371 undo_manager()->AddUndoOperation(std::move(op));
370 } 372 }
371 373
372 void BookmarkUndoService::BookmarkNodeAdded(BookmarkModel* model, 374 void BookmarkUndoService::BookmarkNodeAdded(BookmarkModel* model,
373 const BookmarkNode* parent, 375 const BookmarkNode* parent,
374 int index) { 376 int index) {
375 scoped_ptr<UndoOperation> op( 377 std::unique_ptr<UndoOperation> op(
376 new BookmarkAddOperation(model, parent, index)); 378 new BookmarkAddOperation(model, parent, index));
377 undo_manager()->AddUndoOperation(std::move(op)); 379 undo_manager()->AddUndoOperation(std::move(op));
378 } 380 }
379 381
380 void BookmarkUndoService::OnWillChangeBookmarkNode(BookmarkModel* model, 382 void BookmarkUndoService::OnWillChangeBookmarkNode(BookmarkModel* model,
381 const BookmarkNode* node) { 383 const BookmarkNode* node) {
382 scoped_ptr<UndoOperation> op(new BookmarkEditOperation(model, node)); 384 std::unique_ptr<UndoOperation> op(new BookmarkEditOperation(model, node));
383 undo_manager()->AddUndoOperation(std::move(op)); 385 undo_manager()->AddUndoOperation(std::move(op));
384 } 386 }
385 387
386 void BookmarkUndoService::OnWillReorderBookmarkNode(BookmarkModel* model, 388 void BookmarkUndoService::OnWillReorderBookmarkNode(BookmarkModel* model,
387 const BookmarkNode* node) { 389 const BookmarkNode* node) {
388 scoped_ptr<UndoOperation> op(new BookmarkReorderOperation(model, node)); 390 std::unique_ptr<UndoOperation> op(new BookmarkReorderOperation(model, node));
389 undo_manager()->AddUndoOperation(std::move(op)); 391 undo_manager()->AddUndoOperation(std::move(op));
390 } 392 }
391 393
392 void BookmarkUndoService::GroupedBookmarkChangesBeginning( 394 void BookmarkUndoService::GroupedBookmarkChangesBeginning(
393 BookmarkModel* model) { 395 BookmarkModel* model) {
394 undo_manager()->StartGroupingActions(); 396 undo_manager()->StartGroupingActions();
395 } 397 }
396 398
397 void BookmarkUndoService::GroupedBookmarkChangesEnded(BookmarkModel* model) { 399 void BookmarkUndoService::GroupedBookmarkChangesEnded(BookmarkModel* model) {
398 undo_manager()->EndGroupingActions(); 400 undo_manager()->EndGroupingActions();
399 } 401 }
400 402
401 void BookmarkUndoService::SetUndoProvider(BookmarkUndoProvider* undo_provider) { 403 void BookmarkUndoService::SetUndoProvider(BookmarkUndoProvider* undo_provider) {
402 undo_provider_ = undo_provider; 404 undo_provider_ = undo_provider;
403 } 405 }
404 406
405 void BookmarkUndoService::OnBookmarkNodeRemoved(BookmarkModel* model, 407 void BookmarkUndoService::OnBookmarkNodeRemoved(
406 const BookmarkNode* parent, 408 BookmarkModel* model,
407 int index, 409 const BookmarkNode* parent,
408 scoped_ptr<BookmarkNode> node) { 410 int index,
411 std::unique_ptr<BookmarkNode> node) {
409 DCHECK(undo_provider_); 412 DCHECK(undo_provider_);
410 scoped_ptr<UndoOperation> op(new BookmarkRemoveOperation( 413 std::unique_ptr<UndoOperation> op(new BookmarkRemoveOperation(
411 model, undo_provider_, parent, index, std::move(node))); 414 model, undo_provider_, parent, index, std::move(node)));
412 undo_manager()->AddUndoOperation(std::move(op)); 415 undo_manager()->AddUndoOperation(std::move(op));
413 } 416 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698