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

Side by Side Diff: ios/chrome/browser/web/sad_tab_tab_helper.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #import "ios/chrome/browser/web/sad_tab_tab_helper.h" 5 #import "ios/chrome/browser/web/sad_tab_tab_helper.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/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
10 #import "ios/chrome/browser/ui/sad_tab/sad_tab_view.h" 11 #import "ios/chrome/browser/ui/sad_tab/sad_tab_view.h"
11 #import "ios/chrome/browser/web/sad_tab_tab_helper_delegate.h" 12 #import "ios/chrome/browser/web/sad_tab_tab_helper_delegate.h"
12 #import "ios/web/public/navigation_manager.h" 13 #import "ios/web/public/navigation_manager.h"
13 #import "ios/web/public/web_state/ui/crw_generic_content_view.h" 14 #import "ios/web/public/web_state/ui/crw_generic_content_view.h"
14 15
15 #if !defined(__has_feature) || !__has_feature(objc_arc) 16 #if !defined(__has_feature) || !__has_feature(objc_arc)
16 #error "This file requires ARC support." 17 #error "This file requires ARC support."
17 #endif 18 #endif
18 19
19 DEFINE_WEB_STATE_USER_DATA_KEY(SadTabTabHelper); 20 DEFINE_WEB_STATE_USER_DATA_KEY(SadTabTabHelper);
20 21
21 SadTabTabHelper::SadTabTabHelper(web::WebState* web_state, 22 SadTabTabHelper::SadTabTabHelper(web::WebState* web_state,
22 id<SadTabTabHelperDelegate> delegate) 23 id<SadTabTabHelperDelegate> delegate)
23 : web::WebStateObserver(web_state), delegate_(delegate) { 24 : web::WebStateObserver(web_state), delegate_(delegate) {
24 DCHECK(delegate_); 25 DCHECK(delegate_);
25 } 26 }
26 27
27 SadTabTabHelper::~SadTabTabHelper() = default; 28 SadTabTabHelper::~SadTabTabHelper() = default;
28 29
29 void SadTabTabHelper::CreateForWebState(web::WebState* web_state, 30 void SadTabTabHelper::CreateForWebState(web::WebState* web_state,
30 id<SadTabTabHelperDelegate> delegate) { 31 id<SadTabTabHelperDelegate> delegate) {
31 DCHECK(web_state); 32 DCHECK(web_state);
32 if (!FromWebState(web_state)) { 33 if (!FromWebState(web_state)) {
33 web_state->SetUserData(UserDataKey(), 34 web_state->SetUserData(UserDataKey(), base::WrapUnique(new SadTabTabHelper(
34 new SadTabTabHelper(web_state, delegate)); 35 web_state, delegate)));
35 } 36 }
36 } 37 }
37 38
38 void SadTabTabHelper::RenderProcessGone() { 39 void SadTabTabHelper::RenderProcessGone() {
39 if (!delegate_ || [delegate_ isTabVisibleForTabHelper:this]) { 40 if (!delegate_ || [delegate_ isTabVisibleForTabHelper:this]) {
40 PresentSadTab(); 41 PresentSadTab();
41 } 42 }
42 } 43 }
43 44
44 void SadTabTabHelper::PresentSadTab() { 45 void SadTabTabHelper::PresentSadTab() {
45 SadTabView* sad_tab_view = [[SadTabView alloc] initWithReloadHandler:^{ 46 SadTabView* sad_tab_view = [[SadTabView alloc] initWithReloadHandler:^{
46 web_state()->GetNavigationManager()->Reload(web::ReloadType::NORMAL, true); 47 web_state()->GetNavigationManager()->Reload(web::ReloadType::NORMAL, true);
47 }]; 48 }];
48 49
49 CRWContentView* content_view = 50 CRWContentView* content_view =
50 [[CRWGenericContentView alloc] initWithView:sad_tab_view]; 51 [[CRWGenericContentView alloc] initWithView:sad_tab_view];
51 52
52 web_state()->ShowTransientContentView(content_view); 53 web_state()->ShowTransientContentView(content_view);
53 } 54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698