| 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/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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   96           CONTENT_SETTINGS_TYPE_GEOLOCATION), |   96           CONTENT_SETTINGS_TYPE_GEOLOCATION), | 
|   97       midi_usages_state_( |   97       midi_usages_state_( | 
|   98           HostContentSettingsMapFactory::GetForProfile( |   98           HostContentSettingsMapFactory::GetForProfile( | 
|   99               Profile::FromBrowserContext(tab->GetBrowserContext())), |   99               Profile::FromBrowserContext(tab->GetBrowserContext())), | 
|  100           CONTENT_SETTINGS_TYPE_MIDI_SYSEX), |  100           CONTENT_SETTINGS_TYPE_MIDI_SYSEX), | 
|  101       pending_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), |  101       pending_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), | 
|  102       previous_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), |  102       previous_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), | 
|  103       pending_protocol_handler_setting_(CONTENT_SETTING_DEFAULT), |  103       pending_protocol_handler_setting_(CONTENT_SETTING_DEFAULT), | 
|  104       load_plugins_link_enabled_(true), |  104       load_plugins_link_enabled_(true), | 
|  105       microphone_camera_state_(MICROPHONE_CAMERA_NOT_ACCESSED), |  105       microphone_camera_state_(MICROPHONE_CAMERA_NOT_ACCESSED), | 
 |  106       subresource_filter_enabled_(false), | 
 |  107       subresource_filter_blockage_indicated_(false), | 
|  106       observer_(this) { |  108       observer_(this) { | 
|  107   ClearBlockedContentSettingsExceptForCookies(); |  109   ClearBlockedContentSettingsExceptForCookies(); | 
|  108   ClearCookieSpecificContentSettings(); |  110   ClearCookieSpecificContentSettings(); | 
|  109  |  111  | 
|  110   observer_.Add(HostContentSettingsMapFactory::GetForProfile( |  112   observer_.Add(HostContentSettingsMapFactory::GetForProfile( | 
|  111       Profile::FromBrowserContext(tab->GetBrowserContext()))); |  113       Profile::FromBrowserContext(tab->GetBrowserContext()))); | 
|  112 } |  114 } | 
|  113  |  115  | 
|  114 TabSpecificContentSettings::~TabSpecificContentSettings() { |  116 TabSpecificContentSettings::~TabSpecificContentSettings() { | 
|  115   FOR_EACH_OBSERVER( |  117   FOR_EACH_OBSERVER( | 
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  250       content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX || |  252       content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX || | 
|  251       content_type == CONTENT_SETTINGS_TYPE_KEYGEN) { |  253       content_type == CONTENT_SETTINGS_TYPE_KEYGEN) { | 
|  252     const auto& it = content_settings_status_.find(content_type); |  254     const auto& it = content_settings_status_.find(content_type); | 
|  253     if (it != content_settings_status_.end()) |  255     if (it != content_settings_status_.end()) | 
|  254       return it->second.blocked; |  256       return it->second.blocked; | 
|  255   } |  257   } | 
|  256  |  258  | 
|  257   return false; |  259   return false; | 
|  258 } |  260 } | 
|  259  |  261  | 
 |  262 bool TabSpecificContentSettings::IsSubresourceBlocked() const { | 
 |  263   return subresource_filter_enabled_; | 
 |  264 } | 
 |  265  | 
|  260 bool TabSpecificContentSettings::IsBlockageIndicated( |  266 bool TabSpecificContentSettings::IsBlockageIndicated( | 
|  261     ContentSettingsType content_type) const { |  267     ContentSettingsType content_type) const { | 
|  262   const auto& it = content_settings_status_.find(content_type); |  268   const auto& it = content_settings_status_.find(content_type); | 
|  263   if (it != content_settings_status_.end()) |  269   if (it != content_settings_status_.end()) | 
|  264     return it->second.blockage_indicated_to_user; |  270     return it->second.blockage_indicated_to_user; | 
|  265   return false; |  271   return false; | 
|  266 } |  272 } | 
|  267  |  273  | 
 |  274 bool TabSpecificContentSettings::IsSubresourceBlockageIndicated() const { | 
 |  275   return subresource_filter_blockage_indicated_; | 
 |  276 } | 
 |  277  | 
|  268 void TabSpecificContentSettings::SetBlockageHasBeenIndicated( |  278 void TabSpecificContentSettings::SetBlockageHasBeenIndicated( | 
|  269     ContentSettingsType content_type) { |  279     ContentSettingsType content_type) { | 
|  270   content_settings_status_[content_type].blockage_indicated_to_user = true; |  280   content_settings_status_[content_type].blockage_indicated_to_user = true; | 
|  271 } |  281 } | 
|  272  |  282  | 
 |  283 void TabSpecificContentSettings::SetSubresourceBlockageIndicated() { | 
 |  284   subresource_filter_blockage_indicated_ = true; | 
 |  285 } | 
 |  286  | 
