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

Side by Side Diff: chrome/browser/sessions/session_tab_helper.cc

Issue 15055003: Do not submit: high level overview patch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build. Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sessions/session_tab_helper.h" 5 #include "chrome/browser/sessions/session_tab_helper.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/sessions/session_service.h" 8 #include "chrome/browser/sessions/session_service.h"
9 #include "chrome/browser/sessions/session_service_factory.h" 9 #include "chrome/browser/sessions/session_service_factory.h"
10 #include "chrome/common/chrome_notification_types.h" 10 #include "chrome/common/chrome_notification_types.h"
11 #include "chrome/common/extensions/extension_messages.h" 11 #include "chrome/common/extensions/extension_messages.h"
12 #include "content/public/browser/notification_service.h" 12 #include "content/public/browser/notification_service.h"
13 #include "content/public/browser/render_view_host.h" 13 #include "content/public/browser/render_view_host.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 15
16 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SessionTabHelper); 16 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SessionTabHelper);
17 17
18 SessionTabHelper::SessionTabHelper(content::WebContents* contents) 18 SessionTabHelper::SessionTabHelper(content::WebContents* contents)
19 : content::WebContentsObserver(contents) { 19 : content::WebContentsObserver(contents), sync_session_id_(-1) {}
20 } 20 void SessionTabHelper::SetSessionId(const SessionID& id) { session_id_ = id; }
21 21
22 SessionTabHelper::~SessionTabHelper() { 22 SessionTabHelper::~SessionTabHelper() {
23 } 23 }
24 void SessionTabHelper::SetSessionSyncId(const int64 sync_id) {
25
26 DCHECK(sync_id >= -1);
27 sync_session_id_ = sync_id;
28 }
24 29
25 void SessionTabHelper::SetWindowID(const SessionID& id) { 30 void SessionTabHelper::SetWindowID(const SessionID& id) {
26 window_id_ = id; 31 window_id_ = id;
27 32
28 // Extension code in the renderer holds the ID of the window that hosts it. 33 // Extension code in the renderer holds the ID of the window that hosts it.
29 // Notify it that the window ID changed. 34 // Notify it that the window ID changed.
30 web_contents()->GetRenderViewHost()->Send( 35 web_contents()->GetRenderViewHost()->Send(
31 new ExtensionMsg_UpdateBrowserWindowId( 36 new ExtensionMsg_UpdateBrowserWindowId(
32 web_contents()->GetRenderViewHost()->GetRoutingID(), id.id())); 37 web_contents()->GetRenderViewHost()->GetRoutingID(), id.id()));
33 } 38 }
34 39
35 void SessionTabHelper::RenderViewCreated( 40 void SessionTabHelper::RenderViewCreated(
36 content::RenderViewHost* render_view_host) { 41 content::RenderViewHost* render_view_host) {
37 render_view_host->Send( 42 render_view_host->Send(
38 new ExtensionMsg_UpdateBrowserWindowId(render_view_host->GetRoutingID(), 43 new ExtensionMsg_UpdateBrowserWindowId(render_view_host->GetRoutingID(),
39 window_id_.id())); 44 window_id_.id()));
40 } 45 }
41 46
42 void SessionTabHelper::UserAgentOverrideSet(const std::string& user_agent) { 47 void SessionTabHelper::UserAgentOverrideSet(const std::string& user_agent) {
43 #if defined(ENABLE_SESSION_SERVICE) 48 #if defined(ENABLE_SESSION_SERVICE)
44 Profile* profile = 49 Profile* profile =
45 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 50 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
46 SessionService* session = SessionServiceFactory::GetForProfile(profile); 51 SessionService* session = SessionServiceFactory::GetForProfile(profile);
47 if (session) 52 if (session)
48 session->SetTabUserAgentOverride(window_id(), session_id(), user_agent); 53 session->SetTabUserAgentOverride(window_id(), session_id(), user_agent);
49 #endif 54 #endif
50 } 55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698