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/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 // The image models hierarchy: | 36 // The image models hierarchy: |
37 // | 37 // |
38 // ContentSettingImageModel - base class | 38 // ContentSettingImageModel - base class |
39 // ContentSettingSimpleImageModel - single content setting | 39 // ContentSettingSimpleImageModel - single content setting |
40 // ContentSettingBlockedImageModel - generic blocked setting | 40 // ContentSettingBlockedImageModel - generic blocked setting |
41 // ContentSettingGeolocationImageModel - geolocation | 41 // ContentSettingGeolocationImageModel - geolocation |
42 // ContentSettingRPHImageModel - protocol handlers | 42 // ContentSettingRPHImageModel - protocol handlers |
43 // ContentSettingMIDISysExImageModel - midi sysex | 43 // ContentSettingMIDISysExImageModel - midi sysex |
44 // ContentSettingMediaImageModel - media | 44 // ContentSettingMediaImageModel - media |
| 45 // ContentSettingSubresourceFilterImageModel - deceptive content |
45 | 46 |
46 class ContentSettingBlockedImageModel : public ContentSettingSimpleImageModel { | 47 class ContentSettingBlockedImageModel : public ContentSettingSimpleImageModel { |
47 public: | 48 public: |
48 explicit ContentSettingBlockedImageModel(ContentSettingsType content_type); | 49 explicit ContentSettingBlockedImageModel(ContentSettingsType content_type); |
49 | 50 |
50 void UpdateFromWebContents(WebContents* web_contents) override; | 51 void UpdateFromWebContents(WebContents* web_contents) override; |
51 | 52 |
52 private: | 53 private: |
53 DISALLOW_COPY_AND_ASSIGN(ContentSettingBlockedImageModel); | 54 DISALLOW_COPY_AND_ASSIGN(ContentSettingBlockedImageModel); |
54 }; | 55 }; |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 ContentSettingBubbleModel::Delegate* delegate, | 413 ContentSettingBubbleModel::Delegate* delegate, |
413 WebContents* web_contents, | 414 WebContents* web_contents, |
414 Profile* profile) { | 415 Profile* profile) { |
415 return new ContentSettingMediaStreamBubbleModel(delegate, | 416 return new ContentSettingMediaStreamBubbleModel(delegate, |
416 web_contents, | 417 web_contents, |
417 profile); | 418 profile); |
418 } | 419 } |
419 | 420 |
420 bool ContentSettingMediaImageModel::ShouldRunAnimation( | 421 bool ContentSettingMediaImageModel::ShouldRunAnimation( |
421 WebContents* web_contents) { | 422 WebContents* web_contents) { |
422 // TODO(msramek): For bubbles that are not tied to a single content setting, | |
423 // TabSpecificContentSettings is not a good place to store this bit. | |
424 // Perhaps we should instead use a map<WebContents*, bool> here in | |
425 // ContentSettingMediaImageModel. | |
426 if (!web_contents) | 423 if (!web_contents) |
427 return false; | 424 return false; |
428 TabSpecificContentSettings* content_settings = | 425 TabSpecificContentSettings* content_settings = |
429 TabSpecificContentSettings::FromWebContents(web_contents); | 426 TabSpecificContentSettings::FromWebContents(web_contents); |
430 if (!content_settings) | 427 if (!content_settings) |
431 return false; | 428 return false; |
432 return (!content_settings->IsBlockageIndicated( | 429 return (!content_settings->IsBlockageIndicated( |
433 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) && | 430 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) && |
434 !content_settings->IsBlockageIndicated( | 431 !content_settings->IsBlockageIndicated( |
435 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 432 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
436 } | 433 } |
437 | 434 |
438 void ContentSettingMediaImageModel::SetAnimationHasRun( | 435 void ContentSettingMediaImageModel::SetAnimationHasRun( |
439 WebContents* web_contents) { | 436 WebContents* web_contents) { |
440 if (!web_contents) | 437 if (!web_contents) |
441 return; | 438 return; |
442 TabSpecificContentSettings* content_settings = | 439 TabSpecificContentSettings* content_settings = |
443 TabSpecificContentSettings::FromWebContents(web_contents); | 440 TabSpecificContentSettings::FromWebContents(web_contents); |
444 if (content_settings) { | 441 if (content_settings) { |
445 content_settings->SetBlockageHasBeenIndicated( | 442 content_settings->SetBlockageHasBeenIndicated( |
446 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 443 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
447 content_settings->SetBlockageHasBeenIndicated( | 444 content_settings->SetBlockageHasBeenIndicated( |
448 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 445 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
449 } | 446 } |
450 } | 447 } |
451 | 448 |
| 449 // Subresource Filter ---------------------------------------------------------- |
| 450 |
| 451 ContentSettingSubresourceFilterImageModel:: |
| 452 ContentSettingSubresourceFilterImageModel() |
| 453 : ContentSettingImageModel() {} |
| 454 |
| 455 void ContentSettingSubresourceFilterImageModel::UpdateFromWebContents( |
| 456 WebContents* web_contents) { |
| 457 set_visible(false); |
| 458 |
| 459 if (!web_contents) |
| 460 return; |
| 461 |
| 462 TabSpecificContentSettings* content_settings = |
| 463 TabSpecificContentSettings::FromWebContents(web_contents); |
| 464 |
| 465 if (!content_settings || !content_settings->IsSubresourceBlocked()) |
| 466 return; |
| 467 |
| 468 set_icon_by_vector_id(gfx::VectorIconId::SUBRESOURCE_FILTER_ACTIVE, |
| 469 gfx::VectorIconId::BLOCKED_BADGE); |
| 470 set_explanatory_string_id(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_TITLE); |
| 471 // TODO(melandory): Set tooltip text. |
| 472 set_visible(true); |
| 473 } |
| 474 |
| 475 ContentSettingBubbleModel* |
| 476 ContentSettingSubresourceFilterImageModel::CreateBubbleModel( |
| 477 ContentSettingBubbleModel::Delegate* delegate, |
| 478 WebContents* web_contents, |
| 479 Profile* profile) { |
| 480 return new ContentSettingSubresourceFilterBubbleModel(delegate, web_contents, |
| 481 profile); |
| 482 } |
| 483 |
| 484 bool ContentSettingSubresourceFilterImageModel::ShouldRunAnimation( |
| 485 WebContents* web_contents) { |
| 486 if (!web_contents) |
| 487 return false; |
| 488 TabSpecificContentSettings* content_settings = |
| 489 TabSpecificContentSettings::FromWebContents(web_contents); |
| 490 return content_settings && content_settings->IsSubresourceBlockageIndicated(); |
| 491 } |
| 492 |
| 493 void ContentSettingSubresourceFilterImageModel::SetAnimationHasRun( |
| 494 WebContents* web_contents) { |
| 495 if (!web_contents) |
| 496 return; |
| 497 TabSpecificContentSettings* content_settings = |
| 498 TabSpecificContentSettings::FromWebContents(web_contents); |
| 499 if (content_settings) |
| 500 content_settings->SetSubresourceBlockageIndicated(); |
| 501 } |
| 502 |
452 // Protocol handlers ----------------------------------------------------------- | 503 // Protocol handlers ----------------------------------------------------------- |
453 | 504 |
454 ContentSettingRPHImageModel::ContentSettingRPHImageModel() | 505 ContentSettingRPHImageModel::ContentSettingRPHImageModel() |
455 : ContentSettingSimpleImageModel(CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { | 506 : ContentSettingSimpleImageModel(CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { |
456 if (!UseVectorGraphics()) { | 507 if (!UseVectorGraphics()) { |
457 SetIconByResourceId(IDR_REGISTER_PROTOCOL_HANDLER); | 508 SetIconByResourceId(IDR_REGISTER_PROTOCOL_HANDLER); |
458 } else { | 509 } else { |
459 set_icon_by_vector_id(gfx::VectorIconId::PROTOCOL_HANDLER, | 510 set_icon_by_vector_id(gfx::VectorIconId::PROTOCOL_HANDLER, |
460 gfx::VectorIconId::VECTOR_ICON_NONE); | 511 gfx::VectorIconId::VECTOR_ICON_NONE); |
461 } | 512 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_PPAPI_BROKER)); | 607 new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_PPAPI_BROKER)); |
557 result.push_back( | 608 result.push_back( |
558 new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_PLUGINS)); | 609 new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_PLUGINS)); |
559 result.push_back( | 610 result.push_back( |
560 new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_POPUPS)); | 611 new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_POPUPS)); |
561 result.push_back(new ContentSettingGeolocationImageModel()); | 612 result.push_back(new ContentSettingGeolocationImageModel()); |
562 result.push_back( | 613 result.push_back( |
563 new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); | 614 new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); |
564 result.push_back(new ContentSettingRPHImageModel()); | 615 result.push_back(new ContentSettingRPHImageModel()); |
565 result.push_back(new ContentSettingMediaImageModel()); | 616 result.push_back(new ContentSettingMediaImageModel()); |
| 617 result.push_back(new ContentSettingSubresourceFilterImageModel()); |
566 result.push_back( | 618 result.push_back( |
567 new ContentSettingBlockedImageModel( | 619 new ContentSettingBlockedImageModel( |
568 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS)); | 620 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS)); |
569 result.push_back(new ContentSettingMIDISysExImageModel()); | 621 result.push_back(new ContentSettingMIDISysExImageModel()); |
570 | 622 |
571 return result; | 623 return result; |
572 } | 624 } |
573 | 625 |
574 void ContentSettingImageModel::SetIconByResourceId(int id) { | 626 void ContentSettingImageModel::SetIconByResourceId(int id) { |
575 raster_icon_id_ = id; | 627 raster_icon_id_ = id; |
(...skipping 10 matching lines...) Expand all Loading... |
586 UpdateFromWebContents(web_contents); | 638 UpdateFromWebContents(web_contents); |
587 return old_vector_icon != vector_icon_id_ && | 639 return old_vector_icon != vector_icon_id_ && |
588 old_badge_icon != vector_icon_badge_id_; | 640 old_badge_icon != vector_icon_badge_id_; |
589 } else { | 641 } else { |
590 int old_icon = raster_icon_id_; | 642 int old_icon = raster_icon_id_; |
591 UpdateFromWebContents(web_contents); | 643 UpdateFromWebContents(web_contents); |
592 return old_icon != raster_icon_id_; | 644 return old_icon != raster_icon_id_; |
593 } | 645 } |
594 } | 646 } |
595 #endif | 647 #endif |
OLD | NEW |