| 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 "components/infobars/core/infobar_delegate.h" | 5 #include "components/infobars/core/infobar_delegate.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "components/infobars/core/infobar.h" | 9 #include "components/infobars/core/infobar.h" |
| 10 #include "components/infobars/core/infobar_manager.h" | 10 #include "components/infobars/core/infobar_manager.h" |
| 11 #include "ui/base/material_design/material_design_controller.h" | 11 #include "ui/base/material_design/material_design_controller.h" |
| 12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
| 13 #include "ui/gfx/vector_icons_public.h" | 13 #include "ui/gfx/vector_icon_types.h" |
| 14 | 14 |
| 15 #if !defined(OS_IOS) && !defined(OS_ANDROID) | 15 #if !defined(OS_IOS) && !defined(OS_ANDROID) |
| 16 #include "ui/gfx/color_palette.h" | 16 #include "ui/gfx/color_palette.h" |
| 17 #include "ui/gfx/paint_vector_icon.h" | 17 #include "ui/gfx/paint_vector_icon.h" |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 namespace infobars { | 20 namespace infobars { |
| 21 | 21 |
| 22 const int InfoBarDelegate::kNoIconID = 0; | 22 const int InfoBarDelegate::kNoIconID = 0; |
| 23 | 23 |
| 24 InfoBarDelegate::~InfoBarDelegate() { | 24 InfoBarDelegate::~InfoBarDelegate() { |
| 25 } | 25 } |
| 26 | 26 |
| 27 InfoBarDelegate::InfoBarAutomationType | 27 InfoBarDelegate::InfoBarAutomationType |
| 28 InfoBarDelegate::GetInfoBarAutomationType() const { | 28 InfoBarDelegate::GetInfoBarAutomationType() const { |
| 29 return UNKNOWN_INFOBAR; | 29 return UNKNOWN_INFOBAR; |
| 30 } | 30 } |
| 31 | 31 |
| 32 InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const { | 32 InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const { |
| 33 return WARNING_TYPE; | 33 return WARNING_TYPE; |
| 34 } | 34 } |
| 35 | 35 |
| 36 int InfoBarDelegate::GetIconId() const { | 36 int InfoBarDelegate::GetIconId() const { |
| 37 return kNoIconID; | 37 return kNoIconID; |
| 38 } | 38 } |
| 39 | 39 |
| 40 gfx::VectorIconId InfoBarDelegate::GetVectorIconId() const { | 40 const gfx::VectorIcon& InfoBarDelegate::GetVectorIcon() const { |
| 41 return gfx::VectorIconId::VECTOR_ICON_NONE; | 41 CR_DEFINE_STATIC_LOCAL(gfx::VectorIcon, empty_icon, ()); |
| 42 return empty_icon; |
| 42 } | 43 } |
| 43 | 44 |
| 44 gfx::Image InfoBarDelegate::GetIcon() const { | 45 gfx::Image InfoBarDelegate::GetIcon() const { |
| 45 #if !defined(OS_IOS) && !defined(OS_ANDROID) | 46 #if !defined(OS_IOS) && !defined(OS_ANDROID) |
| 46 gfx::VectorIconId vector_id = GetVectorIconId(); | 47 const gfx::VectorIcon& vector_icon = GetVectorIcon(); |
| 47 if (vector_id != gfx::VectorIconId::VECTOR_ICON_NONE) { | 48 if (!vector_icon.is_empty()) { |
| 48 return gfx::Image(gfx::CreateVectorIcon(vector_id, 16, | 49 return gfx::Image(gfx::CreateVectorIcon(vector_icon, 16, |
| 49 GetInfoBarType() == WARNING_TYPE | 50 GetInfoBarType() == WARNING_TYPE |
| 50 ? SkColorSetRGB(0xFF, 0x67, 0) | 51 ? SkColorSetRGB(0xFF, 0x67, 0) |
| 51 : gfx::kGoogleBlue500)); | 52 : gfx::kGoogleBlue500)); |
| 52 } | 53 } |
| 53 #endif | 54 #endif |
| 54 | 55 |
| 55 int icon_id = GetIconId(); | 56 int icon_id = GetIconId(); |
| 56 return icon_id == kNoIconID ? gfx::Image() : | 57 return icon_id == kNoIconID ? gfx::Image() : |
| 57 ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id); | 58 ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id); |
| 58 } | 59 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 offline_pages::OfflinePageInfoBarDelegate* | 139 offline_pages::OfflinePageInfoBarDelegate* |
| 139 InfoBarDelegate::AsOfflinePageInfoBarDelegate() { | 140 InfoBarDelegate::AsOfflinePageInfoBarDelegate() { |
| 140 return nullptr; | 141 return nullptr; |
| 141 } | 142 } |
| 142 #endif | 143 #endif |
| 143 | 144 |
| 144 InfoBarDelegate::InfoBarDelegate() : nav_entry_id_(0) { | 145 InfoBarDelegate::InfoBarDelegate() : nav_entry_id_(0) { |
| 145 } | 146 } |
| 146 | 147 |
| 147 } // namespace infobars | 148 } // namespace infobars |
| OLD | NEW |