| OLD | NEW |
| (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 #ifndef IOS_CHROME_BROWSER_TABS_LEGACY_TAB_HELPER_H_ |
| 6 #define IOS_CHROME_BROWSER_TABS_LEGACY_TAB_HELPER_H_ |
| 7 |
| 8 #import "base/ios/weak_nsobject.h" |
| 9 #include "base/macros.h" |
| 10 #import "ios/web/public/web_state/web_state_user_data.h" |
| 11 |
| 12 @class Tab; |
| 13 |
| 14 // LegacyTabHelper allows to access to the Tab owning a given WebState for |
| 15 // interoperability of code using WebStates with legacy code using Tabs. |
| 16 class LegacyTabHelper : public web::WebStateUserData<LegacyTabHelper> { |
| 17 public: |
| 18 // Creates the LegacyTabHelper to record the association of |web_state| |
| 19 // with |tab|. It is an error if |web_state| is already associated with |
| 20 // another Tab. |
| 21 static void CreateForWebState(web::WebState* web_state, Tab* tab); |
| 22 |
| 23 // Returns the Tab associated with |web_state| if it exists or nil. |
| 24 static Tab* GetTabForWebState(web::WebState* web_state); |
| 25 |
| 26 private: |
| 27 LegacyTabHelper(web::WebState* web_state, Tab* tab); |
| 28 ~LegacyTabHelper() override; |
| 29 |
| 30 // The Tab instance associated with the WebState. The Tab currently owns |
| 31 // the WebState, so this should only be nil between the call to -[Tab close] |
| 32 // and the object is deallocated. |
| 33 base::WeakNSObject<Tab> tab_; |
| 34 |
| 35 DISALLOW_COPY_AND_ASSIGN(LegacyTabHelper); |
| 36 }; |
| 37 |
| 38 #endif // IOS_CHROME_BROWSER_TABS_LEGACY_TAB_HELPER_H_ |
| OLD | NEW |