| 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/website_settings.h" | 5 #include "chrome/browser/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" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "grit/chromium_strings.h" | 34 #include "grit/chromium_strings.h" |
| 35 #include "grit/generated_resources.h" | 35 #include "grit/generated_resources.h" |
| 36 #include "net/base/cert_status_flags.h" | 36 #include "net/base/cert_status_flags.h" |
| 37 #include "net/base/registry_controlled_domain.h" | 37 #include "net/base/registry_controlled_domain.h" |
| 38 #include "net/base/ssl_cipher_suite_names.h" | 38 #include "net/base/ssl_cipher_suite_names.h" |
| 39 #include "net/base/ssl_connection_status_flags.h" | 39 #include "net/base/ssl_connection_status_flags.h" |
| 40 #include "net/base/x509_certificate.h" | 40 #include "net/base/x509_certificate.h" |
| 41 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
| 42 #include "ui/base/resource/resource_bundle.h" | 42 #include "ui/base/resource/resource_bundle.h" |
| 43 | 43 |
| 44 #if defined(TOOLKIT_GTK) | |
| 45 #include "chrome/browser/ui/gtk/website_settings_popup_gtk.h" | |
| 46 #endif | |
| 47 | |
| 48 using content::BrowserThread; | 44 using content::BrowserThread; |
| 49 | 45 |
| 50 namespace { | 46 namespace { |
| 51 | 47 |
| 52 ContentSettingsType kPermissionType[] = { | 48 ContentSettingsType kPermissionType[] = { |
| 53 CONTENT_SETTINGS_TYPE_POPUPS, | 49 CONTENT_SETTINGS_TYPE_POPUPS, |
| 54 CONTENT_SETTINGS_TYPE_PLUGINS, | 50 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 55 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 51 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 56 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 52 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 57 }; | 53 }; |
| 58 | 54 |
| 59 } // namespace | 55 } // namespace |
| 60 | 56 |
| 61 WebsiteSettings::WebsiteSettings( | 57 WebsiteSettings::WebsiteSettings( |
| 62 WebsiteSettingsUI* ui, | 58 WebsiteSettingsUI* ui, |
| 63 Profile* profile, | 59 Profile* profile, |
| 64 TabSpecificContentSettings* tab_specific_content_settings, | 60 TabSpecificContentSettings* tab_specific_content_settings, |
| 65 const GURL& url, | 61 const GURL& url, |
| 66 const content::SSLStatus& ssl, | 62 const content::SSLStatus& ssl, |
| 67 content::CertStore* cert_store) | 63 content::CertStore* cert_store) |
| 68 : TabSpecificContentSettings::SiteDataObserver( | 64 : TabSpecificContentSettings::SiteDataObserver( |
| 69 tab_specific_content_settings), | 65 tab_specific_content_settings), |
| 70 ui_(ui), | 66 ui_(ui), |
| 71 site_url_(url), | 67 site_url_(url), |
| 72 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN), | 68 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN), |
| 73 cert_id_(0), | 69 cert_id_(0), |
| 74 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN), | 70 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN), |
| 75 cert_store_(cert_store), | 71 cert_store_(cert_store), |
| 76 content_settings_(profile->GetHostContentSettingsMap()) { | 72 content_settings_(profile->GetHostContentSettingsMap()) { |
| 77 ui_->SetPresenter(this); | |
| 78 Init(profile, url, ssl); | 73 Init(profile, url, ssl); |
| 79 | 74 |
| 80 HistoryService* history_service = | 75 HistoryService* history_service = |
| 81 profile->GetHistoryService(Profile::EXPLICIT_ACCESS); | 76 profile->GetHistoryService(Profile::EXPLICIT_ACCESS); |
| 82 if (history_service) { | 77 if (history_service) { |
| 83 history_service->GetVisibleVisitCountToHost( | 78 history_service->GetVisibleVisitCountToHost( |
| 84 site_url_, | 79 site_url_, |
| 85 &visit_count_request_consumer_, | 80 &visit_count_request_consumer_, |
| 86 base::Bind(&WebsiteSettings::OnGotVisitCountToHost, | 81 base::Bind(&WebsiteSettings::OnGotVisitCountToHost, |
| 87 base::Unretained(this))); | 82 base::Unretained(this))); |
| 88 } | 83 } |
| 89 | 84 |
| 90 PresentSitePermissions(); | 85 PresentSitePermissions(); |
| 91 PresentSiteData(); | 86 PresentSiteData(); |
| 92 PresentSiteIdentity(); | 87 PresentSiteIdentity(); |
| 93 PresentHistoryInfo(base::Time()); | 88 PresentHistoryInfo(base::Time()); |
| 94 } | 89 } |
| 95 | 90 |
| 96 WebsiteSettings::~WebsiteSettings() { | 91 WebsiteSettings::~WebsiteSettings() { |
| 97 } | 92 } |
| 98 | 93 |
| 99 void WebsiteSettings::OnUIClosing() { | |
| 100 ui_->SetPresenter(NULL); | |
| 101 delete this; | |
| 102 } | |
| 103 | |
| 104 void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type, | 94 void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type, |
| 105 ContentSetting setting) { | 95 ContentSetting setting) { |
| 106 ContentSettingsPattern primary_pattern; | 96 ContentSettingsPattern primary_pattern; |
| 107 ContentSettingsPattern secondary_pattern; | 97 ContentSettingsPattern secondary_pattern; |
| 108 switch (type) { | 98 switch (type) { |
| 109 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 99 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 110 // TODO(markusheintz): The rule we create here should also change the | 100 // TODO(markusheintz): The rule we create here should also change the |
| 111 // location permission for iframed content. | 101 // location permission for iframed content. |
| 112 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_); | 102 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_); |
| 113 secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_); | 103 secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 first_visit_text = l10n_util::GetStringFUTF16( | 485 first_visit_text = l10n_util::GetStringFUTF16( |
| 496 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY, | 486 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY, |
| 497 base::TimeFormatShortDate(first_visit)); | 487 base::TimeFormatShortDate(first_visit)); |
| 498 } else { | 488 } else { |
| 499 first_visit_text = l10n_util::GetStringUTF16( | 489 first_visit_text = l10n_util::GetStringUTF16( |
| 500 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY); | 490 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY); |
| 501 | 491 |
| 502 } | 492 } |
| 503 ui_->SetFirstVisit(first_visit_text); | 493 ui_->SetFirstVisit(first_visit_text); |
| 504 } | 494 } |
| 505 | |
| 506 // static | |
| 507 void WebsiteSettings::Show(gfx::NativeWindow parent, | |
| 508 Profile* profile, | |
| 509 TabContentsWrapper* tab_contents_wrapper, | |
| 510 const GURL& url, | |
| 511 const content::SSLStatus& ssl) { | |
| 512 #if defined(TOOLKIT_GTK) | |
| 513 // The WebsiteSettingsModel will delete itself after the UI is closed. | |
| 514 new WebsiteSettings(new WebsiteSettingsPopupGtk(parent, | |
| 515 profile, | |
| 516 tab_contents_wrapper), | |
| 517 profile, | |
| 518 tab_contents_wrapper->content_settings(), | |
| 519 url, | |
| 520 ssl, | |
| 521 content::CertStore::GetInstance()); | |
| 522 #endif | |
| 523 } | |
| OLD | NEW |