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 "chrome/renderer/chrome_render_view_observer.h" | 5 #include "chrome/renderer/chrome_render_view_observer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 static_cast<S16CPU>(dest_rect.height())); | 1005 static_cast<S16CPU>(dest_rect.height())); |
1006 score->good_clipping = false; | 1006 score->good_clipping = false; |
1007 } else { | 1007 } else { |
1008 float src_aspect = static_cast<float>(src_bmp_width) / src_bmp.height(); | 1008 float src_aspect = static_cast<float>(src_bmp_width) / src_bmp.height(); |
1009 if (src_aspect > dest_aspect) { | 1009 if (src_aspect > dest_aspect) { |
1010 // Wider than tall, clip horizontally: we center the smaller thumbnail in | 1010 // Wider than tall, clip horizontally: we center the smaller thumbnail in |
1011 // the wider screen. | 1011 // the wider screen. |
1012 S16CPU new_width = static_cast<S16CPU>(src_bmp.height() * dest_aspect); | 1012 S16CPU new_width = static_cast<S16CPU>(src_bmp.height() * dest_aspect); |
1013 S16CPU x_offset = (src_bmp_width - new_width) / 2; | 1013 S16CPU x_offset = (src_bmp_width - new_width) / 2; |
1014 src_rect.set(x_offset, 0, new_width + x_offset, src_bmp.height()); | 1014 src_rect.set(x_offset, 0, new_width + x_offset, src_bmp.height()); |
1015 score->good_clipping = | 1015 score->good_clipping = (src_aspect < ThumbnailScore::kTooWideAspectRatio); |
1016 (src_aspect >= ThumbnailScore::kTooWideAspectRatio) ? false : true; | |
1017 } else { | 1016 } else { |
1018 src_rect.set(0, 0, src_bmp_width, | 1017 src_rect.set(0, 0, src_bmp_width, |
1019 static_cast<S16CPU>(src_bmp_width / dest_aspect)); | 1018 static_cast<S16CPU>(src_bmp_width / dest_aspect)); |
1020 score->good_clipping = true; | 1019 score->good_clipping = true; |
1021 } | 1020 } |
1022 } | 1021 } |
1023 | 1022 |
1024 score->at_top = (view->mainFrame()->scrollOffset().height == 0); | 1023 score->at_top = (view->mainFrame()->scrollOffset().height == 0); |
1025 | 1024 |
1026 SkBitmap subset; | 1025 SkBitmap subset; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 reinterpret_cast<const unsigned char*>(&data[0]); | 1127 reinterpret_cast<const unsigned char*>(&data[0]); |
1129 | 1128 |
1130 return decoder.Decode(src_data, data.size()); | 1129 return decoder.Decode(src_data, data.size()); |
1131 } | 1130 } |
1132 return SkBitmap(); | 1131 return SkBitmap(); |
1133 } | 1132 } |
1134 | 1133 |
1135 bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) { | 1134 bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) { |
1136 return (strict_security_hosts_.find(host) != strict_security_hosts_.end()); | 1135 return (strict_security_hosts_.find(host) != strict_security_hosts_.end()); |
1137 } | 1136 } |
OLD | NEW |