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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/tabs/legacy_tab_helper.mm
diff --git a/ios/chrome/browser/tabs/legacy_tab_helper.mm b/ios/chrome/browser/tabs/legacy_tab_helper.mm
new file mode 100644
index 0000000000000000000000000000000000000000..476e916fa40fa850579f75db09102ba3cd0f4a08
--- /dev/null
+++ b/ios/chrome/browser/tabs/legacy_tab_helper.mm
@@ -0,0 +1,34 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/browser/tabs/legacy_tab_helper.h"
+
+#import "ios/chrome/browser/tabs/tab.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+DEFINE_WEB_STATE_USER_DATA_KEY(LegacyTabHelper);
+
+// static
+void LegacyTabHelper::CreateForWebState(web::WebState* web_state, Tab* tab) {
+ DCHECK(web_state);
+ DCHECK(!FromWebState(web_state));
+ web_state->SetUserData(UserDataKey(), new LegacyTabHelper(web_state, tab));
+}
+
+// static
+Tab* LegacyTabHelper::GetTabForWebState(web::WebState* web_state) {
+ DCHECK(web_state);
+ LegacyTabHelper* tab_helper = LegacyTabHelper::FromWebState(web_state);
+ return tab_helper ? tab_helper->tab_.get() : nil;
+}
+
+LegacyTabHelper::~LegacyTabHelper() = default;
+
+LegacyTabHelper::LegacyTabHelper(web::WebState* web_state, Tab* tab)
+ : tab_(tab) {
+ DCHECK_EQ(web_state, tab.webState);
+}
« 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