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 |
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 IPC_BEGIN_MESSAGE_MAP(TabSpecificContentSettings, message) | 652 IPC_BEGIN_MESSAGE_MAP(TabSpecificContentSettings, message) |
641 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ContentBlocked, OnContentBlocked) | 653 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ContentBlocked, OnContentBlocked) |
642 IPC_MESSAGE_UNHANDLED(handled = false) | 654 IPC_MESSAGE_UNHANDLED(handled = false) |
643 IPC_END_MESSAGE_MAP() | 655 IPC_END_MESSAGE_MAP() |
644 return handled; | 656 return handled; |
645 } | 657 } |
646 | 658 |
647 void TabSpecificContentSettings::DidNavigateMainFrame( | 659 void TabSpecificContentSettings::DidNavigateMainFrame( |
648 const content::LoadCommittedDetails& details, | 660 const content::LoadCommittedDetails& details, |
649 const content::FrameNavigateParams& params) { | 661 const content::FrameNavigateParams& params) { |
| 662 if (form_to_save_) |
| 663 form_to_save_->ApplyChange(); |
650 if (!details.is_in_page) { | 664 if (!details.is_in_page) { |
651 // Clear "blocked" flags. | 665 // Clear "blocked" flags. |
652 ClearBlockedContentSettingsExceptForCookies(); | 666 ClearBlockedContentSettingsExceptForCookies(); |
653 GeolocationDidNavigate(details); | 667 GeolocationDidNavigate(details); |
654 MIDIDidNavigate(details); | 668 MIDIDidNavigate(details); |
655 } | 669 } |
656 } | 670 } |
657 | 671 |
658 void TabSpecificContentSettings::DidStartProvisionalLoadForFrame( | 672 void TabSpecificContentSettings::DidStartProvisionalLoadForFrame( |
659 int64 frame_id, | 673 int64 frame_id, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 } | 731 } |
718 | 732 |
719 void TabSpecificContentSettings::RemoveSiteDataObserver( | 733 void TabSpecificContentSettings::RemoveSiteDataObserver( |
720 SiteDataObserver* observer) { | 734 SiteDataObserver* observer) { |
721 observer_list_.RemoveObserver(observer); | 735 observer_list_.RemoveObserver(observer); |
722 } | 736 } |
723 | 737 |
724 void TabSpecificContentSettings::NotifySiteDataObservers() { | 738 void TabSpecificContentSettings::NotifySiteDataObservers() { |
725 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); | 739 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); |
726 } | 740 } |
OLD | NEW |