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 <utility> | 7 #include <utility> |
8 | 8 |
| 9 #include "build/build_config.h" |
9 #include "content/public/browser/browser_accessibility_state.h" | 10 #include "content/public/browser/browser_accessibility_state.h" |
10 #include "content/public/browser/browser_context.h" | 11 #include "content/public/browser/browser_context.h" |
11 #include "content/public/browser/navigation_controller.h" | 12 #include "content/public/browser/navigation_controller.h" |
12 #include "content/public/browser/render_process_host.h" | 13 #include "content/public/browser/render_process_host.h" |
13 #include "content/public/browser/render_view_host.h" | 14 #include "content/public/browser/render_view_host.h" |
14 #include "content/public/browser/render_widget_host_view.h" | 15 #include "content/public/browser/render_widget_host_view.h" |
15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
16 #include "ipc/ipc_message.h" | 17 #include "ipc/ipc_message.h" |
17 #include "ui/accessibility/ax_enums.h" | 18 #include "ui/accessibility/ax_enums.h" |
18 #include "ui/accessibility/ax_view_state.h" | 19 #include "ui/accessibility/ax_view_state.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 const gfx::Size capture_size = web_contents()->GetPreferredSize(); | 147 const gfx::Size capture_size = web_contents()->GetPreferredSize(); |
147 if (capture_size.width() <= holder_bounds.width() && | 148 if (capture_size.width() <= holder_bounds.width() && |
148 capture_size.height() <= holder_bounds.height()) { | 149 capture_size.height() <= holder_bounds.height()) { |
149 // No scaling, just centering. | 150 // No scaling, just centering. |
150 holder_bounds.ClampToCenteredSize(capture_size); | 151 holder_bounds.ClampToCenteredSize(capture_size); |
151 } else { | 152 } else { |
152 // Scale down, preserving aspect ratio, and center. | 153 // Scale down, preserving aspect ratio, and center. |
153 // TODO(miu): This is basically media::ComputeLetterboxRegion(), and it | 154 // TODO(miu): This is basically media::ComputeLetterboxRegion(), and it |
154 // looks like others have written this code elsewhere. Let's considate | 155 // looks like others have written this code elsewhere. Let's considate |
155 // into a shared function ui/gfx/geometry or around there. | 156 // into a shared function ui/gfx/geometry or around there. |
156 const int64 x = static_cast<int64>(capture_size.width()) * | 157 const int64_t x = |
157 holder_bounds.height(); | 158 static_cast<int64_t>(capture_size.width()) * holder_bounds.height(); |
158 const int64 y = static_cast<int64>(capture_size.height()) * | 159 const int64_t y = |
159 holder_bounds.width(); | 160 static_cast<int64_t>(capture_size.height()) * holder_bounds.width(); |
160 if (y < x) { | 161 if (y < x) { |
161 holder_bounds.ClampToCenteredSize(gfx::Size( | 162 holder_bounds.ClampToCenteredSize(gfx::Size( |
162 holder_bounds.width(), static_cast<int>(y / capture_size.width()))); | 163 holder_bounds.width(), static_cast<int>(y / capture_size.width()))); |
163 } else { | 164 } else { |
164 holder_bounds.ClampToCenteredSize(gfx::Size( | 165 holder_bounds.ClampToCenteredSize(gfx::Size( |
165 static_cast<int>(x / capture_size.height()), holder_bounds.height())); | 166 static_cast<int>(x / capture_size.height()), holder_bounds.height())); |
166 } | 167 } |
167 } | 168 } |
168 | 169 |
169 holder_->SetBoundsRect(holder_bounds); | 170 holder_->SetBoundsRect(holder_bounds); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 if (!contents) { | 393 if (!contents) { |
393 content::WebContents::CreateParams create_params( | 394 content::WebContents::CreateParams create_params( |
394 browser_context, NULL); | 395 browser_context, NULL); |
395 return content::WebContents::Create(create_params); | 396 return content::WebContents::Create(create_params); |
396 } | 397 } |
397 | 398 |
398 return contents; | 399 return contents; |
399 } | 400 } |
400 | 401 |
401 } // namespace views | 402 } // namespace views |
OLD | NEW |