OLD | NEW |
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 "content/browser/web_contents/web_contents_view_android.h" | 5 #include "content/browser/web_contents/web_contents_view_android.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/browser/android/content_view_impl.h" | 8 #include "content/browser/android/content_view_core_impl.h" |
9 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 9 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
10 #include "content/browser/renderer_host/render_view_host_factory.h" | 10 #include "content/browser/renderer_host/render_view_host_factory.h" |
11 #include "content/browser/renderer_host/render_view_host_impl.h" | 11 #include "content/browser/renderer_host/render_view_host_impl.h" |
12 #include "content/browser/web_contents/web_contents_impl.h" | 12 #include "content/browser/web_contents/web_contents_impl.h" |
13 #include "content/public/browser/interstitial_page.h" | 13 #include "content/public/browser/interstitial_page.h" |
14 #include "content/public/browser/web_contents_delegate.h" | 14 #include "content/public/browser/web_contents_delegate.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 WebContentsView* CreateWebContentsView( | 17 WebContentsView* CreateWebContentsView( |
18 WebContentsImpl* web_contents, | 18 WebContentsImpl* web_contents, |
19 WebContentsViewDelegate* delegate, | 19 WebContentsViewDelegate* delegate, |
20 RenderViewHostDelegateView** render_view_host_delegate_view) { | 20 RenderViewHostDelegateView** render_view_host_delegate_view) { |
21 WebContentsViewAndroid* rv = new WebContentsViewAndroid( | 21 WebContentsViewAndroid* rv = new WebContentsViewAndroid( |
22 web_contents, delegate); | 22 web_contents, delegate); |
23 *render_view_host_delegate_view = rv; | 23 *render_view_host_delegate_view = rv; |
24 return rv; | 24 return rv; |
25 } | 25 } |
26 | 26 |
27 WebContentsViewAndroid::WebContentsViewAndroid( | 27 WebContentsViewAndroid::WebContentsViewAndroid( |
28 WebContentsImpl* web_contents, | 28 WebContentsImpl* web_contents, |
29 WebContentsViewDelegate* delegate) | 29 WebContentsViewDelegate* delegate) |
30 : web_contents_(web_contents), | 30 : web_contents_(web_contents), |
31 delegate_(delegate) { | 31 delegate_(delegate) { |
32 } | 32 } |
33 | 33 |
34 WebContentsViewAndroid::~WebContentsViewAndroid() { | 34 WebContentsViewAndroid::~WebContentsViewAndroid() { |
35 } | 35 } |
36 | 36 |
37 void WebContentsViewAndroid::SetContentView( | 37 void WebContentsViewAndroid::SetContentViewCore( |
38 ContentViewImpl* content_view) { | 38 ContentViewCoreImpl* content_view_core) { |
39 content_view_ = content_view; | 39 content_view_core_ = content_view_core; |
40 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 40 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( |
41 web_contents_->GetRenderWidgetHostView()); | 41 web_contents_->GetRenderWidgetHostView()); |
42 if (rwhv) | 42 if (rwhv) |
43 rwhv->SetContentView(content_view_); | 43 rwhv->SetContentViewCore(content_view_core_); |
44 if (web_contents_->ShowingInterstitialPage()) { | 44 if (web_contents_->ShowingInterstitialPage()) { |
45 NOTIMPLEMENTED() << "not upstreamed yet"; | 45 NOTIMPLEMENTED() << "not upstreamed yet"; |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 void WebContentsViewAndroid::CreateView(const gfx::Size& initial_size) { | 49 void WebContentsViewAndroid::CreateView(const gfx::Size& initial_size) { |
50 } | 50 } |
51 | 51 |
52 RenderWidgetHostView* WebContentsViewAndroid::CreateViewForWidget( | 52 RenderWidgetHostView* WebContentsViewAndroid::CreateViewForWidget( |
53 RenderWidgetHost* render_widget_host) { | 53 RenderWidgetHost* render_widget_host) { |
54 if (render_widget_host->GetView()) { | 54 if (render_widget_host->GetView()) { |
55 // During testing, the view will already be set up in most cases to the | 55 // During testing, the view will already be set up in most cases to the |
56 // test view, so we don't want to clobber it with a real one. To verify that | 56 // test view, so we don't want to clobber it with a real one. To verify that |
57 // this actually is happening (and somebody isn't accidentally creating the | 57 // this actually is happening (and somebody isn't accidentally creating the |
58 // view twice), we check for the RVH Factory, which will be set when we're | 58 // view twice), we check for the RVH Factory, which will be set when we're |
59 // making special ones (which go along with the special views). | 59 // making special ones (which go along with the special views). |
60 DCHECK(RenderViewHostFactory::has_factory()); | 60 DCHECK(RenderViewHostFactory::has_factory()); |
61 return render_widget_host->GetView(); | 61 return render_widget_host->GetView(); |
62 } | 62 } |
63 // Note that while this instructs the render widget host to reference | 63 // Note that while this instructs the render widget host to reference |
64 // |native_view_|, this has no effect without also instructing the | 64 // |native_view_|, this has no effect without also instructing the |
65 // native view (i.e. ContentView) how to obtain a reference to this widget in | 65 // native view (i.e. ContentView) how to obtain a reference to this widget in |
66 // order to paint it. See ContentView::GetRenderWidgetHostViewAndroid for an | 66 // order to paint it. See ContentView::GetRenderWidgetHostViewAndroid for an |
67 // example of how this is achieved for InterstitialPages. | 67 // example of how this is achieved for InterstitialPages. |
68 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host); | 68 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host); |
69 return new RenderWidgetHostViewAndroid(rwhi, content_view_); | 69 return new RenderWidgetHostViewAndroid(rwhi, content_view_core_); |
70 } | 70 } |
71 | 71 |
72 gfx::NativeView WebContentsViewAndroid::GetNativeView() const { | 72 gfx::NativeView WebContentsViewAndroid::GetNativeView() const { |
73 return content_view_; | 73 return content_view_core_; |
74 } | 74 } |
75 | 75 |
76 gfx::NativeView WebContentsViewAndroid::GetContentNativeView() const { | 76 gfx::NativeView WebContentsViewAndroid::GetContentNativeView() const { |
77 return content_view_; | 77 return content_view_core_; |
78 } | 78 } |
79 | 79 |
80 gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const { | 80 gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const { |
81 return content_view_; | 81 return content_view_core_; |
82 } | 82 } |
83 | 83 |
84 void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const { | 84 void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const { |
85 if (content_view_) | 85 if (content_view_core_) |
86 *out = content_view_->GetBounds(); | 86 *out = content_view_core_->GetBounds(); |
87 } | 87 } |
88 | 88 |
89 void WebContentsViewAndroid::SetPageTitle(const string16& title) { | 89 void WebContentsViewAndroid::SetPageTitle(const string16& title) { |
90 if (content_view_) | 90 if (content_view_core_) |
91 content_view_->SetTitle(title); | 91 content_view_core_->SetTitle(title); |
92 } | 92 } |
93 | 93 |
94 void WebContentsViewAndroid::OnTabCrashed(base::TerminationStatus status, | 94 void WebContentsViewAndroid::OnTabCrashed(base::TerminationStatus status, |
95 int error_code) { | 95 int error_code) { |
96 NOTIMPLEMENTED() << "not upstreamed yet"; | 96 NOTIMPLEMENTED() << "not upstreamed yet"; |
97 } | 97 } |
98 | 98 |
99 void WebContentsViewAndroid::SizeContents(const gfx::Size& size) { | 99 void WebContentsViewAndroid::SizeContents(const gfx::Size& size) { |
100 // TODO(klobag): Do we need to do anything else? | 100 // TODO(klobag): Do we need to do anything else? |
101 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); | 101 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 bool WebContentsViewAndroid::IsEventTracking() const { | 145 bool WebContentsViewAndroid::IsEventTracking() const { |
146 NOTIMPLEMENTED(); | 146 NOTIMPLEMENTED(); |
147 return false; | 147 return false; |
148 } | 148 } |
149 | 149 |
150 void WebContentsViewAndroid::CloseTabAfterEventTracking() { | 150 void WebContentsViewAndroid::CloseTabAfterEventTracking() { |
151 NOTIMPLEMENTED(); | 151 NOTIMPLEMENTED(); |
152 } | 152 } |
153 | 153 |
154 gfx::Rect WebContentsViewAndroid::GetViewBounds() const { | 154 gfx::Rect WebContentsViewAndroid::GetViewBounds() const { |
155 if (content_view_) | 155 if (content_view_core_) |
156 return content_view_->GetBounds(); | 156 return content_view_core_->GetBounds(); |
157 else | 157 else |
158 return gfx::Rect(); | 158 return gfx::Rect(); |
159 } | 159 } |
160 | 160 |
161 void WebContentsViewAndroid::ShowContextMenu(const ContextMenuParams& params) { | 161 void WebContentsViewAndroid::ShowContextMenu(const ContextMenuParams& params) { |
162 if (delegate_.get()) | 162 if (delegate_.get()) |
163 delegate_->ShowContextMenu(params); | 163 delegate_->ShowContextMenu(params); |
164 } | 164 } |
165 | 165 |
166 void WebContentsViewAndroid::ShowPopupMenu( | 166 void WebContentsViewAndroid::ShowPopupMenu( |
(...skipping 27 matching lines...) Expand all Loading... |
194 // This is called when we the renderer asks us to take focus back (i.e., it has | 194 // This is called when we the renderer asks us to take focus back (i.e., it has |
195 // iterated past the last focusable element on the page). | 195 // iterated past the last focusable element on the page). |
196 void WebContentsViewAndroid::TakeFocus(bool reverse) { | 196 void WebContentsViewAndroid::TakeFocus(bool reverse) { |
197 if (web_contents_->GetDelegate() && | 197 if (web_contents_->GetDelegate() && |
198 web_contents_->GetDelegate()->TakeFocus(reverse)) | 198 web_contents_->GetDelegate()->TakeFocus(reverse)) |
199 return; | 199 return; |
200 web_contents_->GetRenderWidgetHostView()->Focus(); | 200 web_contents_->GetRenderWidgetHostView()->Focus(); |
201 } | 201 } |
202 | 202 |
203 } // namespace content | 203 } // namespace content |
OLD | NEW |