| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 return true; | 171 return true; |
| 172 } | 172 } |
| 173 | 173 |
| 174 // Calculates how "boring" a thumbnail is. The boring score is the | 174 // Calculates how "boring" a thumbnail is. The boring score is the |
| 175 // 0,1 ranged percentage of pixels that are the most common | 175 // 0,1 ranged percentage of pixels that are the most common |
| 176 // luma. Higher boring scores indicate that a higher percentage of a | 176 // luma. Higher boring scores indicate that a higher percentage of a |
| 177 // bitmap are all the same brightness. | 177 // bitmap are all the same brightness. |
| 178 static double CalculateBoringScore(SkBitmap* bitmap) { | 178 static double CalculateBoringScore(SkBitmap* bitmap) { |
| 179 int histogram[256] = {0}; | 179 int histogram[256] = {0}; |
| 180 color_utils::BuildLumaHistogram(bitmap, histogram); | 180 color_utils::BuildLumaHistogram(*bitmap, histogram); |
| 181 | 181 |
| 182 int color_count = *std::max_element(histogram, histogram + 256); | 182 int color_count = *std::max_element(histogram, histogram + 256); |
| 183 int pixel_count = bitmap->width() * bitmap->height(); | 183 int pixel_count = bitmap->width() * bitmap->height(); |
| 184 return static_cast<double>(color_count) / pixel_count; | 184 return static_cast<double>(color_count) / pixel_count; |
| 185 } | 185 } |
| 186 | 186 |
| 187 static FaviconURL::IconType ToFaviconType(WebIconURL::Type type) { | 187 static FaviconURL::IconType ToFaviconType(WebIconURL::Type type) { |
| 188 switch (type) { | 188 switch (type) { |
| 189 case WebIconURL::TypeFavicon: | 189 case WebIconURL::TypeFavicon: |
| 190 return FaviconURL::FAVICON; | 190 return FaviconURL::FAVICON; |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 reinterpret_cast<const unsigned char*>(&data[0]); | 1049 reinterpret_cast<const unsigned char*>(&data[0]); |
| 1050 | 1050 |
| 1051 return decoder.Decode(src_data, data.size()); | 1051 return decoder.Decode(src_data, data.size()); |
| 1052 } | 1052 } |
| 1053 return SkBitmap(); | 1053 return SkBitmap(); |
| 1054 } | 1054 } |
| 1055 | 1055 |
| 1056 bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) { | 1056 bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) { |
| 1057 return (strict_security_hosts_.find(host) != strict_security_hosts_.end()); | 1057 return (strict_security_hosts_.find(host) != strict_security_hosts_.end()); |
| 1058 } | 1058 } |
| OLD | NEW |