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

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

Issue 10993064: Make using WebContentsUserData simpler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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/browser/ui/tab_contents/tab_contents.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents.h"
11 #include "chrome/common/chrome_notification_types.h" 11 #include "chrome/common/chrome_notification_types.h"
12 #include "chrome/common/extensions/extension_messages.h" 12 #include "chrome/common/extensions/extension_messages.h"
13 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
14 #include "content/public/browser/render_view_host.h" 14 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 16
17 int SessionTabHelper::kUserDataKey; 17 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SessionTabHelper)
18 18
19 SessionTabHelper::SessionTabHelper(content::WebContents* contents) 19 SessionTabHelper::SessionTabHelper(content::WebContents* contents)
20 : content::WebContentsObserver(contents) { 20 : content::WebContentsObserver(contents) {
21 } 21 }
22 22
23 SessionTabHelper::~SessionTabHelper() { 23 SessionTabHelper::~SessionTabHelper() {
24 } 24 }
25 25
26 void SessionTabHelper::SetWindowID(const SessionID& id) { 26 void SessionTabHelper::SetWindowID(const SessionID& id) {
27 window_id_ = id; 27 window_id_ = id;
(...skipping 14 matching lines...) Expand all
42 42
43 void SessionTabHelper::UserAgentOverrideSet(const std::string& user_agent) { 43 void SessionTabHelper::UserAgentOverrideSet(const std::string& user_agent) {
44 #if defined(ENABLE_SESSION_SERVICE) 44 #if defined(ENABLE_SESSION_SERVICE)
45 Profile* profile = 45 Profile* profile =
46 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 46 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
47 SessionService* session = SessionServiceFactory::GetForProfile(profile); 47 SessionService* session = SessionServiceFactory::GetForProfile(profile);
48 if (session) 48 if (session)
49 session->SetTabUserAgentOverride(window_id(), session_id(), user_agent); 49 session->SetTabUserAgentOverride(window_id(), session_id(), user_agent);
50 #endif 50 #endif
51 } 51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698