1 // Copyright (c) 2011 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.
5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_TAB_HELPER_H_
6 #define CHROME_BROWSER_SESSIONS_SESSION_TAB_HELPER_H_
8 #include "base/basictypes.h"
9 #include "chrome/browser/sessions/session_id.h"
10 #include "content/public/browser/web_contents_observer.h"
11 #include "content/public/browser/web_contents_user_data.h"
13 // This class keeps the extension API's windowID up-to-date with the current
15 class SessionTabHelper
: public content::WebContentsObserver
,
16 public content::WebContentsUserData
<SessionTabHelper
> {
18 virtual ~SessionTabHelper();
20 // Returns the identifier used by session restore for this tab.
21 const SessionID
& session_id() const { return session_id_
; }
23 // Identifier of the window the tab is in.
24 void SetWindowID(const SessionID
& id
);
25 const SessionID
& window_id() const { return window_id_
; }
27 // content::WebContentsObserver:
28 virtual void RenderViewCreated(
29 content::RenderViewHost
* render_view_host
) OVERRIDE
;
30 virtual void UserAgentOverrideSet(const std::string
& user_agent
) OVERRIDE
;
33 explicit SessionTabHelper(content::WebContents
* contents
);
34 friend class content::WebContentsUserData
<SessionTabHelper
>;
36 // Unique identifier of the tab for session restore. This id is only unique
37 // within the current session, and is not guaranteed to be unique across
39 const SessionID session_id_
;
41 // Unique identifier of the window the tab is in.
44 DISALLOW_COPY_AND_ASSIGN(SessionTabHelper
);
47 #endif // CHROME_BROWSER_SESSIONS_SESSION_TAB_HELPER_H_