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

Unified Diff: ios/chrome/browser/tabs/legacy_tab_helper.h

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/BUILD.gn ('k') | ios/chrome/browser/tabs/legacy_tab_helper.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.h
diff --git a/ios/chrome/browser/tabs/legacy_tab_helper.h b/ios/chrome/browser/tabs/legacy_tab_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..0ede4ffd921422d91d3f8db1ac8b7cdc4585d967
--- /dev/null
+++ b/ios/chrome/browser/tabs/legacy_tab_helper.h
@@ -0,0 +1,38 @@
+// 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.
+
+#ifndef IOS_CHROME_BROWSER_TABS_LEGACY_TAB_HELPER_H_
+#define IOS_CHROME_BROWSER_TABS_LEGACY_TAB_HELPER_H_
+
+#import "base/ios/weak_nsobject.h"
+#include "base/macros.h"
+#import "ios/web/public/web_state/web_state_user_data.h"
+
+@class Tab;
+
+// LegacyTabHelper allows to access to the Tab owning a given WebState for
+// interoperability of code using WebStates with legacy code using Tabs.
+class LegacyTabHelper : public web::WebStateUserData<LegacyTabHelper> {
+ public:
+ // Creates the LegacyTabHelper to record the association of |web_state|
+ // with |tab|. It is an error if |web_state| is already associated with
+ // another Tab.
+ static void CreateForWebState(web::WebState* web_state, Tab* tab);
+
+ // Returns the Tab associated with |web_state| if it exists or nil.
+ static Tab* GetTabForWebState(web::WebState* web_state);
+
+ private:
+ LegacyTabHelper(web::WebState* web_state, Tab* tab);
+ ~LegacyTabHelper() override;
+
+ // The Tab instance associated with the WebState. The Tab currently owns
+ // the WebState, so this should only be nil between the call to -[Tab close]
+ // and the object is deallocated.
+ base::WeakNSObject<Tab> tab_;
+
+ DISALLOW_COPY_AND_ASSIGN(LegacyTabHelper);
+};
+
+#endif // IOS_CHROME_BROWSER_TABS_LEGACY_TAB_HELPER_H_
« no previous file with comments | « ios/chrome/browser/tabs/BUILD.gn ('k') | ios/chrome/browser/tabs/legacy_tab_helper.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698