Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_image_model.cc

Issue 2171713002: Safe browsing subresource filter bubble UI skeleton. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: xib with osx 10.9 Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 WebContents* web_contents, 76 WebContents* web_contents,
77 Profile* profile) override; 77 Profile* profile) override;
78 78
79 bool ShouldRunAnimation(WebContents* web_contents) override; 79 bool ShouldRunAnimation(WebContents* web_contents) override;
80 void SetAnimationHasRun(WebContents* web_contents) override; 80 void SetAnimationHasRun(WebContents* web_contents) override;
81 81
82 private: 82 private:
83 DISALLOW_COPY_AND_ASSIGN(ContentSettingMediaImageModel); 83 DISALLOW_COPY_AND_ASSIGN(ContentSettingMediaImageModel);
84 }; 84 };
85 85
86 // Image model for subresource filter icons in the location bar.
87 class ContentSettingSubresourceFilterImageModel
msramek 2016/07/27 09:46:21 Please update the hierarchy comment at the top of
melandory 2016/07/27 12:53:41 Done.
88 : public ContentSettingImageModel {
89 public:
90 ContentSettingSubresourceFilterImageModel();
91
92 void UpdateFromWebContents(WebContents* web_contents) override;
93
94 ContentSettingBubbleModel* CreateBubbleModel(
95 ContentSettingBubbleModel::Delegate* delegate,
96 WebContents* web_contents,
97 Profile* profile) override;
98
99 bool ShouldRunAnimation(content::WebContents* web_contents) override;
100 void SetAnimationHasRun(content::WebContents* web_contents) override;
101
102 private:
103 DISALLOW_COPY_AND_ASSIGN(ContentSettingSubresourceFilterImageModel);
104 };
105
86 class ContentSettingRPHImageModel : public ContentSettingSimpleImageModel { 106 class ContentSettingRPHImageModel : public ContentSettingSimpleImageModel {
87 public: 107 public:
88 ContentSettingRPHImageModel(); 108 ContentSettingRPHImageModel();
89 109
90 void UpdateFromWebContents(WebContents* web_contents) override; 110 void UpdateFromWebContents(WebContents* web_contents) override;
91 }; 111 };
92 112
93 class ContentSettingMIDISysExImageModel 113 class ContentSettingMIDISysExImageModel
94 : public ContentSettingSimpleImageModel { 114 : public ContentSettingSimpleImageModel {
95 public: 115 public:
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 if (content_settings_type == CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) 254 if (content_settings_type == CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS)
235 return base::WrapUnique(new ContentSettingRPHImageModel()); 255 return base::WrapUnique(new ContentSettingRPHImageModel());
236 256
237 if (content_settings_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) 257 if (content_settings_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX)
238 return base::WrapUnique(new ContentSettingMIDISysExImageModel()); 258 return base::WrapUnique(new ContentSettingMIDISysExImageModel());
239 259
240 return base::WrapUnique( 260 return base::WrapUnique(
241 new ContentSettingBlockedImageModel(content_settings_type)); 261 new ContentSettingBlockedImageModel(content_settings_type));
242 } 262 }
243 263
264 std::unique_ptr<ContentSettingImageModel>
265 ContentSettingImageModel::CreateSubresourceFilterImageModelForTesting() {
266 return base::WrapUnique(new ContentSettingSubresourceFilterImageModel());
267 }
268
244 // Generic blocked content settings -------------------------------------------- 269 // Generic blocked content settings --------------------------------------------
245 270
246 ContentSettingBlockedImageModel::ContentSettingBlockedImageModel( 271 ContentSettingBlockedImageModel::ContentSettingBlockedImageModel(
247 ContentSettingsType content_type) 272 ContentSettingsType content_type)
248 : ContentSettingSimpleImageModel(content_type) { 273 : ContentSettingSimpleImageModel(content_type) {
249 } 274 }
250 275
251 void ContentSettingBlockedImageModel::UpdateFromWebContents( 276 void ContentSettingBlockedImageModel::UpdateFromWebContents(
252 WebContents* web_contents) { 277 WebContents* web_contents) {
253 set_visible(false); 278 set_visible(false);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 ContentSettingBubbleModel::Delegate* delegate, 437 ContentSettingBubbleModel::Delegate* delegate,
413 WebContents* web_contents, 438 WebContents* web_contents,
414 Profile* profile) { 439 Profile* profile) {
415 return new ContentSettingMediaStreamBubbleModel(delegate, 440 return new ContentSettingMediaStreamBubbleModel(delegate,
416 web_contents, 441 web_contents,
417 profile); 442 profile);
418 } 443 }
419 444
420 bool ContentSettingMediaImageModel::ShouldRunAnimation( 445 bool ContentSettingMediaImageModel::ShouldRunAnimation(
421 WebContents* web_contents) { 446 WebContents* web_contents) {
422 // TODO(msramek): For bubbles that are not tied to a single content setting, 447 // TODO(msramek): For bubbles that are not tied to a single content setting,
msramek 2016/07/27 09:46:21 This TODO now applies to ContentSettingSubresource
melandory 2016/07/27 12:53:41 Hope that "this is not ideal" expresses relevant l
423 // TabSpecificContentSettings is not a good place to store this bit. 448 // TabSpecificContentSettings is not a good place to store this bit.
424 // Perhaps we should instead use a map<WebContents*, bool> here in 449 // Perhaps we should instead use a map<WebContents*, bool> here in
425 // ContentSettingMediaImageModel. 450 // ContentSettingMediaImageModel.
426 if (!web_contents) 451 if (!web_contents)
427 return false; 452 return false;
428 TabSpecificContentSettings* content_settings = 453 TabSpecificContentSettings* content_settings =
429 TabSpecificContentSettings::FromWebContents(web_contents); 454 TabSpecificContentSettings::FromWebContents(web_contents);
430 if (!content_settings) 455 if (!content_settings)
431 return false; 456 return false;
432 return (!content_settings->IsBlockageIndicated( 457 return (!content_settings->IsBlockageIndicated(
433 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) && 458 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) &&
434 !content_settings->IsBlockageIndicated( 459 !content_settings->IsBlockageIndicated(
435 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); 460 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA));
436 } 461 }
437 462
438 void ContentSettingMediaImageModel::SetAnimationHasRun( 463 void ContentSettingMediaImageModel::SetAnimationHasRun(
439 WebContents* web_contents) { 464 WebContents* web_contents) {
440 if (!web_contents) 465 if (!web_contents)
441 return; 466 return;
442 TabSpecificContentSettings* content_settings = 467 TabSpecificContentSettings* content_settings =
443 TabSpecificContentSettings::FromWebContents(web_contents); 468 TabSpecificContentSettings::FromWebContents(web_contents);
444 if (content_settings) { 469 if (content_settings) {
445 content_settings->SetBlockageHasBeenIndicated( 470 content_settings->SetBlockageHasBeenIndicated(
446 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); 471 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
447 content_settings->SetBlockageHasBeenIndicated( 472 content_settings->SetBlockageHasBeenIndicated(
448 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 473 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
449 } 474 }
450 } 475 }
451 476
477 // Subresource Filter ----------------------------------------------------------
478
479 ContentSettingSubresourceFilterImageModel::
480 ContentSettingSubresourceFilterImageModel()
481 : ContentSettingImageModel() {}
482
483 void ContentSettingSubresourceFilterImageModel::UpdateFromWebContents(
484 WebContents* web_contents) {
485 set_visible(false);
486
487 if (!web_contents)
488 return;
489
490 TabSpecificContentSettings* content_settings =
491 TabSpecificContentSettings::FromWebContents(web_contents);
492
493 if (!content_settings || !content_settings->is_subresource_filter_enabled())
494 return;
495
496 if (!UseVectorGraphics()) {
497 SetIconByResourceId(IDR_SUBRESOURCE_FILTER_ACTIVE);
498 } else {
499 set_icon_by_vector_id(gfx::VectorIconId::SUBRESOURCE_FILTER_ACTIVE,
500 gfx::VectorIconId::VECTOR_ICON_NONE);
501 }
502 set_explanatory_string_id(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_TITLE);
503 // TODO(melandory): Set tooltip text.
504 set_visible(true);
505 }
506
507 ContentSettingBubbleModel*
508 ContentSettingSubresourceFilterImageModel::CreateBubbleModel(
509 ContentSettingBubbleModel::Delegate* delegate,
510 WebContents* web_contents,
511 Profile* profile) {
512 return new ContentSettingSubresourceFilterBubbleModel(delegate, web_contents,
513 profile);
514 }
515
516 bool ContentSettingSubresourceFilterImageModel::ShouldRunAnimation(
517 WebContents* web_contents) {
518 if (!web_contents)
519 return false;
520 TabSpecificContentSettings* content_settings =
521 TabSpecificContentSettings::FromWebContents(web_contents);
522 return content_settings && content_settings->is_subresource_filter_enabled();
msramek 2016/07/27 09:46:21 This should check if the blockage has been *indica
melandory 2016/07/27 12:53:41 Done.
523 }
524
525 void ContentSettingSubresourceFilterImageModel::SetAnimationHasRun(
526 WebContents* web_contents) {
527 if (!web_contents)
528 return;
529 TabSpecificContentSettings* content_settings =
530 TabSpecificContentSettings::FromWebContents(web_contents);
531 if (content_settings)
532 content_settings->SetSubresourceBlockageIndicated();
533 }
534
452 // Protocol handlers ----------------------------------------------------------- 535 // Protocol handlers -----------------------------------------------------------
453 536
454 ContentSettingRPHImageModel::ContentSettingRPHImageModel() 537 ContentSettingRPHImageModel::ContentSettingRPHImageModel()
455 : ContentSettingSimpleImageModel(CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { 538 : ContentSettingSimpleImageModel(CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) {
456 if (!UseVectorGraphics()) { 539 if (!UseVectorGraphics()) {
457 SetIconByResourceId(IDR_REGISTER_PROTOCOL_HANDLER); 540 SetIconByResourceId(IDR_REGISTER_PROTOCOL_HANDLER);
458 } else { 541 } else {
459 set_icon_by_vector_id(gfx::VectorIconId::PROTOCOL_HANDLER, 542 set_icon_by_vector_id(gfx::VectorIconId::PROTOCOL_HANDLER,
460 gfx::VectorIconId::VECTOR_ICON_NONE); 543 gfx::VectorIconId::VECTOR_ICON_NONE);
461 } 544 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_PPAPI_BROKER)); 639 new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_PPAPI_BROKER));
557 result.push_back( 640 result.push_back(
558 new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_PLUGINS)); 641 new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_PLUGINS));
559 result.push_back( 642 result.push_back(
560 new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_POPUPS)); 643 new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_POPUPS));
561 result.push_back(new ContentSettingGeolocationImageModel()); 644 result.push_back(new ContentSettingGeolocationImageModel());
562 result.push_back( 645 result.push_back(
563 new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); 646 new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT));
564 result.push_back(new ContentSettingRPHImageModel()); 647 result.push_back(new ContentSettingRPHImageModel());
565 result.push_back(new ContentSettingMediaImageModel()); 648 result.push_back(new ContentSettingMediaImageModel());
649 result.push_back(new ContentSettingSubresourceFilterImageModel());
566 result.push_back( 650 result.push_back(
567 new ContentSettingBlockedImageModel( 651 new ContentSettingBlockedImageModel(
568 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS)); 652 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS));
569 result.push_back(new ContentSettingMIDISysExImageModel()); 653 result.push_back(new ContentSettingMIDISysExImageModel());
570 654
571 return result; 655 return result;
572 } 656 }
573 657
574 void ContentSettingImageModel::SetIconByResourceId(int id) { 658 void ContentSettingImageModel::SetIconByResourceId(int id) {
575 raster_icon_id_ = id; 659 raster_icon_id_ = id;
(...skipping 10 matching lines...) Expand all
586 UpdateFromWebContents(web_contents); 670 UpdateFromWebContents(web_contents);
587 return old_vector_icon != vector_icon_id_ && 671 return old_vector_icon != vector_icon_id_ &&
588 old_badge_icon != vector_icon_badge_id_; 672 old_badge_icon != vector_icon_badge_id_;
589 } else { 673 } else {
590 int old_icon = raster_icon_id_; 674 int old_icon = raster_icon_id_;
591 UpdateFromWebContents(web_contents); 675 UpdateFromWebContents(web_contents);
592 return old_icon != raster_icon_id_; 676 return old_icon != raster_icon_id_;
593 } 677 }
594 } 678 }
595 #endif 679 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698