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

Side by Side Diff: chrome/browser/content_settings/tab_specific_content_settings.cc

Issue 20990005: Web MIDI: implement permission infobar (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disable icon for now Created 7 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 | Annotate | Revision Log
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/content_settings/tab_specific_content_settings.h" 5 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 void TabSpecificContentSettings::SiteDataObserver::ContentSettingsDestroyed() { 73 void TabSpecificContentSettings::SiteDataObserver::ContentSettingsDestroyed() {
74 tab_specific_content_settings_ = NULL; 74 tab_specific_content_settings_ = NULL;
75 } 75 }
76 76
77 TabSpecificContentSettings::TabSpecificContentSettings(WebContents* tab) 77 TabSpecificContentSettings::TabSpecificContentSettings(WebContents* tab)
78 : content::WebContentsObserver(tab), 78 : content::WebContentsObserver(tab),
79 profile_(Profile::FromBrowserContext(tab->GetBrowserContext())), 79 profile_(Profile::FromBrowserContext(tab->GetBrowserContext())),
80 allowed_local_shared_objects_(profile_), 80 allowed_local_shared_objects_(profile_),
81 blocked_local_shared_objects_(profile_), 81 blocked_local_shared_objects_(profile_),
82 geolocation_usages_state_(profile_, CONTENT_SETTINGS_TYPE_GEOLOCATION), 82 geolocation_usages_state_(profile_, CONTENT_SETTINGS_TYPE_GEOLOCATION),
83 midi_usages_state_(profile_, CONTENT_SETTINGS_TYPE_MIDI_SYSEX),
83 pending_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), 84 pending_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()),
84 previous_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), 85 previous_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()),
85 pending_protocol_handler_setting_(CONTENT_SETTING_DEFAULT), 86 pending_protocol_handler_setting_(CONTENT_SETTING_DEFAULT),
86 load_plugins_link_enabled_(true) { 87 load_plugins_link_enabled_(true) {
87 ClearBlockedContentSettingsExceptForCookies(); 88 ClearBlockedContentSettingsExceptForCookies();
88 ClearCookieSpecificContentSettings(); 89 ClearCookieSpecificContentSettings();
89 90
90 registrar_.Add(this, chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED, 91 registrar_.Add(this, chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED,
91 content::Source<HostContentSettingsMap>( 92 content::Source<HostContentSettingsMap>(
92 profile_->GetHostContentSettingsMap())); 93 profile_->GetHostContentSettingsMap()));
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || 205 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES ||
205 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || 206 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT ||
206 content_type == CONTENT_SETTINGS_TYPE_PLUGINS || 207 content_type == CONTENT_SETTINGS_TYPE_PLUGINS ||
207 content_type == CONTENT_SETTINGS_TYPE_COOKIES || 208 content_type == CONTENT_SETTINGS_TYPE_COOKIES ||
208 content_type == CONTENT_SETTINGS_TYPE_POPUPS || 209 content_type == CONTENT_SETTINGS_TYPE_POPUPS ||
209 content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT || 210 content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT ||
210 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM || 211 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM ||
211 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || 212 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
212 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA || 213 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA ||
213 content_type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER || 214 content_type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER ||
214 content_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) { 215 content_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS ||
216 content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
215 return content_blocked_[content_type]; 217 return content_blocked_[content_type];
216 } 218 }
217 219
218 return false; 220 return false;
219 } 221 }
220 222
221 bool TabSpecificContentSettings::IsBlockageIndicated( 223 bool TabSpecificContentSettings::IsBlockageIndicated(
222 ContentSettingsType content_type) const { 224 ContentSettingsType content_type) const {
223 return content_blockage_indicated_to_user_[content_type]; 225 return content_blockage_indicated_to_user_[content_type];
224 } 226 }
225 227
226 void TabSpecificContentSettings::SetBlockageHasBeenIndicated( 228 void TabSpecificContentSettings::SetBlockageHasBeenIndicated(
227 ContentSettingsType content_type) { 229 ContentSettingsType content_type) {
228 content_blockage_indicated_to_user_[content_type] = true; 230 content_blockage_indicated_to_user_[content_type] = true;
229 } 231 }
230 232
231 bool TabSpecificContentSettings::IsContentAllowed( 233 bool TabSpecificContentSettings::IsContentAllowed(
232 ContentSettingsType content_type) const { 234 ContentSettingsType content_type) const {
233 // This method currently only returns meaningful values for the content type 235 // This method currently only returns meaningful values for the content type
234 // cookies, mediastream, PPAPI broker, and downloads. 236 // cookies, mediastream, PPAPI broker, and downloads.
235 if (content_type != CONTENT_SETTINGS_TYPE_COOKIES && 237 if (content_type != CONTENT_SETTINGS_TYPE_COOKIES &&
236 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM && 238 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM &&
237 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC && 239 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC &&
238 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA && 240 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA &&
239 content_type != CONTENT_SETTINGS_TYPE_PPAPI_BROKER && 241 content_type != CONTENT_SETTINGS_TYPE_PPAPI_BROKER &&
240 content_type != CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) { 242 content_type != CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS &&
243 content_type != CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
241 return false; 244 return false;
242 } 245 }
243 246
244 return content_allowed_[content_type]; 247 return content_allowed_[content_type];
245 } 248 }
246 249
247 const std::set<std::string>& 250 const std::set<std::string>&
248 TabSpecificContentSettings::BlockedResourcesForType( 251 TabSpecificContentSettings::BlockedResourcesForType(
249 ContentSettingsType content_type) const { 252 ContentSettingsType content_type) const {
250 if (blocked_resources_[content_type].get()) { 253 if (blocked_resources_[content_type].get()) {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 } 492 }
490 493
491 void TabSpecificContentSettings::OnCameraAccessed() { 494 void TabSpecificContentSettings::OnCameraAccessed() {
492 OnContentAllowed(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 495 OnContentAllowed(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
493 } 496 }
494 497
495 void TabSpecificContentSettings::OnCameraAccessBlocked() { 498 void TabSpecificContentSettings::OnCameraAccessBlocked() {
496 OnContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string()); 499 OnContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string());
497 } 500 }
498 501
502 void TabSpecificContentSettings::OnMIDISysExAccessed(
503 const GURL& requesting_origin) {
504 midi_usages_state_.OnPermissionSet(requesting_origin, true);
505 // TODO(toyoshim): Bubble iconfor MIDI is disabled for now.
Bernhard Bauer 2013/07/31 15:35:39 Nit: "icon for MIDI"
Takashi Toyoshima 2013/08/01 07:43:09 Done.
506 // http://crbug.com/257618 .
507 // OnContentAllowed(CONTENT_SETTINGS_TYPE_MIDI_SYSEX);
508 }
509
510 void TabSpecificContentSettings::OnMIDISysExAccessBlocked(
511 const GURL& requesting_origin) {
512 midi_usages_state_.OnPermissionSet(requesting_origin, false);
513 // TODO(toyoshim): Bubble iconfor MIDI is disabled for now.
scherkus (not reviewing) 2013/07/31 18:09:55 fix typos here s/iconfor/icon for/ s/MIDI is/MID
Takashi Toyoshima 2013/08/01 08:27:38 Done.
514 // http://crbug.com/257618 .
scherkus (not reviewing) 2013/07/31 18:09:55 remove trailing whitespace and period
Takashi Toyoshima 2013/08/01 08:27:38 Done.
515 // OnContentBlocked(CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string());
516 }
517
499 void TabSpecificContentSettings::ClearBlockedContentSettingsExceptForCookies() { 518 void TabSpecificContentSettings::ClearBlockedContentSettingsExceptForCookies() {
500 for (size_t i = 0; i < arraysize(content_blocked_); ++i) { 519 for (size_t i = 0; i < arraysize(content_blocked_); ++i) {
501 if (i == CONTENT_SETTINGS_TYPE_COOKIES) 520 if (i == CONTENT_SETTINGS_TYPE_COOKIES)
502 continue; 521 continue;
503 blocked_resources_[i].reset(); 522 blocked_resources_[i].reset();
504 content_blocked_[i] = false; 523 content_blocked_[i] = false;
505 content_allowed_[i] = false; 524 content_allowed_[i] = false;
506 content_blockage_indicated_to_user_[i] = false; 525 content_blockage_indicated_to_user_[i] = false;
507 } 526 }
508 load_plugins_link_enabled_ = true; 527 load_plugins_link_enabled_ = true;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, 561 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED,
543 content::Source<WebContents>(web_contents()), 562 content::Source<WebContents>(web_contents()),
544 content::NotificationService::NoDetails()); 563 content::NotificationService::NoDetails());
545 } 564 }
546 565
547 void TabSpecificContentSettings::GeolocationDidNavigate( 566 void TabSpecificContentSettings::GeolocationDidNavigate(
548 const content::LoadCommittedDetails& details) { 567 const content::LoadCommittedDetails& details) {
549 geolocation_usages_state_.DidNavigate(details); 568 geolocation_usages_state_.DidNavigate(details);
550 } 569 }
551 570
571 void TabSpecificContentSettings::MIDIDidNavigate(
572 const content::LoadCommittedDetails& details) {
573 midi_usages_state_.DidNavigate(details);
574 }
575
552 void TabSpecificContentSettings::ClearGeolocationContentSettings() { 576 void TabSpecificContentSettings::ClearGeolocationContentSettings() {
553 geolocation_usages_state_.ClearStateMap(); 577 geolocation_usages_state_.ClearStateMap();
554 } 578 }
555 579
580 void TabSpecificContentSettings::ClearMIDIContentSettings() {
581 midi_usages_state_.ClearStateMap();
582 }
583
556 void TabSpecificContentSettings::SetPepperBrokerAllowed(bool allowed) { 584 void TabSpecificContentSettings::SetPepperBrokerAllowed(bool allowed) {
557 if (allowed) { 585 if (allowed) {
558 OnContentAllowed(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); 586 OnContentAllowed(CONTENT_SETTINGS_TYPE_PPAPI_BROKER);
559 } else { 587 } else {
560 OnContentBlocked(CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string()); 588 OnContentBlocked(CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string());
561 } 589 }
562 } 590 }
563 591
564 void TabSpecificContentSettings::RenderViewForInterstitialPageCreated( 592 void TabSpecificContentSettings::RenderViewForInterstitialPageCreated(
565 RenderViewHost* render_view_host) { 593 RenderViewHost* render_view_host) {
(...skipping 12 matching lines...) Expand all
578 return handled; 606 return handled;
579 } 607 }
580 608
581 void TabSpecificContentSettings::DidNavigateMainFrame( 609 void TabSpecificContentSettings::DidNavigateMainFrame(
582 const content::LoadCommittedDetails& details, 610 const content::LoadCommittedDetails& details,
583 const content::FrameNavigateParams& params) { 611 const content::FrameNavigateParams& params) {
584 if (!details.is_in_page) { 612 if (!details.is_in_page) {
585 // Clear "blocked" flags. 613 // Clear "blocked" flags.
586 ClearBlockedContentSettingsExceptForCookies(); 614 ClearBlockedContentSettingsExceptForCookies();
587 GeolocationDidNavigate(details); 615 GeolocationDidNavigate(details);
616 MIDIDidNavigate(details);
588 } 617 }
589 } 618 }
590 619
591 void TabSpecificContentSettings::DidStartProvisionalLoadForFrame( 620 void TabSpecificContentSettings::DidStartProvisionalLoadForFrame(
592 int64 frame_id, 621 int64 frame_id,
593 int64 parent_frame_id, 622 int64 parent_frame_id,
594 bool is_main_frame, 623 bool is_main_frame,
595 const GURL& validated_url, 624 const GURL& validated_url,
596 bool is_error_page, 625 bool is_error_page,
597 bool is_iframe_srcdoc, 626 bool is_iframe_srcdoc,
598 RenderViewHost* render_view_host) { 627 RenderViewHost* render_view_host) {
599 if (!is_main_frame) 628 if (!is_main_frame)
600 return; 629 return;
601 630
602 // If we're displaying a network error page do not reset the content 631 // If we're displaying a network error page do not reset the content
603 // settings delegate's cookies so the user has a chance to modify cookie 632 // settings delegate's cookies so the user has a chance to modify cookie
604 // settings. 633 // settings.
605 if (!is_error_page) 634 if (!is_error_page)
606 ClearCookieSpecificContentSettings(); 635 ClearCookieSpecificContentSettings();
607 ClearGeolocationContentSettings(); 636 ClearGeolocationContentSettings();
637 ClearMIDIContentSettings();
608 } 638 }
609 639
610 void TabSpecificContentSettings::AppCacheAccessed(const GURL& manifest_url, 640 void TabSpecificContentSettings::AppCacheAccessed(const GURL& manifest_url,
611 bool blocked_by_policy) { 641 bool blocked_by_policy) {
612 if (blocked_by_policy) { 642 if (blocked_by_policy) {
613 blocked_local_shared_objects_.appcaches()->AddAppCache(manifest_url); 643 blocked_local_shared_objects_.appcaches()->AddAppCache(manifest_url);
614 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string()); 644 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string());
615 } else { 645 } else {
616 allowed_local_shared_objects_.appcaches()->AddAppCache(manifest_url); 646 allowed_local_shared_objects_.appcaches()->AddAppCache(manifest_url);
617 OnContentAllowed(CONTENT_SETTINGS_TYPE_COOKIES); 647 OnContentAllowed(CONTENT_SETTINGS_TYPE_COOKIES);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 } 679 }
650 680
651 void TabSpecificContentSettings::RemoveSiteDataObserver( 681 void TabSpecificContentSettings::RemoveSiteDataObserver(
652 SiteDataObserver* observer) { 682 SiteDataObserver* observer) {
653 observer_list_.RemoveObserver(observer); 683 observer_list_.RemoveObserver(observer);
654 } 684 }
655 685
656 void TabSpecificContentSettings::NotifySiteDataObservers() { 686 void TabSpecificContentSettings::NotifySiteDataObservers() {
657 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); 687 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed());
658 } 688 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698