| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/ui/views/extensions/bookmark_app_bubble_view.h" | 5 #include "chrome/browser/ui/views/extensions/bookmark_app_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/numerics/safe_conversions.h" |
| 7 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 8 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/ui/host_desktop.h" | 11 #include "chrome/browser/ui/host_desktop.h" |
| 11 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
| 12 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 13 #include "extensions/common/constants.h" | 14 #include "extensions/common/constants.h" |
| 14 #include "ui/accessibility/ax_view_state.h" | 15 #include "ui/accessibility/ax_view_state.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 17 #include "ui/events/keycodes/keyboard_codes.h" | 18 #include "ui/events/keycodes/keyboard_codes.h" |
| 18 #include "ui/gfx/geometry/safe_integer_conversions.h" | |
| 19 #include "ui/gfx/image/image_skia.h" | 19 #include "ui/gfx/image/image_skia.h" |
| 20 #include "ui/gfx/image/image_skia_source.h" | 20 #include "ui/gfx/image/image_skia_source.h" |
| 21 #include "ui/views/controls/button/checkbox.h" | 21 #include "ui/views/controls/button/checkbox.h" |
| 22 #include "ui/views/controls/button/label_button.h" | 22 #include "ui/views/controls/button/label_button.h" |
| 23 #include "ui/views/controls/image_view.h" | 23 #include "ui/views/controls/image_view.h" |
| 24 #include "ui/views/controls/label.h" | 24 #include "ui/views/controls/label.h" |
| 25 #include "ui/views/controls/textfield/textfield.h" | 25 #include "ui/views/controls/textfield/textfield.h" |
| 26 #include "ui/views/layout/grid_layout.h" | 26 #include "ui/views/layout/grid_layout.h" |
| 27 #include "ui/views/layout/layout_constants.h" | 27 #include "ui/views/layout/layout_constants.h" |
| 28 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 40 const int kIconSize = extension_misc::EXTENSION_ICON_MEDIUM; | 40 const int kIconSize = extension_misc::EXTENSION_ICON_MEDIUM; |
| 41 | 41 |
| 42 class WebAppInfoImageSource : public gfx::ImageSkiaSource { | 42 class WebAppInfoImageSource : public gfx::ImageSkiaSource { |
| 43 public: | 43 public: |
| 44 WebAppInfoImageSource(int dip_size, const WebApplicationInfo& info) | 44 WebAppInfoImageSource(int dip_size, const WebApplicationInfo& info) |
| 45 : dip_size_(dip_size), info_(info) {} | 45 : dip_size_(dip_size), info_(info) {} |
| 46 ~WebAppInfoImageSource() override {} | 46 ~WebAppInfoImageSource() override {} |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 gfx::ImageSkiaRep GetImageForScale(float scale) override { | 49 gfx::ImageSkiaRep GetImageForScale(float scale) override { |
| 50 int size = gfx::ClampToInt(dip_size_ * scale); | 50 int size = base::saturated_cast<int>(dip_size_ * scale); |
| 51 for (const auto& icon_info : info_.icons) { | 51 for (const auto& icon_info : info_.icons) { |
| 52 if (icon_info.width == size) { | 52 if (icon_info.width == size) { |
| 53 return gfx::ImageSkiaRep(icon_info.data, scale); | 53 return gfx::ImageSkiaRep(icon_info.data, scale); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 return gfx::ImageSkiaRep(); | 56 return gfx::ImageSkiaRep(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 int dip_size_; | 59 int dip_size_; |
| 60 WebApplicationInfo info_; | 60 WebApplicationInfo info_; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 268 } |
| 269 #endif | 269 #endif |
| 270 return string_id; | 270 return string_id; |
| 271 } | 271 } |
| 272 | 272 |
| 273 base::string16 BookmarkAppBubbleView::GetTrimmedTitle() { | 273 base::string16 BookmarkAppBubbleView::GetTrimmedTitle() { |
| 274 base::string16 title(title_tf_->text()); | 274 base::string16 title(title_tf_->text()); |
| 275 base::TrimWhitespace(title, base::TRIM_ALL, &title); | 275 base::TrimWhitespace(title, base::TRIM_ALL, &title); |
| 276 return title; | 276 return title; |
| 277 } | 277 } |
| OLD | NEW |