| 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_->BlacklistPassword(); | |
| 111 return true; | |
| 112 } | |
| 113 | |
| 114 TabSpecificContentSettings* TabSpecificContentSettings::Get( | 102 TabSpecificContentSettings* TabSpecificContentSettings::Get( |
| 115 int render_process_id, int render_view_id) { | 103 int render_process_id, int render_view_id) { |
| 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 117 | 105 |
| 118 RenderViewHost* view = RenderViewHost::FromID(render_process_id, | 106 RenderViewHost* view = RenderViewHost::FromID(render_process_id, |
| 119 render_view_id); | 107 render_view_id); |
| 120 if (!view) | 108 if (!view) |
| 121 return NULL; | 109 return NULL; |
| 122 | 110 |
| 123 WebContents* web_contents = WebContents::FromRenderViewHost(view); | 111 WebContents* web_contents = WebContents::FromRenderViewHost(view); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 void TabSpecificContentSettings::OnGeolocationPermissionSet( | 456 void TabSpecificContentSettings::OnGeolocationPermissionSet( |
| 469 const GURL& requesting_origin, | 457 const GURL& requesting_origin, |
| 470 bool allowed) { | 458 bool allowed) { |
| 471 geolocation_usages_state_.OnPermissionSet(requesting_origin, allowed); | 459 geolocation_usages_state_.OnPermissionSet(requesting_origin, allowed); |
| 472 content::NotificationService::current()->Notify( | 460 content::NotificationService::current()->Notify( |
| 473 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 461 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
| 474 content::Source<WebContents>(web_contents()), | 462 content::Source<WebContents>(web_contents()), |
| 475 content::NotificationService::NoDetails()); | 463 content::NotificationService::NoDetails()); |
| 476 } | 464 } |
| 477 | 465 |
| 466 // TODO(npentrel): Save the password when user accepts the prompt |
| 478 void TabSpecificContentSettings::OnPasswordSubmitted( | 467 void TabSpecificContentSettings::OnPasswordSubmitted( |
| 479 PasswordFormManager* form_to_save) { | 468 PasswordFormManager* form_to_save) { |
| 480 form_to_save_.reset(form_to_save); | |
| 481 OnContentAllowed(CONTENT_SETTINGS_TYPE_SAVE_PASSWORD); | 469 OnContentAllowed(CONTENT_SETTINGS_TYPE_SAVE_PASSWORD); |
| 482 NotifySiteDataObservers(); | 470 NotifySiteDataObservers(); |
| 483 } | 471 } |
| 484 | 472 |
| 485 TabSpecificContentSettings::PasswordSavingState | 473 TabSpecificContentSettings::PasswordSavingState |
| 486 TabSpecificContentSettings::GetPasswordSavingState() const { | 474 TabSpecificContentSettings::GetPasswordSavingState() const { |
| 487 if (IsContentAllowed(CONTENT_SETTINGS_TYPE_SAVE_PASSWORD)) | 475 if (IsContentAllowed(CONTENT_SETTINGS_TYPE_SAVE_PASSWORD)) |
| 488 return PASSWORD_TO_BE_SAVED; | 476 return PASSWORD_TO_BE_SAVED; |
| 489 else | 477 else |
| 490 return NO_PASSWORD_TO_BE_SAVED; | 478 return NO_PASSWORD_TO_BE_SAVED; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 IPC_BEGIN_MESSAGE_MAP(TabSpecificContentSettings, message) | 640 IPC_BEGIN_MESSAGE_MAP(TabSpecificContentSettings, message) |
| 653 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ContentBlocked, OnContentBlocked) | 641 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ContentBlocked, OnContentBlocked) |
| 654 IPC_MESSAGE_UNHANDLED(handled = false) | 642 IPC_MESSAGE_UNHANDLED(handled = false) |
| 655 IPC_END_MESSAGE_MAP() | 643 IPC_END_MESSAGE_MAP() |
| 656 return handled; | 644 return handled; |
| 657 } | 645 } |
| 658 | 646 |
| 659 void TabSpecificContentSettings::DidNavigateMainFrame( | 647 void TabSpecificContentSettings::DidNavigateMainFrame( |
| 660 const content::LoadCommittedDetails& details, | 648 const content::LoadCommittedDetails& details, |
| 661 const content::FrameNavigateParams& params) { | 649 const content::FrameNavigateParams& params) { |
| 662 if (form_to_save_) | |
| 663 form_to_save_->ApplyChange(); | |
| 664 if (!details.is_in_page) { | 650 if (!details.is_in_page) { |
| 665 // Clear "blocked" flags. | 651 // Clear "blocked" flags. |
| 666 ClearBlockedContentSettingsExceptForCookies(); | 652 ClearBlockedContentSettingsExceptForCookies(); |
| 667 GeolocationDidNavigate(details); | 653 GeolocationDidNavigate(details); |
| 668 MIDIDidNavigate(details); | 654 MIDIDidNavigate(details); |
| 669 } | 655 } |
| 670 } | 656 } |
| 671 | 657 |
| 672 void TabSpecificContentSettings::DidStartProvisionalLoadForFrame( | 658 void TabSpecificContentSettings::DidStartProvisionalLoadForFrame( |
| 673 int64 frame_id, | 659 int64 frame_id, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 } | 717 } |
| 732 | 718 |
| 733 void TabSpecificContentSettings::RemoveSiteDataObserver( | 719 void TabSpecificContentSettings::RemoveSiteDataObserver( |
| 734 SiteDataObserver* observer) { | 720 SiteDataObserver* observer) { |
| 735 observer_list_.RemoveObserver(observer); | 721 observer_list_.RemoveObserver(observer); |
| 736 } | 722 } |
| 737 | 723 |
| 738 void TabSpecificContentSettings::NotifySiteDataObservers() { | 724 void TabSpecificContentSettings::NotifySiteDataObservers() { |
| 739 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); | 725 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); |
| 740 } | 726 } |
| OLD | NEW |