summaryrefslogtreecommitdiffstats
path: root/ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h
blob: d6f6f355d195df2c32e59dee0917874d28f9ab19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2015 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_SESSIONS_IOS_CHROME_SESSION_TAB_HELPER_H_
#define IOS_CHROME_BROWSER_SESSIONS_IOS_CHROME_SESSION_TAB_HELPER_H_

#include "base/macros.h"
#include "components/sessions/core/session_id.h"
#include "ios/web/public/web_state/web_state_user_data.h"

class IOSChromeSessionTabHelper
    : public web::WebStateUserData<IOSChromeSessionTabHelper> {
 public:
  ~IOSChromeSessionTabHelper() override;

  // Returns the identifier used by session restore for this tab.
  const SessionID& session_id() const { return session_id_; }

  // Identifier of the window the tab is in.
  void SetWindowID(const SessionID& id);
  const SessionID& window_id() const { return window_id_; }

 private:
  explicit IOSChromeSessionTabHelper(web::WebState* web_state);
  friend class web::WebStateUserData<IOSChromeSessionTabHelper>;

  // Unique identifier of the tab for session restore. This id is only unique
  // within the current session, and is not guaranteed to be unique across
  // sessions.
  const SessionID session_id_;

  // Unique identifier of the window the tab is in.
  SessionID window_id_;

  DISALLOW_COPY_AND_ASSIGN(IOSChromeSessionTabHelper);
};

#endif  // IOS_CHROME_BROWSER_SESSIONS_IOS_CHROME_SESSION_TAB_HELPER_H_