| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/restore_tab_helper.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 8 #include "chrome/common/extensions/extension_messages.h" | 8 #include "chrome/common/extensions/extension_messages.h" |
| 9 #include "content/browser/renderer_host/render_view_host.h" | 9 #include "content/browser/renderer_host/render_view_host.h" |
| 10 #include "content/browser/tab_contents/tab_contents.h" | |
| 11 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
| 12 #include "content/public/browser/notification_types.h" | 11 #include "content/public/browser/notification_types.h" |
| 12 #include "content/public/browser/web_contents.h" |
| 13 | 13 |
| 14 RestoreTabHelper::RestoreTabHelper(TabContents* contents) | 14 using content::WebContents; |
| 15 : content::WebContentsObserver(contents), | 15 |
| 16 contents_(contents) { | 16 RestoreTabHelper::RestoreTabHelper(WebContents* contents) |
| 17 : content::WebContentsObserver(contents) { |
| 17 } | 18 } |
| 18 | 19 |
| 19 RestoreTabHelper::~RestoreTabHelper() { | 20 RestoreTabHelper::~RestoreTabHelper() { |
| 20 } | 21 } |
| 21 | 22 |
| 22 void RestoreTabHelper::SetWindowID(const SessionID& id) { | 23 void RestoreTabHelper::SetWindowID(const SessionID& id) { |
| 23 window_id_ = id; | 24 window_id_ = id; |
| 24 | 25 |
| 25 // TODO(mpcomplete): Maybe this notification should send out a TabContents. | 26 // TODO(mpcomplete): Maybe this notification should send out a TabContents. |
| 26 TabContentsWrapper* tab = | 27 TabContentsWrapper* tab = |
| 27 TabContentsWrapper::GetCurrentWrapperForContents(contents_); | 28 TabContentsWrapper::GetCurrentWrapperForContents(web_contents()); |
| 28 if (tab) { | 29 if (tab) { |
| 29 content::NotificationService::current()->Notify( | 30 content::NotificationService::current()->Notify( |
| 30 content::NOTIFICATION_TAB_PARENTED, | 31 content::NOTIFICATION_TAB_PARENTED, |
| 31 content::Source<TabContentsWrapper>(tab), | 32 content::Source<TabContentsWrapper>(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 contents_->GetRenderViewHost()->Send( | 38 web_contents()->GetRenderViewHost()->Send( |
| 38 new ExtensionMsg_UpdateBrowserWindowId( | 39 new ExtensionMsg_UpdateBrowserWindowId( |
| 39 contents_->GetRenderViewHost()->routing_id(), id.id())); | 40 web_contents()->GetRenderViewHost()->routing_id(), id.id())); |
| 40 } | 41 } |
| 41 | 42 |
| 42 void RestoreTabHelper::RenderViewCreated(RenderViewHost* render_view_host) { | 43 void RestoreTabHelper::RenderViewCreated(RenderViewHost* render_view_host) { |
| 43 render_view_host->Send( | 44 render_view_host->Send( |
| 44 new ExtensionMsg_UpdateBrowserWindowId(render_view_host->routing_id(), | 45 new ExtensionMsg_UpdateBrowserWindowId(render_view_host->routing_id(), |
| 45 window_id_.id())); | 46 window_id_.id())); |
| 46 } | 47 } |
| OLD | NEW |