Chromium Code Reviews| 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/website_settings/website_settings.h" | 5 #include "chrome/browser/ui/website_settings/website_settings.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/i18n/time_formatting.h" | 12 #include "base/i18n/time_formatting.h" |
| 13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
| 17 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 17 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
| 18 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 18 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
| 19 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" | 19 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
| 20 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 20 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| 21 #include "chrome/browser/browsing_data/browsing_data_server_bound_cert_helper.h" | 21 #include "chrome/browser/browsing_data/browsing_data_server_bound_cert_helper.h" |
| 22 #include "chrome/browser/content_settings/content_settings_utils.h" | 22 #include "chrome/browser/content_settings/content_settings_utils.h" |
| 23 #include "chrome/browser/content_settings/host_content_settings_map.h" | 23 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 24 #include "chrome/browser/content_settings/local_shared_objects_container.h" | 24 #include "chrome/browser/content_settings/local_shared_objects_container.h" |
| 25 #include "chrome/browser/infobars/infobar_tab_helper.h" | |
| 25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/history/history_service_factory.h" | 27 #include "chrome/browser/history/history_service_factory.h" |
| 27 #include "chrome/browser/ssl/ssl_error_info.h" | 28 #include "chrome/browser/ssl/ssl_error_info.h" |
| 29 #include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h " | |
| 28 #include "chrome/browser/ui/website_settings/website_settings_ui.h" | 30 #include "chrome/browser/ui/website_settings/website_settings_ui.h" |
| 29 #include "chrome/common/content_settings_pattern.h" | 31 #include "chrome/common/content_settings_pattern.h" |
| 30 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
| 31 #include "content/public/browser/cert_store.h" | 33 #include "content/public/browser/cert_store.h" |
| 32 #include "content/public/common/ssl_status.h" | 34 #include "content/public/common/ssl_status.h" |
| 33 #include "content/public/common/url_constants.h" | 35 #include "content/public/common/url_constants.h" |
| 34 #include "grit/chromium_strings.h" | 36 #include "grit/chromium_strings.h" |
| 35 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
| 36 #include "net/base/cert_status_flags.h" | 38 #include "net/base/cert_status_flags.h" |
| 37 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 39 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 57 CONTENT_SETTINGS_TYPE_MOUSELOCK, | 59 CONTENT_SETTINGS_TYPE_MOUSELOCK, |
| 58 CONTENT_SETTINGS_TYPE_MEDIASTREAM, | 60 CONTENT_SETTINGS_TYPE_MEDIASTREAM, |
| 59 }; | 61 }; |
| 60 | 62 |
| 61 } // namespace | 63 } // namespace |
| 62 | 64 |
| 63 WebsiteSettings::WebsiteSettings( | 65 WebsiteSettings::WebsiteSettings( |
| 64 WebsiteSettingsUI* ui, | 66 WebsiteSettingsUI* ui, |
| 65 Profile* profile, | 67 Profile* profile, |
| 66 TabSpecificContentSettings* tab_specific_content_settings, | 68 TabSpecificContentSettings* tab_specific_content_settings, |
| 69 InfoBarTabHelper* infobar_tab_helper, | |
| 67 const GURL& url, | 70 const GURL& url, |
| 68 const content::SSLStatus& ssl, | 71 const content::SSLStatus& ssl, |
| 69 content::CertStore* cert_store) | 72 content::CertStore* cert_store) |
| 70 : TabSpecificContentSettings::SiteDataObserver( | 73 : TabSpecificContentSettings::SiteDataObserver( |
| 71 tab_specific_content_settings), | 74 tab_specific_content_settings), |
| 72 ui_(ui), | 75 ui_(ui), |
| 76 infobar_helper_(infobar_tab_helper), | |
| 77 show_info_bar_(false), | |
| 73 site_url_(url), | 78 site_url_(url), |
| 74 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN), | 79 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN), |
| 75 cert_id_(0), | 80 cert_id_(0), |
| 76 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN), | 81 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN), |
| 77 cert_store_(cert_store), | 82 cert_store_(cert_store), |
| 78 content_settings_(profile->GetHostContentSettingsMap()) { | 83 content_settings_(profile->GetHostContentSettingsMap()) { |
| 79 Init(profile, url, ssl); | 84 Init(profile, url, ssl); |
| 80 | 85 |
| 81 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 86 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
| 82 profile, Profile::EXPLICIT_ACCESS); | 87 profile, Profile::EXPLICIT_ACCESS); |
| 83 if (history_service) { | 88 if (history_service) { |
| 84 history_service->GetVisibleVisitCountToHost( | 89 history_service->GetVisibleVisitCountToHost( |
| 85 site_url_, | 90 site_url_, |
| 86 &visit_count_request_consumer_, | 91 &visit_count_request_consumer_, |
| 87 base::Bind(&WebsiteSettings::OnGotVisitCountToHost, | 92 base::Bind(&WebsiteSettings::OnGotVisitCountToHost, |
| 88 base::Unretained(this))); | 93 base::Unretained(this))); |
| 89 } | 94 } |
| 90 | 95 |
| 91 PresentSitePermissions(); | 96 PresentSitePermissions(); |
| 92 PresentSiteData(); | 97 PresentSiteData(); |
| 93 PresentSiteIdentity(); | 98 PresentSiteIdentity(); |
| 94 PresentHistoryInfo(base::Time()); | 99 PresentHistoryInfo(base::Time()); |
| 95 } | 100 } |
| 96 | 101 |
| 97 WebsiteSettings::~WebsiteSettings() { | 102 WebsiteSettings::~WebsiteSettings() { |
|
Finnur
2012/08/01 08:23:58
This class is only alive while the UI is being sho
markusheintz_
2012/08/01 08:59:01
yes. It used to be the other way around.
| |
| 98 } | 103 } |
| 99 | 104 |
| 100 void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type, | 105 void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type, |
| 101 ContentSetting setting) { | 106 ContentSetting setting) { |
| 102 ContentSettingsPattern primary_pattern; | 107 ContentSettingsPattern primary_pattern; |
| 103 ContentSettingsPattern secondary_pattern; | 108 ContentSettingsPattern secondary_pattern; |
| 104 switch (type) { | 109 switch (type) { |
| 105 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 110 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 106 // TODO(markusheintz): The rule we create here should also change the | 111 // TODO(markusheintz): The rule we create here should also change the |
| 107 // location permission for iframed content. | 112 // location permission for iframed content. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 r2 != ContentSettingsPattern::DISJOINT_ORDER_PRE); | 155 r2 != ContentSettingsPattern::DISJOINT_ORDER_PRE); |
| 151 if (r2 == ContentSettingsPattern::PREDECESSOR) | 156 if (r2 == ContentSettingsPattern::PREDECESSOR) |
| 152 secondary_pattern = info.secondary_pattern; | 157 secondary_pattern = info.secondary_pattern; |
| 153 } | 158 } |
| 154 | 159 |
| 155 Value* value = NULL; | 160 Value* value = NULL; |
| 156 if (setting != CONTENT_SETTING_DEFAULT) | 161 if (setting != CONTENT_SETTING_DEFAULT) |
| 157 value = Value::CreateIntegerValue(setting); | 162 value = Value::CreateIntegerValue(setting); |
| 158 content_settings_->SetWebsiteSetting( | 163 content_settings_->SetWebsiteSetting( |
| 159 primary_pattern, secondary_pattern, type, "", value); | 164 primary_pattern, secondary_pattern, type, "", value); |
| 165 show_info_bar_ = true; | |
| 160 } | 166 } |
| 161 | 167 |
| 162 void WebsiteSettings::OnGotVisitCountToHost(HistoryService::Handle handle, | 168 void WebsiteSettings::OnGotVisitCountToHost(HistoryService::Handle handle, |
| 163 bool found_visits, | 169 bool found_visits, |
| 164 int visit_count, | 170 int visit_count, |
| 165 base::Time first_visit) { | 171 base::Time first_visit) { |
| 166 if (!found_visits) { | 172 if (!found_visits) { |
| 167 // This indicates an error, such as the page's URL scheme wasn't | 173 // This indicates an error, such as the page's URL scheme wasn't |
| 168 // http/https. | 174 // http/https. |
| 169 first_visit = base::Time(); | 175 first_visit = base::Time(); |
| 170 } else if (visit_count == 0) { | 176 } else if (visit_count == 0) { |
| 171 first_visit = base::Time::Now(); | 177 first_visit = base::Time::Now(); |
| 172 } | 178 } |
| 173 PresentHistoryInfo(first_visit); | 179 PresentHistoryInfo(first_visit); |
| 174 } | 180 } |
| 175 | 181 |
| 176 void WebsiteSettings::OnSiteDataAccessed() { | 182 void WebsiteSettings::OnSiteDataAccessed() { |
| 177 PresentSiteData(); | 183 PresentSiteData(); |
| 178 } | 184 } |
| 179 | 185 |
| 186 void WebsiteSettings::OnUIClosing() { | |
| 187 if (show_info_bar_) { | |
| 188 infobar_helper_->AddInfoBar( | |
| 189 new WebsiteSettingsInfobarDelegate(infobar_helper_)); | |
| 190 } | |
| 191 } | |
| 192 | |
| 180 void WebsiteSettings::Init(Profile* profile, | 193 void WebsiteSettings::Init(Profile* profile, |
| 181 const GURL& url, | 194 const GURL& url, |
| 182 const content::SSLStatus& ssl) { | 195 const content::SSLStatus& ssl) { |
| 183 if (url.SchemeIs(chrome::kChromeUIScheme)) { | 196 if (url.SchemeIs(chrome::kChromeUIScheme)) { |
| 184 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE; | 197 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE; |
| 185 site_identity_details_ = | 198 site_identity_details_ = |
| 186 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE); | 199 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE); |
| 187 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE; | 200 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE; |
| 188 return; | 201 return; |
| 189 } | 202 } |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 first_visit_text = l10n_util::GetStringFUTF16( | 507 first_visit_text = l10n_util::GetStringFUTF16( |
| 495 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY, | 508 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY, |
| 496 base::TimeFormatShortDate(first_visit)); | 509 base::TimeFormatShortDate(first_visit)); |
| 497 } else { | 510 } else { |
| 498 first_visit_text = l10n_util::GetStringUTF16( | 511 first_visit_text = l10n_util::GetStringUTF16( |
| 499 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY); | 512 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY); |
| 500 | 513 |
| 501 } | 514 } |
| 502 ui_->SetFirstVisit(first_visit_text); | 515 ui_->SetFirstVisit(first_visit_text); |
| 503 } | 516 } |
| OLD | NEW |