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

Side by Side Diff: ios/chrome/browser/reading_list/reading_list_web_state_observer.mm

Issue 2853443002: Switch SupportsUserData uses to use unique_ptr. (Closed)
Patch Set: Created 3 years, 7 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/reading_list/reading_list_web_state_observer.h" 5 #include "ios/chrome/browser/reading_list/reading_list_web_state_observer.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 29 matching lines...) Expand all
40 ReadingListModel* reading_list_model) { 40 ReadingListModel* reading_list_model) {
41 DCHECK(web_state); 41 DCHECK(web_state);
42 ReadingListWebStateObserverUserDataWrapper* wrapper = 42 ReadingListWebStateObserverUserDataWrapper* wrapper =
43 static_cast<ReadingListWebStateObserverUserDataWrapper*>( 43 static_cast<ReadingListWebStateObserverUserDataWrapper*>(
44 web_state->GetUserData(kObserverKey)); 44 web_state->GetUserData(kObserverKey));
45 if (!wrapper) { 45 if (!wrapper) {
46 auto newDataWrapper = 46 auto newDataWrapper =
47 base::MakeUnique<ReadingListWebStateObserverUserDataWrapper>( 47 base::MakeUnique<ReadingListWebStateObserverUserDataWrapper>(
48 web_state, reading_list_model); 48 web_state, reading_list_model);
49 wrapper = newDataWrapper.get(); 49 wrapper = newDataWrapper.get();
50 web_state->SetUserData(kObserverKey, newDataWrapper.release()); 50 web_state->SetUserData(kObserverKey, std::move(newDataWrapper));
51 } 51 }
52 return wrapper; 52 return wrapper;
53 } 53 }
54 54
55 ReadingListWebStateObserverUserDataWrapper( 55 ReadingListWebStateObserverUserDataWrapper(
56 web::WebState* web_state, 56 web::WebState* web_state,
57 ReadingListModel* reading_list_model) 57 ReadingListModel* reading_list_model)
58 : observer_(web_state, reading_list_model) { 58 : observer_(web_state, reading_list_model) {
59 DCHECK(web_state); 59 DCHECK(web_state);
60 } 60 }
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 // on next navigation. 321 // on next navigation.
322 // Trigger a new navigation on the offline URL. 322 // Trigger a new navigation on the offline URL.
323 web::WebState::OpenURLParams params(url, item->GetReferrer(), 323 web::WebState::OpenURLParams params(url, item->GetReferrer(),
324 WindowOpenDisposition::CURRENT_TAB, 324 WindowOpenDisposition::CURRENT_TAB,
325 item->GetTransitionType(), NO); 325 item->GetTransitionType(), NO);
326 web_state()->OpenURL(params); 326 web_state()->OpenURL(params);
327 } 327 }
328 reading_list_model_->SetReadStatus(entry->URL(), true); 328 reading_list_model_->SetReadStatus(entry->URL(), true);
329 UMA_HISTOGRAM_BOOLEAN("ReadingList.OfflineVersionDisplayed", true); 329 UMA_HISTOGRAM_BOOLEAN("ReadingList.OfflineVersionDisplayed", true);
330 } 330 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698