Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_bubble_model.cc

Issue 23980003: Save password functionality added to the save password bubble (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/content_settings/content_setting_bubble_model.h" 5 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/content_settings/content_settings_utils.h" 11 #include "chrome/browser/content_settings/content_settings_utils.h"
12 #include "chrome/browser/content_settings/cookie_settings.h" 12 #include "chrome/browser/content_settings/cookie_settings.h"
13 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
14 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 13 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
15 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" 14 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
16 #include "chrome/browser/favicon/favicon_tab_helper.h" 15 #include "chrome/browser/favicon/favicon_tab_helper.h"
17 #include "chrome/browser/infobars/infobar_service.h" 16 #include "chrome/browser/infobars/infobar_service.h"
18 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 17 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
19 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" 18 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
20 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" 20 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
22 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate. h" 21 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate. h"
23 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" 22 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_LINK}, 156 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_LINK},
158 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LINK}, 157 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LINK},
159 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_LINK}, 158 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_LINK},
160 {CONTENT_SETTINGS_TYPE_GEOLOCATION, IDS_GEOLOCATION_BUBBLE_MANAGE_LINK}, 159 {CONTENT_SETTINGS_TYPE_GEOLOCATION, IDS_GEOLOCATION_BUBBLE_MANAGE_LINK},
161 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDS_LEARN_MORE}, 160 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDS_LEARN_MORE},
162 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, IDS_HANDLERS_BUBBLE_MANAGE_LINK}, 161 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, IDS_HANDLERS_BUBBLE_MANAGE_LINK},
163 {CONTENT_SETTINGS_TYPE_MEDIASTREAM, IDS_MEDIASTREAM_BUBBLE_MANAGE_LINK}, 162 {CONTENT_SETTINGS_TYPE_MEDIASTREAM, IDS_MEDIASTREAM_BUBBLE_MANAGE_LINK},
164 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_PPAPI_BROKER_BUBBLE_MANAGE_LINK}, 163 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_PPAPI_BROKER_BUBBLE_MANAGE_LINK},
165 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOADS_LINK}, 164 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOADS_LINK},
166 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_MIDI_SYSEX_BUBBLE_MANAGE_LINK}, 165 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_MIDI_SYSEX_BUBBLE_MANAGE_LINK},
166 {CONTENT_SETTINGS_TYPE_SAVE_PASSWORD,
167 IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS},
167 }; 168 };
168 set_manage_link(l10n_util::GetStringUTF8( 169 set_manage_link(l10n_util::GetStringUTF8(
169 GetIdForContentType(kLinkIDs, arraysize(kLinkIDs), content_type()))); 170 GetIdForContentType(kLinkIDs, arraysize(kLinkIDs), content_type())));
170 } 171 }
171 172
172 void ContentSettingTitleAndLinkModel::OnManageLinkClicked() { 173 void ContentSettingTitleAndLinkModel::OnManageLinkClicked() {
173 if (delegate_) 174 if (delegate_)
174 delegate_->ShowContentSettingsPage(content_type()); 175 delegate_->ShowContentSettingsPage(content_type());
175 } 176 }
176 177
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 } 567 }
567 568
568 void ContentSettingPopupBubbleModel::OnPopupClicked(int index) { 569 void ContentSettingPopupBubbleModel::OnPopupClicked(int index) {
569 if (web_contents()) { 570 if (web_contents()) {
570 PopupBlockerTabHelper::FromWebContents(web_contents())-> 571 PopupBlockerTabHelper::FromWebContents(web_contents())->
571 ShowBlockedPopup(bubble_content().popup_items[index].popup_id); 572 ShowBlockedPopup(bubble_content().popup_items[index].popup_id);
572 } 573 }
573 } 574 }
574 575
575 // The model for the save password bubble. 576 // The model for the save password bubble.
576 class SavePasswordBubbleModel : public ContentSettingBubbleModel { 577 SavePasswordBubbleModel::SavePasswordBubbleModel(Delegate* delegate,
577 public: 578 WebContents* web_contents,
578 SavePasswordBubbleModel(WebContents* web_contents, Profile* profile);
579 virtual ~SavePasswordBubbleModel() {}
580
581 private:
582 // Sets the title of the bubble.
583 void SetTitle();
584
585 TabSpecificContentSettings::PasswordSavingState state_;
586
587 DISALLOW_COPY_AND_ASSIGN(SavePasswordBubbleModel);
588 };
589
590 SavePasswordBubbleModel::SavePasswordBubbleModel(WebContents* web_contents,
591 Profile* profile) 579 Profile* profile)
592 : ContentSettingBubbleModel(web_contents, profile, 580 : ContentSettingTitleAndLinkModel(delegate, web_contents, profile,
593 CONTENT_SETTINGS_TYPE_SAVE_PASSWORD), 581 CONTENT_SETTINGS_TYPE_SAVE_PASSWORD),
594 state_(TabSpecificContentSettings::NO_PASSWORD_TO_BE_SAVED) { 582 state_(TabSpecificContentSettings::NO_PASSWORD_TO_BE_SAVED) {
595 DCHECK(profile); 583 DCHECK(profile);
596 TabSpecificContentSettings* content_settings = 584 TabSpecificContentSettings* content_settings =
597 TabSpecificContentSettings::FromWebContents(web_contents); 585 TabSpecificContentSettings::FromWebContents(web_contents);
598 state_ = content_settings->GetPasswordSavingState(); 586 state_ = content_settings->GetPasswordSavingState();
599 587
600 SetTitle(); 588 SetTitle();
601 } 589 }
602 590
603 void SavePasswordBubbleModel::SetTitle() { 591 void SavePasswordBubbleModel::SetTitle() {
604 int title_id = 0; 592 int title_id = 0;
605 // If the save password icon was accessed, the icon is displayed and the 593 // If the save password icon was accessed, the icon is displayed and the
606 // bubble is instantiated 594 // bubble is instantiated
607 if (state_ == TabSpecificContentSettings::PASSWORD_TO_BE_SAVED) 595 if (state_ == TabSpecificContentSettings::PASSWORD_TO_BE_SAVED)
608 title_id = IDS_SAVE_PASSWORD; 596 title_id = IDS_SAVE_PASSWORD;
609 597
610 set_title(l10n_util::GetStringUTF8(title_id)); 598 set_title(l10n_util::GetStringUTF8(title_id));
611 } 599 }
612 600
601 void SavePasswordBubbleModel::OnCancelClicked() {
602 TabSpecificContentSettings* content_settings =
603 TabSpecificContentSettings::FromWebContents(web_contents());
604 content_settings->PasswordFormBlacklisted();
605 }
606
607 void SavePasswordBubbleModel::OnSaveClicked() {
608 TabSpecificContentSettings* content_settings =
609 TabSpecificContentSettings::FromWebContents(web_contents());
610 content_settings->PasswordAccepted();
611 }
612
613 // The model of the content settings bubble for media settings. 613 // The model of the content settings bubble for media settings.
614 class ContentSettingMediaStreamBubbleModel 614 class ContentSettingMediaStreamBubbleModel
615 : public ContentSettingTitleAndLinkModel { 615 : public ContentSettingTitleAndLinkModel {
616 public: 616 public:
617 ContentSettingMediaStreamBubbleModel(Delegate* delegate, 617 ContentSettingMediaStreamBubbleModel(Delegate* delegate,
618 WebContents* web_contents, 618 WebContents* web_contents,
619 Profile* profile); 619 Profile* profile);
620 620
621 virtual ~ContentSettingMediaStreamBubbleModel(); 621 virtual ~ContentSettingMediaStreamBubbleModel();
622 622
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 } 1270 }
1271 1271
1272 // static 1272 // static
1273 ContentSettingBubbleModel* 1273 ContentSettingBubbleModel*
1274 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 1274 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
1275 Delegate* delegate, 1275 Delegate* delegate,
1276 WebContents* web_contents, 1276 WebContents* web_contents,
1277 Profile* profile, 1277 Profile* profile,
1278 ContentSettingsType content_type) { 1278 ContentSettingsType content_type) {
1279 if (content_type == CONTENT_SETTINGS_TYPE_SAVE_PASSWORD) { 1279 if (content_type == CONTENT_SETTINGS_TYPE_SAVE_PASSWORD) {
1280 return new SavePasswordBubbleModel(web_contents, profile); 1280 return new SavePasswordBubbleModel(delegate, web_contents, profile);
1281 } 1281 }
1282 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { 1282 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) {
1283 return new ContentSettingCookiesBubbleModel(delegate, web_contents, profile, 1283 return new ContentSettingCookiesBubbleModel(delegate, web_contents, profile,
1284 content_type); 1284 content_type);
1285 } 1285 }
1286 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) { 1286 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) {
1287 return new ContentSettingPopupBubbleModel(delegate, web_contents, profile, 1287 return new ContentSettingPopupBubbleModel(delegate, web_contents, profile,
1288 content_type); 1288 content_type);
1289 } 1289 }
1290 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { 1290 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { 1361 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
1362 DCHECK_EQ(web_contents_, 1362 DCHECK_EQ(web_contents_,
1363 content::Source<WebContents>(source).ptr()); 1363 content::Source<WebContents>(source).ptr());
1364 web_contents_ = NULL; 1364 web_contents_ = NULL;
1365 } else { 1365 } else {
1366 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 1366 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
1367 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); 1367 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
1368 profile_ = NULL; 1368 profile_ = NULL;
1369 } 1369 }
1370 } 1370 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698