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

Side by Side Diff: ios/chrome/browser/tabs/legacy_tab_helper.mm

Issue 2681843002: Add mechanism to get the Tab from the associated WebState. (Closed)
Patch Set: Address comments. Created 3 years, 10 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
« no previous file with comments | « ios/chrome/browser/tabs/legacy_tab_helper.h ('k') | ios/chrome/browser/tabs/tab.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/tabs/legacy_tab_helper.h"
6
7 #import "ios/chrome/browser/tabs/tab.h"
8
9 #if !defined(__has_feature) || !__has_feature(objc_arc)
10 #error "This file requires ARC support."
11 #endif
12
13 DEFINE_WEB_STATE_USER_DATA_KEY(LegacyTabHelper);
14
15 // static
16 void LegacyTabHelper::CreateForWebState(web::WebState* web_state, Tab* tab) {
17 DCHECK(web_state);
18 DCHECK(!FromWebState(web_state));
19 web_state->SetUserData(UserDataKey(), new LegacyTabHelper(web_state, tab));
20 }
21
22 // static
23 Tab* LegacyTabHelper::GetTabForWebState(web::WebState* web_state) {
24 DCHECK(web_state);
25 LegacyTabHelper* tab_helper = LegacyTabHelper::FromWebState(web_state);
26 return tab_helper ? tab_helper->tab_.get() : nil;
27 }
28
29 LegacyTabHelper::~LegacyTabHelper() = default;
30
31 LegacyTabHelper::LegacyTabHelper(web::WebState* web_state, Tab* tab)
32 : tab_(tab) {
33 DCHECK_EQ(web_state, tab.webState);
34 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/legacy_tab_helper.h ('k') | ios/chrome/browser/tabs/tab.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698