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

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

Issue 10917198: Switch NOTIFICATION_TAB_PARENTED to use WebContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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
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"
11 #include "chrome/common/chrome_notification_types.h" 10 #include "chrome/common/chrome_notification_types.h"
12 #include "chrome/common/extensions/extension_messages.h" 11 #include "chrome/common/extensions/extension_messages.h"
13 #include "content/public/browser/notification_service.h" 12 #include "content/public/browser/notification_service.h"
14 #include "content/public/browser/render_view_host.h" 13 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
16 15
17 int SessionTabHelper::kUserDataKey; 16 int SessionTabHelper::kUserDataKey;
18 17
19 SessionTabHelper::SessionTabHelper(content::WebContents* contents) 18 SessionTabHelper::SessionTabHelper(content::WebContents* contents)
20 : content::WebContentsObserver(contents) { 19 : content::WebContentsObserver(contents) {
21 } 20 }
22 21
23 SessionTabHelper::~SessionTabHelper() { 22 SessionTabHelper::~SessionTabHelper() {
24 } 23 }
25 24
26 void SessionTabHelper::SetWindowID(const SessionID& id) { 25 void SessionTabHelper::SetWindowID(const SessionID& id) {
27 window_id_ = id; 26 window_id_ = id;
28 27
29 // TODO(mpcomplete): Maybe this notification should send out a WebContents. 28 content::NotificationService::current()->Notify(
30 TabContents* tab = TabContents::FromWebContents(web_contents()); 29 chrome::NOTIFICATION_TAB_PARENTED,
31 if (tab) { 30 content::Source<content::WebContents>(web_contents()),
32 content::NotificationService::current()->Notify( 31 content::NotificationService::NoDetails());
33 chrome::NOTIFICATION_TAB_PARENTED,
34 content::Source<TabContents>(tab),
35 content::NotificationService::NoDetails());
36 }
37 32
38 // 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.
39 // Notify it that the window ID changed. 34 // Notify it that the window ID changed.
40 web_contents()->GetRenderViewHost()->Send( 35 web_contents()->GetRenderViewHost()->Send(
41 new ExtensionMsg_UpdateBrowserWindowId( 36 new ExtensionMsg_UpdateBrowserWindowId(
42 web_contents()->GetRenderViewHost()->GetRoutingID(), id.id())); 37 web_contents()->GetRenderViewHost()->GetRoutingID(), id.id()));
43 } 38 }
44 39
45 void SessionTabHelper::RenderViewCreated( 40 void SessionTabHelper::RenderViewCreated(
46 content::RenderViewHost* render_view_host) { 41 content::RenderViewHost* render_view_host) {
47 render_view_host->Send( 42 render_view_host->Send(
48 new ExtensionMsg_UpdateBrowserWindowId(render_view_host->GetRoutingID(), 43 new ExtensionMsg_UpdateBrowserWindowId(render_view_host->GetRoutingID(),
49 window_id_.id())); 44 window_id_.id()));
50 } 45 }
51 46
52 void SessionTabHelper::UserAgentOverrideSet(const std::string& user_agent) { 47 void SessionTabHelper::UserAgentOverrideSet(const std::string& user_agent) {
53 #if defined(ENABLE_SESSION_SERVICE) 48 #if defined(ENABLE_SESSION_SERVICE)
54 Profile* profile = 49 Profile* profile =
55 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 50 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
56 SessionService* session = SessionServiceFactory::GetForProfile(profile); 51 SessionService* session = SessionServiceFactory::GetForProfile(profile);
57 if (session) 52 if (session)
58 session->SetTabUserAgentOverride(window_id(), session_id(), user_agent); 53 session->SetTabUserAgentOverride(window_id(), session_id(), user_agent);
59 #endif 54 #endif
60 } 55 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_service.cc ('k') | chrome/browser/sync/glue/session_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698