|  273 bool TabSpecificContentSettings::IsContentAllowed( |  287 bool TabSpecificContentSettings::IsContentAllowed( | 
|  274     ContentSettingsType content_type) const { |  288     ContentSettingsType content_type) const { | 
|  275   // This method currently only returns meaningful values for the content type |  289   // This method currently only returns meaningful values for the content type | 
|  276   // cookies, media, PPAPI broker, downloads, and MIDI sysex. |  290   // cookies, media, PPAPI broker, downloads, and MIDI sysex. | 
|  277   if (content_type != CONTENT_SETTINGS_TYPE_COOKIES && |  291   if (content_type != CONTENT_SETTINGS_TYPE_COOKIES && | 
|  278       content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC && |  292       content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC && | 
|  279       content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA && |  293       content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA && | 
|  280       content_type != CONTENT_SETTINGS_TYPE_PPAPI_BROKER && |  294       content_type != CONTENT_SETTINGS_TYPE_PPAPI_BROKER && | 
|  281       content_type != CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS && |  295       content_type != CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS && | 
|  282       content_type != CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { |  296       content_type != CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { | 
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  683   ContentSettingsStatus& status = |  697   ContentSettingsStatus& status = | 
|  684       content_settings_status_[CONTENT_SETTINGS_TYPE_POPUPS]; |  698       content_settings_status_[CONTENT_SETTINGS_TYPE_POPUPS]; | 
|  685   status.blocked = blocked; |  699   status.blocked = blocked; | 
|  686   status.blockage_indicated_to_user = false; |  700   status.blockage_indicated_to_user = false; | 
|  687   content::NotificationService::current()->Notify( |  701   content::NotificationService::current()->Notify( | 
|  688       chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |  702       chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 
|  689       content::Source<WebContents>(web_contents()), |  703       content::Source<WebContents>(web_contents()), | 
|  690       content::NotificationService::NoDetails()); |  704       content::NotificationService::NoDetails()); | 
|  691 } |  705 } | 
|  692  |  706  | 
 |  707 void TabSpecificContentSettings::SetSubresourceBlocked(bool enabled) { | 
 |  708   subresource_filter_enabled_ = enabled; | 
 |  709 } | 
 |  710  | 
|  693 void TabSpecificContentSettings::SetPepperBrokerAllowed(bool allowed) { |  711 void TabSpecificContentSettings::SetPepperBrokerAllowed(bool allowed) { | 
|  694   if (allowed) { |  712   if (allowed) { | 
|  695     OnContentAllowed(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); |  713     OnContentAllowed(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); | 
|  696   } else { |  714   } else { | 
|  697     OnContentBlocked(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); |  715     OnContentBlocked(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); | 
|  698   } |  716   } | 
|  699 } |  717 } | 
|  700  |  718  | 
|  701 void TabSpecificContentSettings::OnContentSettingChanged( |  719 void TabSpecificContentSettings::OnContentSettingChanged( | 
|  702     const ContentSettingsPattern& primary_pattern, |  720     const ContentSettingsPattern& primary_pattern, | 
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  849       static_cast<MicrophoneCameraStateFlags>( |  867       static_cast<MicrophoneCameraStateFlags>( | 
|  850           TabSpecificContentSettings::MICROPHONE_ACCESSED | |  868           TabSpecificContentSettings::MICROPHONE_ACCESSED | | 
|  851           TabSpecificContentSettings::MICROPHONE_BLOCKED | |  869           TabSpecificContentSettings::MICROPHONE_BLOCKED | | 
|  852           TabSpecificContentSettings::CAMERA_ACCESSED | |  870           TabSpecificContentSettings::CAMERA_ACCESSED | | 
|  853           TabSpecificContentSettings::CAMERA_BLOCKED); |  871           TabSpecificContentSettings::CAMERA_BLOCKED); | 
|  854   OnMediaStreamPermissionSet( |  872   OnMediaStreamPermissionSet( | 
|  855       web_contents()->GetLastCommittedURL(), |  873       web_contents()->GetLastCommittedURL(), | 
|  856       media_blocked, |  874       media_blocked, | 
|  857       std::string(), std::string(), std::string(), std::string()); |  875       std::string(), std::string(), std::string(), std::string()); | 
|  858 } |  876 } | 
| OLD | NEW |