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

Side by Side Diff: ios/chrome/browser/web/sad_tab_tab_helper.mm

Issue 2807843002: Refactor creation of SadTabView into a tab helper object (Closed)
Patch Set: Attempt to fix build dependency Created 3 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/chrome/browser/web/sad_tab_tab_helper.h"
6
7 #import <Foundation/Foundation.h>
8
9 #include "base/strings/sys_string_conversions.h"
10 #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/web/public/navigation_manager.h"
13 #import "ios/web/public/web_state/ui/crw_generic_content_view.h"
14
15 #if !defined(__has_feature) || !__has_feature(objc_arc)
16 #error "This file requires ARC support."
17 #endif
18
19 DEFINE_WEB_STATE_USER_DATA_KEY(SadTabTabHelper);
20
21 SadTabTabHelper::SadTabTabHelper(web::WebState* web_state,
22 id<SadTabTabHelperDelegate> delegate)
23 : web::WebStateObserver(web_state), delegate_(delegate) {
24 DCHECK(delegate_);
25 }
26
27 SadTabTabHelper::~SadTabTabHelper() = default;
28
29 void SadTabTabHelper::CreateForWebState(web::WebState* web_state,
30 id<SadTabTabHelperDelegate> delegate) {
31 DCHECK(web_state);
32 if (!FromWebState(web_state)) {
33 web_state->SetUserData(UserDataKey(),
34 new SadTabTabHelper(web_state, delegate));
35 }
36 }
37
38 void SadTabTabHelper::RenderProcessGone() {
39 if (!delegate_ || [delegate_ isTabVisibleForTabHelper:this]) {
40 PresentSadTab();
41 }
42 }
43
44 void SadTabTabHelper::PresentSadTab() {
45 SadTabView* sad_tab_view = [[SadTabView alloc] initWithReloadHandler:^{
46 web_state()->GetNavigationManager()->Reload(web::ReloadType::NORMAL, true);
47 }];
48
49 CRWContentView* content_view =
50 [[CRWGenericContentView alloc] initWithView:sad_tab_view];
51
52 web_state()->ShowTransientContentView(content_view);
53 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/web/sad_tab_tab_helper.h ('k') | ios/chrome/browser/web/sad_tab_tab_helper_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698