| 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 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" | 5 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_nsobject.h" | 7 #include "base/memory/scoped_nsobject.h" |
| 8 #include "content/browser/renderer_host/render_view_host.h" | 8 #include "content/browser/renderer_host/render_view_host.h" |
| 9 #include "content/browser/renderer_host/render_widget_host_view.h" | 9 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 10 #include "content/browser/tab_contents/navigation_controller.h" | 10 #include "content/browser/tab_contents/navigation_controller.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 TabContentsNotificationBridge::TabContentsNotificationBridge( | 44 TabContentsNotificationBridge::TabContentsNotificationBridge( |
| 45 TabContentsController* controller) | 45 TabContentsController* controller) |
| 46 : controller_(controller) { | 46 : controller_(controller) { |
| 47 } | 47 } |
| 48 | 48 |
| 49 void TabContentsNotificationBridge::Observe( | 49 void TabContentsNotificationBridge::Observe( |
| 50 NotificationType type, | 50 NotificationType type, |
| 51 const NotificationSource& source, | 51 const NotificationSource& source, |
| 52 const NotificationDetails& details) { | 52 const NotificationDetails& details) { |
| 53 if (type == NotificationType::RENDER_VIEW_HOST_CHANGED) { | 53 if (type == chrome::RENDER_VIEW_HOST_CHANGED) { |
| 54 RenderViewHostSwitchedDetails* switched_details = | 54 RenderViewHostSwitchedDetails* switched_details = |
| 55 Details<RenderViewHostSwitchedDetails>(details).ptr(); | 55 Details<RenderViewHostSwitchedDetails>(details).ptr(); |
| 56 [controller_ tabContentsRenderViewHostChanged:switched_details->old_host | 56 [controller_ tabContentsRenderViewHostChanged:switched_details->old_host |
| 57 newHost:switched_details->new_host]; | 57 newHost:switched_details->new_host]; |
| 58 } else { | 58 } else { |
| 59 NOTREACHED(); | 59 NOTREACHED(); |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 | 62 |
| 63 void TabContentsNotificationBridge::ChangeTabContents(TabContents* contents) { | 63 void TabContentsNotificationBridge::ChangeTabContents(TabContents* contents) { |
| 64 registrar_.RemoveAll(); | 64 registrar_.RemoveAll(); |
| 65 if (contents) { | 65 if (contents) { |
| 66 registrar_.Add(this, | 66 registrar_.Add(this, |
| 67 NotificationType::RENDER_VIEW_HOST_CHANGED, | 67 chrome::RENDER_VIEW_HOST_CHANGED, |
| 68 Source<NavigationController>(&contents->controller())); | 68 Source<NavigationController>(&contents->controller())); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 | 72 |
| 73 // A custom view that notifies |controller| that view's frame is changing. | 73 // A custom view that notifies |controller| that view's frame is changing. |
| 74 | 74 |
| 75 @interface ResizeNotificationView : NSView { | 75 @interface ResizeNotificationView : NSView { |
| 76 TabContentsController* controller_; | 76 TabContentsController* controller_; |
| 77 } | 77 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 // the view may have, so avoid changing the view hierarchy unless | 201 // the view may have, so avoid changing the view hierarchy unless |
| 202 // the view is different. | 202 // the view is different. |
| 203 if ([self tabContents] != updatedContents) { | 203 if ([self tabContents] != updatedContents) { |
| 204 [self changeTabContents:updatedContents]; | 204 [self changeTabContents:updatedContents]; |
| 205 if ([self tabContents]) | 205 if ([self tabContents]) |
| 206 [self ensureContentsVisible]; | 206 [self ensureContentsVisible]; |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 | 209 |
| 210 @end | 210 @end |
| OLD | NEW |