| 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/browser/ui/content_settings/content_setting_image_model.h" | 5 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
| 6 | 6 |
| 7 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "chrome/app/vector_icons/vector_icons.h" |
| 11 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 12 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 12 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 13 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 13 #include "chrome/browser/plugins/plugin_utils.h" | 14 #include "chrome/browser/plugins/plugin_utils.h" |
| 14 #include "chrome/browser/prerender/prerender_manager.h" | 15 #include "chrome/browser/prerender/prerender_manager.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/common/chrome_features.h" | 17 #include "chrome/common/chrome_features.h" |
| 17 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| 18 #include "chrome/grit/theme_resources.h" | |
| 19 #include "components/content_settings/core/browser/host_content_settings_map.h" | 19 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 22 #include "ui/base/material_design/material_design_controller.h" | 22 #include "ui/base/material_design/material_design_controller.h" |
| 23 #include "ui/base/resource/resource_bundle.h" | |
| 24 #include "ui/gfx/color_palette.h" | 23 #include "ui/gfx/color_palette.h" |
| 25 #include "ui/gfx/color_utils.h" | 24 #include "ui/gfx/color_utils.h" |
| 26 #include "ui/gfx/paint_vector_icon.h" | 25 #include "ui/gfx/paint_vector_icon.h" |
| 27 #include "ui/gfx/vector_icons_public.h" | 26 #include "ui/vector_icons/vector_icons.h" |
| 28 | 27 |
| 29 using content::WebContents; | 28 using content::WebContents; |
| 30 | 29 |
| 31 // The image models hierarchy: | 30 // The image models hierarchy: |
| 32 // | 31 // |
| 33 // ContentSettingImageModel - base class | 32 // ContentSettingImageModel - base class |
| 34 // ContentSettingSimpleImageModel - single content setting | 33 // ContentSettingSimpleImageModel - single content setting |
| 35 // ContentSettingBlockedImageModel - generic blocked setting | 34 // ContentSettingBlockedImageModel - generic blocked setting |
| 36 // ContentSettingGeolocationImageModel - geolocation | 35 // ContentSettingGeolocationImageModel - geolocation |
| 37 // ContentSettingRPHImageModel - protocol handlers | 36 // ContentSettingRPHImageModel - protocol handlers |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 92 |
| 94 void UpdateFromWebContents(WebContents* web_contents) override; | 93 void UpdateFromWebContents(WebContents* web_contents) override; |
| 95 private: | 94 private: |
| 96 DISALLOW_COPY_AND_ASSIGN(ContentSettingMIDISysExImageModel); | 95 DISALLOW_COPY_AND_ASSIGN(ContentSettingMIDISysExImageModel); |
| 97 }; | 96 }; |
| 98 | 97 |
| 99 namespace { | 98 namespace { |
| 100 | 99 |
| 101 struct ContentSettingsImageDetails { | 100 struct ContentSettingsImageDetails { |
| 102 ContentSettingsType type; | 101 ContentSettingsType type; |
| 103 gfx::VectorIconId icon_id; | 102 const gfx::VectorIcon& icon; |
| 104 int blocked_tooltip_id; | 103 int blocked_tooltip_id; |
| 105 int blocked_explanatory_text_id; | 104 int blocked_explanatory_text_id; |
| 106 int accessed_tooltip_id; | 105 int accessed_tooltip_id; |
| 107 }; | 106 }; |
| 108 | 107 |
| 109 const ContentSettingsImageDetails kImageDetails[] = { | 108 const ContentSettingsImageDetails kImageDetails[] = { |
| 110 {CONTENT_SETTINGS_TYPE_COOKIES, gfx::VectorIconId::COOKIE, | 109 {CONTENT_SETTINGS_TYPE_COOKIES, kCookieIcon, IDS_BLOCKED_COOKIES_TITLE, 0, |
| 111 IDS_BLOCKED_COOKIES_TITLE, 0, IDS_ACCESSED_COOKIES_TITLE}, | 110 IDS_ACCESSED_COOKIES_TITLE}, |
| 112 {CONTENT_SETTINGS_TYPE_IMAGES, gfx::VectorIconId::IMAGE, | 111 {CONTENT_SETTINGS_TYPE_IMAGES, kImageIcon, IDS_BLOCKED_IMAGES_TITLE, 0, 0}, |
| 113 IDS_BLOCKED_IMAGES_TITLE, 0, 0}, | 112 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, kCodeIcon, IDS_BLOCKED_JAVASCRIPT_TITLE, |
| 114 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, gfx::VectorIconId::CODE, | 113 0, 0}, |
| 115 IDS_BLOCKED_JAVASCRIPT_TITLE, 0, 0}, | 114 {CONTENT_SETTINGS_TYPE_PLUGINS, kExtensionIcon, IDS_BLOCKED_PLUGINS_MESSAGE, |
| 116 {CONTENT_SETTINGS_TYPE_PLUGINS, gfx::VectorIconId::EXTENSION, | 115 IDS_BLOCKED_PLUGIN_EXPLANATORY_TEXT, 0}, |
| 117 IDS_BLOCKED_PLUGINS_MESSAGE, IDS_BLOCKED_PLUGIN_EXPLANATORY_TEXT, 0}, | 116 {CONTENT_SETTINGS_TYPE_POPUPS, kWebIcon, IDS_BLOCKED_POPUPS_TOOLTIP, |
| 118 {CONTENT_SETTINGS_TYPE_POPUPS, gfx::VectorIconId::WEB, | 117 IDS_BLOCKED_POPUPS_EXPLANATORY_TEXT, 0}, |
| 119 IDS_BLOCKED_POPUPS_TOOLTIP, IDS_BLOCKED_POPUPS_EXPLANATORY_TEXT, 0}, | 118 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, kMixedContentIcon, |
| 120 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, gfx::VectorIconId::MIXED_CONTENT, | |
| 121 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT, 0, 0}, | 119 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT, 0, 0}, |
| 122 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, gfx::VectorIconId::EXTENSION, | 120 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, kExtensionIcon, |
| 123 IDS_BLOCKED_PPAPI_BROKER_TITLE, 0, IDS_ALLOWED_PPAPI_BROKER_TITLE}, | 121 IDS_BLOCKED_PPAPI_BROKER_TITLE, 0, IDS_ALLOWED_PPAPI_BROKER_TITLE}, |
| 124 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, | 122 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, kFileDownloadIcon, |
| 125 gfx::VectorIconId::FILE_DOWNLOAD, IDS_BLOCKED_DOWNLOAD_TITLE, | 123 IDS_BLOCKED_DOWNLOAD_TITLE, IDS_BLOCKED_DOWNLOADS_EXPLANATION, |
| 126 IDS_BLOCKED_DOWNLOADS_EXPLANATION, IDS_ALLOWED_DOWNLOAD_TITLE}, | 124 IDS_ALLOWED_DOWNLOAD_TITLE}, |
| 127 }; | 125 }; |
| 128 | 126 |
| 129 // The ordering of the models here influences the order in which icons are | 127 // The ordering of the models here influences the order in which icons are |
| 130 // shown in the omnibox. | 128 // shown in the omnibox. |
| 131 constexpr ContentSettingsType kContentTypeIconOrder[] = { | 129 constexpr ContentSettingsType kContentTypeIconOrder[] = { |
| 132 CONTENT_SETTINGS_TYPE_COOKIES, | 130 CONTENT_SETTINGS_TYPE_COOKIES, |
| 133 CONTENT_SETTINGS_TYPE_IMAGES, | 131 CONTENT_SETTINGS_TYPE_IMAGES, |
| 134 CONTENT_SETTINGS_TYPE_JAVASCRIPT, | 132 CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
| 135 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, | 133 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
| 136 CONTENT_SETTINGS_TYPE_PLUGINS, | 134 CONTENT_SETTINGS_TYPE_PLUGINS, |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 // For cookies, only show the cookie blocked page action if cookies are | 263 // For cookies, only show the cookie blocked page action if cookies are |
| 266 // blocked by default. | 264 // blocked by default. |
| 267 if (type == CONTENT_SETTINGS_TYPE_COOKIES && | 265 if (type == CONTENT_SETTINGS_TYPE_COOKIES && |
| 268 (map->GetDefaultContentSetting(type, nullptr) != CONTENT_SETTING_BLOCK)) | 266 (map->GetDefaultContentSetting(type, nullptr) != CONTENT_SETTING_BLOCK)) |
| 269 return; | 267 return; |
| 270 | 268 |
| 271 tooltip_id = image_details->accessed_tooltip_id; | 269 tooltip_id = image_details->accessed_tooltip_id; |
| 272 explanation_id = 0; | 270 explanation_id = 0; |
| 273 } | 271 } |
| 274 set_visible(true); | 272 set_visible(true); |
| 275 gfx::VectorIconId badge_id = gfx::VectorIconId::VECTOR_ICON_NONE; | 273 const gfx::VectorIcon* badge_id = &gfx::kNoneIcon; |
| 276 if (type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER) | 274 if (type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER) |
| 277 badge_id = gfx::VectorIconId::WARNING_BADGE; | 275 badge_id = &kWarningBadgeIcon; |
| 278 else if (content_settings->IsContentBlocked(type)) | 276 else if (content_settings->IsContentBlocked(type)) |
| 279 badge_id = gfx::VectorIconId::BLOCKED_BADGE; | 277 badge_id = &kBlockedBadgeIcon; |
| 280 | 278 |
| 281 set_icon_by_vector_id(image_details->icon_id, badge_id); | 279 set_icon(image_details->icon, *badge_id); |
| 282 set_explanatory_string_id(explanation_id); | 280 set_explanatory_string_id(explanation_id); |
| 283 DCHECK(tooltip_id); | 281 DCHECK(tooltip_id); |
| 284 set_tooltip(l10n_util::GetStringUTF16(tooltip_id)); | 282 set_tooltip(l10n_util::GetStringUTF16(tooltip_id)); |
| 285 } | 283 } |
| 286 | 284 |
| 287 // Geolocation ----------------------------------------------------------------- | 285 // Geolocation ----------------------------------------------------------------- |
| 288 | 286 |
| 289 ContentSettingGeolocationImageModel::ContentSettingGeolocationImageModel() | 287 ContentSettingGeolocationImageModel::ContentSettingGeolocationImageModel() |
| 290 : ContentSettingSimpleImageModel(CONTENT_SETTINGS_TYPE_GEOLOCATION) { | 288 : ContentSettingSimpleImageModel(CONTENT_SETTINGS_TYPE_GEOLOCATION) { |
| 291 } | 289 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 304 if (usages_state.state_map().empty()) | 302 if (usages_state.state_map().empty()) |
| 305 return; | 303 return; |
| 306 set_visible(true); | 304 set_visible(true); |
| 307 | 305 |
| 308 // If any embedded site has access the allowed icon takes priority over the | 306 // If any embedded site has access the allowed icon takes priority over the |
| 309 // blocked icon. | 307 // blocked icon. |
| 310 unsigned int state_flags = 0; | 308 unsigned int state_flags = 0; |
| 311 usages_state.GetDetailedInfo(nullptr, &state_flags); | 309 usages_state.GetDetailedInfo(nullptr, &state_flags); |
| 312 bool allowed = | 310 bool allowed = |
| 313 !!(state_flags & ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED); | 311 !!(state_flags & ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED); |
| 314 set_icon_by_vector_id(gfx::VectorIconId::MY_LOCATION, | 312 set_icon(kMyLocationIcon, allowed ? gfx::kNoneIcon : kBlockedBadgeIcon); |
| 315 allowed ? gfx::VectorIconId::VECTOR_ICON_NONE | |
| 316 : gfx::VectorIconId::BLOCKED_BADGE); | |
| 317 set_tooltip(l10n_util::GetStringUTF16(allowed | 313 set_tooltip(l10n_util::GetStringUTF16(allowed |
| 318 ? IDS_GEOLOCATION_ALLOWED_TOOLTIP | 314 ? IDS_GEOLOCATION_ALLOWED_TOOLTIP |
| 319 : IDS_GEOLOCATION_BLOCKED_TOOLTIP)); | 315 : IDS_GEOLOCATION_BLOCKED_TOOLTIP)); |
| 320 } | 316 } |
| 321 | 317 |
| 322 // Media ----------------------------------------------------------------------- | 318 // Media ----------------------------------------------------------------------- |
| 323 | 319 |
| 324 ContentSettingMediaImageModel::ContentSettingMediaImageModel() | 320 ContentSettingMediaImageModel::ContentSettingMediaImageModel() |
| 325 : ContentSettingImageModel() { | 321 : ContentSettingImageModel() { |
| 326 } | 322 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 344 if (state == TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED) | 340 if (state == TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED) |
| 345 return; | 341 return; |
| 346 | 342 |
| 347 bool is_mic = (state & TabSpecificContentSettings::MICROPHONE_ACCESSED) != 0; | 343 bool is_mic = (state & TabSpecificContentSettings::MICROPHONE_ACCESSED) != 0; |
| 348 bool is_cam = (state & TabSpecificContentSettings::CAMERA_ACCESSED) != 0; | 344 bool is_cam = (state & TabSpecificContentSettings::CAMERA_ACCESSED) != 0; |
| 349 DCHECK(is_mic || is_cam); | 345 DCHECK(is_mic || is_cam); |
| 350 | 346 |
| 351 int id = IDS_CAMERA_BLOCKED; | 347 int id = IDS_CAMERA_BLOCKED; |
| 352 if (state & (TabSpecificContentSettings::MICROPHONE_BLOCKED | | 348 if (state & (TabSpecificContentSettings::MICROPHONE_BLOCKED | |
| 353 TabSpecificContentSettings::CAMERA_BLOCKED)) { | 349 TabSpecificContentSettings::CAMERA_BLOCKED)) { |
| 354 set_icon_by_vector_id(gfx::VectorIconId::VIDEOCAM, | 350 set_icon(ui::kVideocamIcon, kBlockedBadgeIcon); |
| 355 gfx::VectorIconId::BLOCKED_BADGE); | |
| 356 if (is_mic) | 351 if (is_mic) |
| 357 id = is_cam ? IDS_MICROPHONE_CAMERA_BLOCKED : IDS_MICROPHONE_BLOCKED; | 352 id = is_cam ? IDS_MICROPHONE_CAMERA_BLOCKED : IDS_MICROPHONE_BLOCKED; |
| 358 } else { | 353 } else { |
| 359 set_icon_by_vector_id(gfx::VectorIconId::VIDEOCAM, | 354 set_icon(ui::kVideocamIcon, gfx::kNoneIcon); |
| 360 gfx::VectorIconId::VECTOR_ICON_NONE); | |
| 361 id = IDS_CAMERA_ACCESSED; | 355 id = IDS_CAMERA_ACCESSED; |
| 362 if (is_mic) | 356 if (is_mic) |
| 363 id = is_cam ? IDS_MICROPHONE_CAMERA_ALLOWED : IDS_MICROPHONE_ACCESSED; | 357 id = is_cam ? IDS_MICROPHONE_CAMERA_ALLOWED : IDS_MICROPHONE_ACCESSED; |
| 364 } | 358 } |
| 365 set_tooltip(l10n_util::GetStringUTF16(id)); | 359 set_tooltip(l10n_util::GetStringUTF16(id)); |
| 366 set_visible(true); | 360 set_visible(true); |
| 367 } | 361 } |
| 368 | 362 |
| 369 ContentSettingBubbleModel* ContentSettingMediaImageModel::CreateBubbleModel( | 363 ContentSettingBubbleModel* ContentSettingMediaImageModel::CreateBubbleModel( |
| 370 ContentSettingBubbleModel::Delegate* delegate, | 364 ContentSettingBubbleModel::Delegate* delegate, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 | 409 |
| 416 if (!web_contents) | 410 if (!web_contents) |
| 417 return; | 411 return; |
| 418 | 412 |
| 419 TabSpecificContentSettings* content_settings = | 413 TabSpecificContentSettings* content_settings = |
| 420 TabSpecificContentSettings::FromWebContents(web_contents); | 414 TabSpecificContentSettings::FromWebContents(web_contents); |
| 421 | 415 |
| 422 if (!content_settings || !content_settings->IsSubresourceBlocked()) | 416 if (!content_settings || !content_settings->IsSubresourceBlocked()) |
| 423 return; | 417 return; |
| 424 | 418 |
| 425 set_icon_by_vector_id(gfx::VectorIconId::SUBRESOURCE_FILTER_ACTIVE, | 419 set_icon(kSubresourceFilterActiveIcon, kBlockedBadgeIcon); |
| 426 gfx::VectorIconId::BLOCKED_BADGE); | |
| 427 set_explanatory_string_id(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_TITLE); | 420 set_explanatory_string_id(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_TITLE); |
| 428 set_tooltip( | 421 set_tooltip( |
| 429 l10n_util::GetStringUTF16(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_TITLE)); | 422 l10n_util::GetStringUTF16(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_TITLE)); |
| 430 set_visible(true); | 423 set_visible(true); |
| 431 } | 424 } |
| 432 | 425 |
| 433 ContentSettingBubbleModel* | 426 ContentSettingBubbleModel* |
| 434 ContentSettingSubresourceFilterImageModel::CreateBubbleModel( | 427 ContentSettingSubresourceFilterImageModel::CreateBubbleModel( |
| 435 ContentSettingBubbleModel::Delegate* delegate, | 428 ContentSettingBubbleModel::Delegate* delegate, |
| 436 WebContents* web_contents, | 429 WebContents* web_contents, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 456 TabSpecificContentSettings* content_settings = | 449 TabSpecificContentSettings* content_settings = |
| 457 TabSpecificContentSettings::FromWebContents(web_contents); | 450 TabSpecificContentSettings::FromWebContents(web_contents); |
| 458 if (content_settings) | 451 if (content_settings) |
| 459 content_settings->SetSubresourceBlockageIndicated(); | 452 content_settings->SetSubresourceBlockageIndicated(); |
| 460 } | 453 } |
| 461 | 454 |
| 462 // Protocol handlers ----------------------------------------------------------- | 455 // Protocol handlers ----------------------------------------------------------- |
| 463 | 456 |
| 464 ContentSettingRPHImageModel::ContentSettingRPHImageModel() | 457 ContentSettingRPHImageModel::ContentSettingRPHImageModel() |
| 465 : ContentSettingSimpleImageModel(CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { | 458 : ContentSettingSimpleImageModel(CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { |
| 466 set_icon_by_vector_id(gfx::VectorIconId::PROTOCOL_HANDLER, | 459 set_icon(ui::kProtocolHandlerIcon, gfx::kNoneIcon); |
| 467 gfx::VectorIconId::VECTOR_ICON_NONE); | |
| 468 set_tooltip(l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_TOOLTIP)); | 460 set_tooltip(l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_TOOLTIP)); |
| 469 } | 461 } |
| 470 | 462 |
| 471 void ContentSettingRPHImageModel::UpdateFromWebContents( | 463 void ContentSettingRPHImageModel::UpdateFromWebContents( |
| 472 WebContents* web_contents) { | 464 WebContents* web_contents) { |
| 473 set_visible(false); | 465 set_visible(false); |
| 474 if (!web_contents) | 466 if (!web_contents) |
| 475 return; | 467 return; |
| 476 | 468 |
| 477 TabSpecificContentSettings* content_settings = | 469 TabSpecificContentSettings* content_settings = |
| (...skipping 26 matching lines...) Expand all Loading... |
| 504 if (usages_state.state_map().empty()) | 496 if (usages_state.state_map().empty()) |
| 505 return; | 497 return; |
| 506 set_visible(true); | 498 set_visible(true); |
| 507 | 499 |
| 508 // If any embedded site has access the allowed icon takes priority over the | 500 // If any embedded site has access the allowed icon takes priority over the |
| 509 // blocked icon. | 501 // blocked icon. |
| 510 unsigned int state_flags = 0; | 502 unsigned int state_flags = 0; |
| 511 usages_state.GetDetailedInfo(nullptr, &state_flags); | 503 usages_state.GetDetailedInfo(nullptr, &state_flags); |
| 512 bool allowed = | 504 bool allowed = |
| 513 !!(state_flags & ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED); | 505 !!(state_flags & ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED); |
| 514 set_icon_by_vector_id(gfx::VectorIconId::MIDI, | 506 set_icon(ui::kMidiIcon, allowed ? gfx::kNoneIcon : kBlockedBadgeIcon); |
| 515 allowed ? gfx::VectorIconId::VECTOR_ICON_NONE | |
| 516 : gfx::VectorIconId::BLOCKED_BADGE); | |
| 517 set_tooltip(l10n_util::GetStringUTF16(allowed | 507 set_tooltip(l10n_util::GetStringUTF16(allowed |
| 518 ? IDS_MIDI_SYSEX_ALLOWED_TOOLTIP | 508 ? IDS_MIDI_SYSEX_ALLOWED_TOOLTIP |
| 519 : IDS_MIDI_SYSEX_BLOCKED_TOOLTIP)); | 509 : IDS_MIDI_SYSEX_BLOCKED_TOOLTIP)); |
| 520 } | 510 } |
| 521 | 511 |
| 522 // Base class ------------------------------------------------------------------ | 512 // Base class ------------------------------------------------------------------ |
| 523 | 513 |
| 524 gfx::Image ContentSettingImageModel::GetIcon(SkColor nearby_text_color) const { | 514 gfx::Image ContentSettingImageModel::GetIcon(SkColor nearby_text_color) const { |
| 525 #if defined(OS_MACOSX) | 515 #if defined(OS_MACOSX) |
| 526 SkColor icon_color = nearby_text_color; | 516 SkColor icon_color = nearby_text_color; |
| 527 #else | 517 #else |
| 528 SkColor icon_color = color_utils::DeriveDefaultIconColor(nearby_text_color); | 518 SkColor icon_color = color_utils::DeriveDefaultIconColor(nearby_text_color); |
| 529 #endif | 519 #endif |
| 530 | 520 |
| 531 return gfx::Image( | 521 return gfx::Image( |
| 532 gfx::CreateVectorIconWithBadge(icon_id_, 16, icon_color, icon_badge_id_)); | 522 gfx::CreateVectorIconWithBadge(*icon_, 16, icon_color, *icon_badge_)); |
| 533 } | 523 } |
| 534 | 524 |
| 535 ContentSettingImageModel::ContentSettingImageModel() | 525 ContentSettingImageModel::ContentSettingImageModel() |
| 536 : is_visible_(false), | 526 : is_visible_(false), |
| 537 icon_id_(gfx::VectorIconId::VECTOR_ICON_NONE), | 527 icon_(&gfx::kNoneIcon), |
| 538 icon_badge_id_(gfx::VectorIconId::VECTOR_ICON_NONE), | 528 icon_badge_(&gfx::kNoneIcon), |
| 539 explanatory_string_id_(0) {} | 529 explanatory_string_id_(0) {} |
| 540 | 530 |
| 541 // static | 531 // static |
| 542 std::vector<std::unique_ptr<ContentSettingImageModel>> | 532 std::vector<std::unique_ptr<ContentSettingImageModel>> |
| 543 ContentSettingImageModel::GenerateContentSettingImageModels() { | 533 ContentSettingImageModel::GenerateContentSettingImageModels() { |
| 544 std::vector<std::unique_ptr<ContentSettingImageModel>> result; | 534 std::vector<std::unique_ptr<ContentSettingImageModel>> result; |
| 545 std::unique_ptr<ContentSettingImageModel> model; | 535 std::unique_ptr<ContentSettingImageModel> model; |
| 546 | 536 |
| 547 for (auto icon : kContentTypeIconOrder) { | 537 for (auto icon : kContentTypeIconOrder) { |
| 548 switch (icon) { | 538 switch (icon) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 if (content_type == kContentTypeIconOrder[i]) | 570 if (content_type == kContentTypeIconOrder[i]) |
| 581 return i; | 571 return i; |
| 582 } | 572 } |
| 583 NOTREACHED(); | 573 NOTREACHED(); |
| 584 return arraysize(kContentTypeIconOrder); | 574 return arraysize(kContentTypeIconOrder); |
| 585 } | 575 } |
| 586 | 576 |
| 587 #if defined(OS_MACOSX) | 577 #if defined(OS_MACOSX) |
| 588 bool ContentSettingImageModel::UpdateFromWebContentsAndCheckIfIconChanged( | 578 bool ContentSettingImageModel::UpdateFromWebContentsAndCheckIfIconChanged( |
| 589 content::WebContents* web_contents) { | 579 content::WebContents* web_contents) { |
| 590 gfx::VectorIconId old_icon = icon_id_; | 580 const gfx::VectorIcon* old_icon = icon_; |
| 591 gfx::VectorIconId old_badge_icon = icon_badge_id_; | 581 const gfx::VectorIcon* old_badge_icon = icon_badge_; |
| 592 UpdateFromWebContents(web_contents); | 582 UpdateFromWebContents(web_contents); |
| 593 return old_icon != icon_id_ && old_badge_icon != icon_badge_id_; | 583 return old_icon != icon_ && old_badge_icon != icon_badge_; |
| 594 } | 584 } |
| 595 #endif | 585 #endif |
| OLD | NEW |