| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 registrar_.Add(this, chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED, | 92 registrar_.Add(this, chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED, |
| 93 content::Source<HostContentSettingsMap>( | 93 content::Source<HostContentSettingsMap>( |
| 94 profile_->GetHostContentSettingsMap())); | 94 profile_->GetHostContentSettingsMap())); |
| 95 } | 95 } |
| 96 | 96 |
| 97 TabSpecificContentSettings::~TabSpecificContentSettings() { | 97 TabSpecificContentSettings::~TabSpecificContentSettings() { |
| 98 FOR_EACH_OBSERVER( | 98 FOR_EACH_OBSERVER( |
| 99 SiteDataObserver, observer_list_, ContentSettingsDestroyed()); | 99 SiteDataObserver, observer_list_, ContentSettingsDestroyed()); |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool TabSpecificContentSettings::PasswordAccepted() { |
| 103 DCHECK(form_to_save_.get()); |
| 104 form_to_save_->SavePassword(); |
| 105 return true; |
| 106 } |
| 107 |
| 108 bool TabSpecificContentSettings::PasswordFormBlacklisted() { |
| 109 DCHECK(form_to_save_.get()); |
| 110 form_to_save_->PermanentlyBlacklist(); |
| 111 return true; |
| 112 } |
| 113 |
| 102 TabSpecificContentSettings* TabSpecificContentSettings::Get( | 114 TabSpecificContentSettings* TabSpecificContentSettings::Get( |
| 103 int render_process_id, int render_view_id) { | 115 int render_process_id, int render_view_id) { |
| 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 105 | 117 |
| 106 RenderViewHost* view = RenderViewHost::FromID(render_process_id, | 118 RenderViewHost* view = RenderViewHost::FromID(render_process_id, |
| 107 render_view_id); | 119 render_view_id); |
| 108 if (!view) | 120 if (!view) |
| 109 return NULL; | 121 return NULL; |
| 110 | 122 |
| 111 WebContents* web_contents = WebContents::FromRenderViewHost(view); | 123 WebContents* web_contents = WebContents::FromRenderViewHost(view); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 void TabSpecificContentSettings::OnGeolocationPermissionSet( | 468 void TabSpecificContentSettings::OnGeolocationPermissionSet( |
| 457 const GURL& requesting_origin, | 469 const GURL& requesting_origin, |
| 458 bool allowed) { | 470 bool allowed) { |
| 459 geolocation_usages_state_.OnPermissionSet(requesting_origin, allowed); | 471 geolocation_usages_state_.OnPermissionSet(requesting_origin, allowed); |
| 460 content::NotificationService::current()->Notify( | 472 content::NotificationService::current()->Notify( |
| 461 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 473 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
| 462 content::Source<WebContents>(web_contents()), | 474 content::Source<WebContents>(web_contents()), |
| 463 content::NotificationService::NoDetails()); | 475 content::NotificationService::NoDetails()); |
| 464 } | 476 } |
| 465 | 477 |
| 466 // TODO(npentrel): Save the password when user accepts the prompt | |
| 467 void TabSpecificContentSettings::OnPasswordSubmitted( | 478 void TabSpecificContentSettings::OnPasswordSubmitted( |
| 468 PasswordFormManager* form_to_save) { | 479 PasswordFormManager* form_to_save) { |
| 480 form_to_save_.reset(form_to_save); |
| 469 OnContentAllowed(CONTENT_SETTINGS_TYPE_SAVE_PASSWORD); | 481 OnContentAllowed(CONTENT_SETTINGS_TYPE_SAVE_PASSWORD); |
| 470 NotifySiteDataObservers(); | 482 NotifySiteDataObservers(); |
| 471 } | 483 } |
| 472 | 484 |
| 473 TabSpecificContentSettings::PasswordSavingState | 485 TabSpecificContentSettings::PasswordSavingState |
| 474 TabSpecificContentSettings::GetPasswordSavingState() const { | 486 TabSpecificContentSettings::GetPasswordSavingState() const { |
| 475 if (IsContentAllowed(CONTENT_SETTINGS_TYPE_SAVE_PASSWORD)) | 487 if (IsContentAllowed(CONTENT_SETTINGS_TYPE_SAVE_PASSWORD)) |
| 476 return PASSWORD_TO_BE_SAVED; | 488 return PASSWORD_TO_BE_SAVED; |
| 477 else | 489 else |
| 478 return NO_PASSWORD_TO_BE_SAVED; | 490 return NO_PASSWORD_TO_BE_SAVED; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 } | 729 } |
| 718 | 730 |
| 719 void TabSpecificContentSettings::RemoveSiteDataObserver( | 731 void TabSpecificContentSettings::RemoveSiteDataObserver( |
| 720 SiteDataObserver* observer) { | 732 SiteDataObserver* observer) { |
| 721 observer_list_.RemoveObserver(observer); | 733 observer_list_.RemoveObserver(observer); |
| 722 } | 734 } |
| 723 | 735 |
| 724 void TabSpecificContentSettings::NotifySiteDataObservers() { | 736 void TabSpecificContentSettings::NotifySiteDataObservers() { |
| 725 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); | 737 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); |
| 726 } | 738 } |
| OLD | NEW |