| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/passwords/manage_passwords_icon_controller.h" | |
| 6 | |
| 7 #include "chrome/browser/chrome_notification_types.h" | |
| 8 #include "chrome/browser/ui/browser_finder.h" | |
| 9 #include "chrome/browser/ui/browser_window.h" | |
| 10 #include "chrome/browser/ui/omnibox/location_bar.h" | |
| 11 #include "content/public/browser/notification_service.h" | |
| 12 | |
| 13 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ManagePasswordsIconController); | |
| 14 | |
| 15 ManagePasswordsIconController::ManagePasswordsIconController( | |
| 16 content::WebContents* web_contents) | |
| 17 : TabSpecificContentSettings::PasswordObserver( | |
| 18 TabSpecificContentSettings::FromWebContents(web_contents)), | |
| 19 content::WebContentsObserver(web_contents), | |
| 20 manage_passwords_icon_to_be_shown_(false), | |
| 21 password_to_be_saved_(false), | |
| 22 manage_passwords_bubble_needs_showing_(false), | |
| 23 browser_context_(web_contents->GetBrowserContext()) {} | |
| 24 | |
| 25 ManagePasswordsIconController::~ManagePasswordsIconController() {} | |
| 26 | |
| 27 void ManagePasswordsIconController::OnBubbleShown() { | |
| 28 TabSpecificContentSettings* content_settings = | |
| 29 TabSpecificContentSettings::FromWebContents(web_contents()); | |
| 30 DCHECK(content_settings); | |
| 31 content_settings->unset_manage_passwords_bubble_needs_showing(); | |
| 32 } | |
| 33 | |
| 34 void ManagePasswordsIconController::OnPasswordAction() { | |
| 35 TabSpecificContentSettings* content_settings = | |
| 36 TabSpecificContentSettings::FromWebContents(web_contents()); | |
| 37 DCHECK(content_settings); | |
| 38 manage_passwords_icon_to_be_shown_ = | |
| 39 content_settings->manage_passwords_icon_to_be_shown(); | |
| 40 password_to_be_saved_ = content_settings->password_to_be_saved(); | |
| 41 manage_passwords_bubble_needs_showing_ = | |
| 42 content_settings->manage_passwords_bubble_needs_showing(); | |
| 43 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); | |
| 44 if (!browser) | |
| 45 return; | |
| 46 LocationBar* location_bar = browser->window()->GetLocationBar(); | |
| 47 DCHECK(location_bar); | |
| 48 location_bar->UpdateManagePasswordsIconAndBubble(); | |
| 49 } | |
| OLD | NEW |