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

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

Issue 10891044: RestoreTabHelper > SessionTabHelper, move more session stuff into it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
« no previous file with comments | « chrome/browser/sessions/session_tab_helper.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/restore_tab_helper.h" 5 #include "chrome/browser/sessions/session_tab_helper.h"
6 6
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/sessions/session_service.h"
9 #include "chrome/browser/sessions/session_service_factory.h"
7 #include "chrome/browser/ui/tab_contents/tab_contents.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents.h"
8 #include "chrome/common/chrome_notification_types.h" 11 #include "chrome/common/chrome_notification_types.h"
9 #include "chrome/common/extensions/extension_messages.h" 12 #include "chrome/common/extensions/extension_messages.h"
10 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
11 #include "content/public/browser/render_view_host.h" 14 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
13 16
14 using content::WebContents; 17 SessionTabHelper::SessionTabHelper(content::WebContents* contents)
15
16 RestoreTabHelper::RestoreTabHelper(WebContents* contents)
17 : content::WebContentsObserver(contents) { 18 : content::WebContentsObserver(contents) {
18 } 19 }
19 20
20 RestoreTabHelper::~RestoreTabHelper() { 21 SessionTabHelper::~SessionTabHelper() {
21 } 22 }
22 23
23 void RestoreTabHelper::SetWindowID(const SessionID& id) { 24 void SessionTabHelper::SetWindowID(const SessionID& id) {
24 window_id_ = id; 25 window_id_ = id;
25 26
26 // TODO(mpcomplete): Maybe this notification should send out a WebContents. 27 // TODO(mpcomplete): Maybe this notification should send out a WebContents.
27 TabContents* tab = TabContents::FromWebContents(web_contents()); 28 TabContents* tab = TabContents::FromWebContents(web_contents());
28 if (tab) { 29 if (tab) {
29 content::NotificationService::current()->Notify( 30 content::NotificationService::current()->Notify(
30 chrome::NOTIFICATION_TAB_PARENTED, 31 chrome::NOTIFICATION_TAB_PARENTED,
31 content::Source<TabContents>(tab), 32 content::Source<TabContents>(tab),
32 content::NotificationService::NoDetails()); 33 content::NotificationService::NoDetails());
33 } 34 }
34 35
35 // Extension code in the renderer holds the ID of the window that hosts it. 36 // Extension code in the renderer holds the ID of the window that hosts it.
36 // Notify it that the window ID changed. 37 // Notify it that the window ID changed.
37 web_contents()->GetRenderViewHost()->Send( 38 web_contents()->GetRenderViewHost()->Send(
38 new ExtensionMsg_UpdateBrowserWindowId( 39 new ExtensionMsg_UpdateBrowserWindowId(
39 web_contents()->GetRenderViewHost()->GetRoutingID(), id.id())); 40 web_contents()->GetRenderViewHost()->GetRoutingID(), id.id()));
40 } 41 }
41 42
42 void RestoreTabHelper::RenderViewCreated( 43 void SessionTabHelper::RenderViewCreated(
43 content::RenderViewHost* render_view_host) { 44 content::RenderViewHost* render_view_host) {
44 render_view_host->Send( 45 render_view_host->Send(
45 new ExtensionMsg_UpdateBrowserWindowId(render_view_host->GetRoutingID(), 46 new ExtensionMsg_UpdateBrowserWindowId(render_view_host->GetRoutingID(),
46 window_id_.id())); 47 window_id_.id()));
47 } 48 }
49
50 void SessionTabHelper::UserAgentOverrideSet(const std::string& user_agent) {
51 #if defined(ENABLE_SESSION_SERVICE)
52 Profile* profile =
53 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
54 SessionService* session = SessionServiceFactory::GetForProfile(profile);
55 if (session)
56 session->SetTabUserAgentOverride(window_id(), session_id(), user_agent);
57 #endif
58 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_tab_helper.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698