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/tab_contents.h" | 10 #include "content/browser/tab_contents/tab_contents.h" |
11 #include "content/public/browser/navigation_controller.h" | 11 #include "content/public/browser/navigation_controller.h" |
12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
14 #include "content/public/browser/notification_details.h" | 14 #include "content/public/browser/notification_details.h" |
15 #include "content/public/browser/notification_source.h" | 15 #include "content/public/browser/notification_source.h" |
16 #include "content/public/browser/notification_types.h" | 16 #include "content/public/browser/notification_types.h" |
17 | 17 |
| 18 using content::NavigationController; |
18 using content::WebContents; | 19 using content::WebContents; |
19 | 20 |
20 @interface TabContentsController(Private) | 21 @interface TabContentsController(Private) |
21 // Forwards frame update to |delegate_| (ResizeNotificationView calls it). | 22 // Forwards frame update to |delegate_| (ResizeNotificationView calls it). |
22 - (void)tabContentsViewFrameWillChange:(NSRect)frameRect; | 23 - (void)tabContentsViewFrameWillChange:(NSRect)frameRect; |
23 // Notification from TabContents (forwarded by TabContentsNotificationBridge). | 24 // Notification from TabContents (forwarded by TabContentsNotificationBridge). |
24 - (void)tabContentsRenderViewHostChanged:(RenderViewHost*)oldHost | 25 - (void)tabContentsRenderViewHostChanged:(RenderViewHost*)oldHost |
25 newHost:(RenderViewHost*)newHost; | 26 newHost:(RenderViewHost*)newHost; |
26 @end | 27 @end |
27 | 28 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 NOTREACHED(); | 62 NOTREACHED(); |
62 } | 63 } |
63 } | 64 } |
64 | 65 |
65 void TabContentsNotificationBridge::ChangeWebContents(WebContents* contents) { | 66 void TabContentsNotificationBridge::ChangeWebContents(WebContents* contents) { |
66 registrar_.RemoveAll(); | 67 registrar_.RemoveAll(); |
67 if (contents) { | 68 if (contents) { |
68 registrar_.Add( | 69 registrar_.Add( |
69 this, | 70 this, |
70 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 71 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
71 content::Source<content::NavigationController>( | 72 content::Source<NavigationController>(&contents->GetController())); |
72 &contents->GetController())); | |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 | 76 |
77 // A custom view that notifies |controller| that view's frame is changing. | 77 // A custom view that notifies |controller| that view's frame is changing. |
78 | 78 |
79 @interface ResizeNotificationView : NSView { | 79 @interface ResizeNotificationView : NSView { |
80 TabContentsController* controller_; | 80 TabContentsController* controller_; |
81 } | 81 } |
82 - (id)initWithController:(TabContentsController*)controller; | 82 - (id)initWithController:(TabContentsController*)controller; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // the view may have, so avoid changing the view hierarchy unless | 205 // the view may have, so avoid changing the view hierarchy unless |
206 // the view is different. | 206 // the view is different. |
207 if ([self tabContents] != updatedContents) { | 207 if ([self tabContents] != updatedContents) { |
208 [self changeTabContents:updatedContents]; | 208 [self changeTabContents:updatedContents]; |
209 if ([self tabContents]) | 209 if ([self tabContents]) |
210 [self ensureContentsVisible]; | 210 [self ensureContentsVisible]; |
211 } | 211 } |
212 } | 212 } |
213 | 213 |
214 @end | 214 @end |
OLD | NEW |