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

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

Issue 2458453002: [sensors] Add Permission guard to the generic sensor apis.
Patch Set: rebase + blink reformat Created 3 years, 8 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/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"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 ContentSettingsType content_settings_type) { 211 ContentSettingsType content_settings_type) {
212 if (content_settings_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) 212 if (content_settings_type == CONTENT_SETTINGS_TYPE_GEOLOCATION)
213 return base::MakeUnique<ContentSettingGeolocationImageModel>(); 213 return base::MakeUnique<ContentSettingGeolocationImageModel>();
214 214
215 if (content_settings_type == CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) 215 if (content_settings_type == CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS)
216 return base::MakeUnique<ContentSettingRPHImageModel>(); 216 return base::MakeUnique<ContentSettingRPHImageModel>();
217 217
218 if (content_settings_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) 218 if (content_settings_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX)
219 return base::MakeUnique<ContentSettingMIDISysExImageModel>(); 219 return base::MakeUnique<ContentSettingMIDISysExImageModel>();
220 220
221 if (content_settings_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) 221 if (content_settings_type == CONTENT_SETTINGS_TYPE_SENSORS)
222 return base::MakeUnique<ContentSettingDownloadsImageModel>(); 222 return base::MakeUnique<ContentSettingSensorImageModel>();
223 223
224 return base::MakeUnique<ContentSettingBlockedImageModel>( 224 return base::MakeUnique<ContentSettingBlockedImageModel>(
225 content_settings_type); 225 content_settings_type);
226 } 226 }
227 227
228 // Generic blocked content settings -------------------------------------------- 228 // Generic blocked content settings --------------------------------------------
229 229
230 ContentSettingBlockedImageModel::ContentSettingBlockedImageModel( 230 ContentSettingBlockedImageModel::ContentSettingBlockedImageModel(
231 ContentSettingsType content_type) 231 ContentSettingsType content_type)
232 : ContentSettingSimpleImageModel(content_type) { 232 : ContentSettingSimpleImageModel(content_type) {
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 unsigned int state_flags = 0; 519 unsigned int state_flags = 0;
520 usages_state.GetDetailedInfo(nullptr, &state_flags); 520 usages_state.GetDetailedInfo(nullptr, &state_flags);
521 bool allowed = 521 bool allowed =
522 !!(state_flags & ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED); 522 !!(state_flags & ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED);
523 set_icon(ui::kMidiIcon, allowed ? gfx::kNoneIcon : kBlockedBadgeIcon); 523 set_icon(ui::kMidiIcon, allowed ? gfx::kNoneIcon : kBlockedBadgeIcon);
524 set_tooltip(l10n_util::GetStringUTF16(allowed 524 set_tooltip(l10n_util::GetStringUTF16(allowed
525 ? IDS_MIDI_SYSEX_ALLOWED_TOOLTIP 525 ? IDS_MIDI_SYSEX_ALLOWED_TOOLTIP
526 : IDS_MIDI_SYSEX_BLOCKED_TOOLTIP)); 526 : IDS_MIDI_SYSEX_BLOCKED_TOOLTIP));
527 } 527 }
528 528
529 // Sensors ------------------------------------------------------------------
530
531 ContentSettingSensorImageModel::ContentSettingSensorImageModel()
532 : ContentSettingSimpleImageModel(CONTENT_SETTINGS_TYPE_SENSORS) {}
533
534 void ContentSettingSensorImageModel::UpdateFromWebContents(
535 WebContents* web_contents) {
536 set_visible(false);
537 if (!web_contents)
538 return;
539 TabSpecificContentSettings* content_settings =
540 TabSpecificContentSettings::FromWebContents(web_contents);
541 if (!content_settings)
542 return;
543 // TODO(riju): when UMA is ready.
544 set_visible(true);
545
546 // If any embedded site has access the allowed icon takes priority over the
547 // blocked icon.
548 unsigned int state_flags = 0;
549 bool allowed =
550 !!(state_flags & ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED);
551 set_icon_by_vector_id(gfx::VectorIconId::MIDI, // TODO(riju)
552 allowed ? gfx::VectorIconId::VECTOR_ICON_NONE
553 : gfx::VectorIconId::BLOCKED_BADGE);
554 set_tooltip(l10n_util::GetStringUTF16(allowed ? IDS_SENSORS_ALLOWED_TOOLTIP
555 : IDS_SENSORS_BLOCKED_TOOLTIP));
556 }
557
529 // Automatic downloads --------------------------------------------------------- 558 // Automatic downloads ---------------------------------------------------------
530 559
531 ContentSettingDownloadsImageModel::ContentSettingDownloadsImageModel() 560 ContentSettingDownloadsImageModel::ContentSettingDownloadsImageModel()
532 : ContentSettingSimpleImageModel( 561 : ContentSettingSimpleImageModel(
533 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) {} 562 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) {}
534 563
535 void ContentSettingDownloadsImageModel::UpdateFromWebContents( 564 void ContentSettingDownloadsImageModel::UpdateFromWebContents(
536 WebContents* web_contents) { 565 WebContents* web_contents) {
537 set_visible(false); 566 set_visible(false);
538 if (!web_contents) 567 if (!web_contents)
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 663
635 #if defined(OS_MACOSX) 664 #if defined(OS_MACOSX)
636 bool ContentSettingImageModel::UpdateFromWebContentsAndCheckIfIconChanged( 665 bool ContentSettingImageModel::UpdateFromWebContentsAndCheckIfIconChanged(
637 content::WebContents* web_contents) { 666 content::WebContents* web_contents) {
638 const gfx::VectorIcon* old_icon = icon_; 667 const gfx::VectorIcon* old_icon = icon_;
639 const gfx::VectorIcon* old_badge_icon = icon_badge_; 668 const gfx::VectorIcon* old_badge_icon = icon_badge_;
640 UpdateFromWebContents(web_contents); 669 UpdateFromWebContents(web_contents);
641 return old_icon != icon_ && old_badge_icon != icon_badge_; 670 return old_icon != icon_ && old_badge_icon != icon_badge_;
642 } 671 }
643 #endif 672 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/content_settings/content_setting_bubble_model.cc ('k') | chrome/browser/ui/page_info/page_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698