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 "ui/views/controls/webview/webview.h" | 5 #include "ui/views/controls/webview/webview.h" |
6 | 6 |
7 #include "content/public/browser/browser_accessibility_state.h" | 7 #include "content/public/browser/browser_accessibility_state.h" |
8 #include "content/public/browser/browser_context.h" | 8 #include "content/public/browser/browser_context.h" |
9 #include "content/public/browser/navigation_controller.h" | 9 #include "content/public/browser/navigation_controller.h" |
10 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 content::RenderWidgetHostView* host_view = | 115 content::RenderWidgetHostView* host_view = |
116 is_embedding_fullscreen_widget_ ? | 116 is_embedding_fullscreen_widget_ ? |
117 web_contents()->GetFullscreenRenderWidgetHostView() : | 117 web_contents()->GetFullscreenRenderWidgetHostView() : |
118 web_contents()->GetRenderWidgetHostView(); | 118 web_contents()->GetRenderWidgetHostView(); |
119 if (host_view) | 119 if (host_view) |
120 return host_view->GetTextInputClient(); | 120 return host_view->GetTextInputClient(); |
121 } | 121 } |
122 return NULL; | 122 return NULL; |
123 } | 123 } |
124 | 124 |
125 scoped_ptr<content::WebContents> WebView::SwapWebContents( | |
126 scoped_ptr<content::WebContents> new_web_contents) { | |
127 if (wc_owner_) | |
128 wc_owner_->SetDelegate(NULL); | |
129 scoped_ptr<content::WebContents> old_web_contents(wc_owner_.Pass()); | |
130 wc_owner_ = new_web_contents.Pass(); | |
131 wc_owner_->SetDelegate(this); | |
miu
2014/07/22 19:27:53
This should be guarded by: if (wc_owner_)
flackr
2014/07/22 20:01:33
Done.
| |
132 SetWebContents(wc_owner_.get()); | |
133 return old_web_contents.Pass(); | |
134 } | |
135 | |
125 void WebView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 136 void WebView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
126 // In most cases, the holder is simply sized to fill this WebView's bounds. | 137 // In most cases, the holder is simply sized to fill this WebView's bounds. |
127 // Only WebContentses that are in fullscreen mode and being screen-captured | 138 // Only WebContentses that are in fullscreen mode and being screen-captured |
128 // will engage the special layout/sizing behavior. | 139 // will engage the special layout/sizing behavior. |
129 gfx::Rect holder_bounds(bounds().size()); | 140 gfx::Rect holder_bounds(bounds().size()); |
130 if (!embed_fullscreen_widget_mode_enabled_ || | 141 if (!embed_fullscreen_widget_mode_enabled_ || |
131 !web_contents() || | 142 !web_contents() || |
132 web_contents()->GetCapturerCount() == 0 || | 143 web_contents()->GetCapturerCount() == 0 || |
133 web_contents()->GetPreferredSize().IsEmpty() || | 144 web_contents()->GetPreferredSize().IsEmpty() || |
134 !(is_embedding_fullscreen_widget_ || | 145 !(is_embedding_fullscreen_widget_ || |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 if (!contents) { | 369 if (!contents) { |
359 content::WebContents::CreateParams create_params( | 370 content::WebContents::CreateParams create_params( |
360 browser_context, NULL); | 371 browser_context, NULL); |
361 return content::WebContents::Create(create_params); | 372 return content::WebContents::Create(create_params); |
362 } | 373 } |
363 | 374 |
364 return contents; | 375 return contents; |
365 } | 376 } |
366 | 377 |
367 } // namespace views | 378 } // namespace views |
OLD | NEW |