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/ui/views/tab_contents/tab_contents_container.h" | 5 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" |
6 | 6 |
7 #include "chrome/browser/ui/view_ids.h" | 7 #include "chrome/browser/ui/view_ids.h" |
8 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_container.h" | 8 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_container.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/renderer_host/render_widget_host_view.h" | 10 #include "content/browser/renderer_host/render_widget_host_view.h" |
11 #include "content/browser/tab_contents/interstitial_page.h" | 11 #include "content/browser/tab_contents/interstitial_page.h" |
12 #include "content/browser/tab_contents/tab_contents.h" | 12 #include "content/browser/tab_contents/tab_contents.h" |
13 #include "content/common/notification_details.h" | 13 #include "content/common/notification_details.h" |
14 #include "content/common/notification_source.h" | 14 #include "content/common/notification_source.h" |
15 #include "ui/base/accessibility/accessible_view_state.h" | 15 #include "ui/base/accessibility/accessible_view_state.h" |
16 | 16 |
17 | 17 |
18 //////////////////////////////////////////////////////////////////////////////// | 18 //////////////////////////////////////////////////////////////////////////////// |
19 // TabContentsContainer, public: | 19 // TabContentsContainer, public: |
20 | 20 |
21 TabContentsContainer::~TabContentsContainer() { | 21 TabContentsContainer::~TabContentsContainer() { |
22 if (tab_contents_) | 22 if (tab_contents_) |
23 RemoveObservers(); | 23 RemoveObservers(); |
24 } | 24 } |
25 | 25 |
26 //////////////////////////////////////////////////////////////////////////////// | 26 //////////////////////////////////////////////////////////////////////////////// |
27 // TabContentsContainer, NotificationObserver implementation: | 27 // TabContentsContainer, NotificationObserver implementation: |
28 | 28 |
29 void TabContentsContainer::Observe(NotificationType type, | 29 void TabContentsContainer::Observe(int type, |
30 const NotificationSource& source, | 30 const NotificationSource& source, |
31 const NotificationDetails& details) { | 31 const NotificationDetails& details) { |
32 if (type == NotificationType::RENDER_VIEW_HOST_CHANGED) { | 32 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) { |
33 RenderViewHostSwitchedDetails* switched_details = | 33 RenderViewHostSwitchedDetails* switched_details = |
34 Details<RenderViewHostSwitchedDetails>(details).ptr(); | 34 Details<RenderViewHostSwitchedDetails>(details).ptr(); |
35 RenderViewHostChanged(switched_details->old_host, | 35 RenderViewHostChanged(switched_details->old_host, |
36 switched_details->new_host); | 36 switched_details->new_host); |
37 } else if (type == NotificationType::TAB_CONTENTS_DESTROYED) { | 37 } else if (type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED) { |
38 TabContentsDestroyed(Source<TabContents>(source).ptr()); | 38 TabContentsDestroyed(Source<TabContents>(source).ptr()); |
39 } else { | 39 } else { |
40 NOTREACHED(); | 40 NOTREACHED(); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 //////////////////////////////////////////////////////////////////////////////// | 44 //////////////////////////////////////////////////////////////////////////////// |
45 // TabContentsContainer, View overrides: | 45 // TabContentsContainer, View overrides: |
46 | 46 |
47 void TabContentsContainer::GetAccessibleState(ui::AccessibleViewState* state) { | 47 void TabContentsContainer::GetAccessibleState(ui::AccessibleViewState* state) { |
48 state->role = ui::AccessibilityTypes::ROLE_WINDOW; | 48 state->role = ui::AccessibilityTypes::ROLE_WINDOW; |
49 } | 49 } |
50 | 50 |
51 //////////////////////////////////////////////////////////////////////////////// | 51 //////////////////////////////////////////////////////////////////////////////// |
52 // TabContentsContainer, private: | 52 // TabContentsContainer, private: |
53 | 53 |
54 void TabContentsContainer::AddObservers() { | 54 void TabContentsContainer::AddObservers() { |
55 // TabContents can change their RenderViewHost and hence the HWND that is | 55 // TabContents can change their RenderViewHost and hence the HWND that is |
56 // shown and getting focused. We need to keep track of that so we install | 56 // shown and getting focused. We need to keep track of that so we install |
57 // the focus subclass on the shown HWND so we intercept focus change events. | 57 // the focus subclass on the shown HWND so we intercept focus change events. |
58 registrar_.Add(this, | 58 registrar_.Add(this, |
59 NotificationType::RENDER_VIEW_HOST_CHANGED, | 59 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
60 Source<NavigationController>(&tab_contents_->controller())); | 60 Source<NavigationController>(&tab_contents_->controller())); |
61 | 61 |
62 registrar_.Add(this, | 62 registrar_.Add(this, |
63 NotificationType::TAB_CONTENTS_DESTROYED, | 63 content::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
64 Source<TabContents>(tab_contents_)); | 64 Source<TabContents>(tab_contents_)); |
65 } | 65 } |
66 | 66 |
67 void TabContentsContainer::RemoveObservers() { | 67 void TabContentsContainer::RemoveObservers() { |
68 registrar_.RemoveAll(); | 68 registrar_.RemoveAll(); |
69 } | 69 } |
70 | 70 |
71 void TabContentsContainer::TabContentsDestroyed(TabContents* contents) { | 71 void TabContentsContainer::TabContentsDestroyed(TabContents* contents) { |
72 // Sometimes, a TabContents is destroyed before we know about it. This allows | 72 // Sometimes, a TabContents is destroyed before we know about it. This allows |
73 // us to clean up our state in case this happens. | 73 // us to clean up our state in case this happens. |
74 DCHECK(contents == tab_contents_); | 74 DCHECK(contents == tab_contents_); |
75 ChangeTabContents(NULL); | 75 ChangeTabContents(NULL); |
76 } | 76 } |
77 | 77 |
78 void TabContentsContainer::RenderWidgetHostViewChanged( | 78 void TabContentsContainer::RenderWidgetHostViewChanged( |
79 RenderWidgetHostView* new_view) { | 79 RenderWidgetHostView* new_view) { |
80 if (new_view) | 80 if (new_view) |
81 new_view->set_reserved_contents_rect(cached_reserved_rect_); | 81 new_view->set_reserved_contents_rect(cached_reserved_rect_); |
82 } | 82 } |
OLD | NEW |