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

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

Issue 559523004: Cleanup: Remove unneeded extension_messages.h usage and ifdef out some extensions code usage when e… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 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
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/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/sessions/session_service.h" 9 #include "chrome/browser/sessions/session_service.h"
10 #include "chrome/browser/sessions/session_service_factory.h" 10 #include "chrome/browser/sessions/session_service_factory.h"
11 #include "content/public/browser/notification_service.h" 11 #include "content/public/browser/notification_service.h"
12 #include "content/public/browser/render_view_host.h" 12 #include "content/public/browser/render_view_host.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14
15 #if defined(ENABLE_EXTENSIONS)
14 #include "extensions/common/extension_messages.h" 16 #include "extensions/common/extension_messages.h"
17 #endif
15 18
16 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SessionTabHelper); 19 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SessionTabHelper);
17 20
18 SessionTabHelper::SessionTabHelper(content::WebContents* contents) 21 SessionTabHelper::SessionTabHelper(content::WebContents* contents)
19 : content::WebContentsObserver(contents) { 22 : content::WebContentsObserver(contents) {
20 } 23 }
21 24
22 SessionTabHelper::~SessionTabHelper() { 25 SessionTabHelper::~SessionTabHelper() {
23 } 26 }
24 27
25 void SessionTabHelper::SetWindowID(const SessionID& id) { 28 void SessionTabHelper::SetWindowID(const SessionID& id) {
26 window_id_ = id; 29 window_id_ = id;
27 30
31 #if defined(ENABLE_EXTENSIONS)
28 // Extension code in the renderer holds the ID of the window that hosts it. 32 // Extension code in the renderer holds the ID of the window that hosts it.
29 // Notify it that the window ID changed. 33 // Notify it that the window ID changed.
30 web_contents()->GetRenderViewHost()->Send( 34 web_contents()->GetRenderViewHost()->Send(
31 new ExtensionMsg_UpdateBrowserWindowId( 35 new ExtensionMsg_UpdateBrowserWindowId(
32 web_contents()->GetRenderViewHost()->GetRoutingID(), id.id())); 36 web_contents()->GetRenderViewHost()->GetRoutingID(), id.id()));
37 #endif
33 } 38 }
34 39
35 // static 40 // static
36 SessionID::id_type SessionTabHelper::IdForTab(const content::WebContents* tab) { 41 SessionID::id_type SessionTabHelper::IdForTab(const content::WebContents* tab) {
37 const SessionTabHelper* session_tab_helper = 42 const SessionTabHelper* session_tab_helper =
38 tab ? SessionTabHelper::FromWebContents(tab) : NULL; 43 tab ? SessionTabHelper::FromWebContents(tab) : NULL;
39 return session_tab_helper ? session_tab_helper->session_id().id() : -1; 44 return session_tab_helper ? session_tab_helper->session_id().id() : -1;
40 } 45 }
41 46
42 // static 47 // static
43 SessionID::id_type SessionTabHelper::IdForWindowContainingTab( 48 SessionID::id_type SessionTabHelper::IdForWindowContainingTab(
44 const content::WebContents* tab) { 49 const content::WebContents* tab) {
45 const SessionTabHelper* session_tab_helper = 50 const SessionTabHelper* session_tab_helper =
46 tab ? SessionTabHelper::FromWebContents(tab) : NULL; 51 tab ? SessionTabHelper::FromWebContents(tab) : NULL;
47 return session_tab_helper ? session_tab_helper->window_id().id() : -1; 52 return session_tab_helper ? session_tab_helper->window_id().id() : -1;
48 } 53 }
49 54
55 #if defined(ENABLE_EXTENSIONS)
50 void SessionTabHelper::RenderViewCreated( 56 void SessionTabHelper::RenderViewCreated(
51 content::RenderViewHost* render_view_host) { 57 content::RenderViewHost* render_view_host) {
52 render_view_host->Send( 58 render_view_host->Send(
53 new ExtensionMsg_UpdateBrowserWindowId(render_view_host->GetRoutingID(), 59 new ExtensionMsg_UpdateBrowserWindowId(render_view_host->GetRoutingID(),
54 window_id_.id())); 60 window_id_.id()));
55 } 61 }
62 #endif
56 63
57 void SessionTabHelper::UserAgentOverrideSet(const std::string& user_agent) { 64 void SessionTabHelper::UserAgentOverrideSet(const std::string& user_agent) {
58 #if defined(ENABLE_SESSION_SERVICE) 65 #if defined(ENABLE_SESSION_SERVICE)
59 Profile* profile = 66 Profile* profile =
60 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 67 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
61 SessionService* session = SessionServiceFactory::GetForProfile(profile); 68 SessionService* session = SessionServiceFactory::GetForProfile(profile);
62 if (session) 69 if (session)
63 session->SetTabUserAgentOverride(window_id(), session_id(), user_agent); 70 session->SetTabUserAgentOverride(window_id(), session_id(), user_agent);
64 #endif 71 #endif
65 } 72 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_tab_helper.h ('k') | chrome/browser/themes/theme_syncable_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698