password_changed_view.h revision 3345a6884c488ff3a535c2c9acdd33d74b37e311
1// Copyright (c) 2010 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#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_PASSWORD_CHANGED_VIEW_H_ 6#define CHROME_BROWSER_CHROMEOS_LOGIN_PASSWORD_CHANGED_VIEW_H_ 7#pragma once 8 9#include <string> 10 11#include "views/controls/button/button.h" 12#include "views/controls/textfield/textfield.h" 13#include "views/view.h" 14#include "views/window/dialog_delegate.h" 15 16namespace views { 17class Button; 18class Label; 19class RadioButton; 20class Textfield; 21} // namespace views 22 23namespace chromeos { 24 25// A dialog box that is shown when password change was detected. 26// User is presented with an option to sync all settings or 27// enter old password and sync only delta. 28class PasswordChangedView : public views::View, 29 public views::DialogDelegate, 30 public views::ButtonListener, 31 public views::Textfield::Controller { 32 public: 33 // Delegate class to get notifications from the view. 34 class Delegate { 35 public: 36 virtual ~Delegate() {} 37 38 // User provided |old_password|, decrypt homedir and sync only delta. 39 virtual void RecoverEncryptedData(const std::string& old_password) = 0; 40 41 // Ignores password change and forces full sync. 42 virtual void ResyncEncryptedData() = 0; 43 }; 44 45 explicit PasswordChangedView(Delegate* delegate); 46 virtual ~PasswordChangedView() {} 47 48 // views::DialogDelegate overrides: 49 virtual bool Accept(); 50 virtual int GetDialogButtons() const; 51 52 // views::WindowDelegate overrides: 53 virtual bool IsModal() const { return true; } 54 virtual views::View* GetContentsView() { return this; } 55 56 // views::View overrides: 57 virtual std::wstring GetWindowTitle() const; 58 59 // views::ButtonListener overrides: 60 virtual void ButtonPressed(views::Button* sender, 61 const views::Event& event); 62 63 // views::Textfield::Controller overrides: 64 virtual bool HandleKeystroke(views::Textfield* sender, 65 const views::Textfield::Keystroke& keystroke); 66 virtual void ContentsChanged(views::Textfield* sender, 67 const string16& new_contents) {} 68 69 // Selects delta sync radio button. 70 void SelectDeltaSyncOption(); 71 72 protected: 73 // views::View overrides: 74 virtual gfx::Size GetPreferredSize(); 75 virtual void ViewHierarchyChanged(bool is_add, 76 views::View* parent, 77 views::View* child); 78 79 private: 80 // Called when dialog is accepted. 81 bool ExitDialog(); 82 83 // Initialize view layout. 84 void Init(); 85 86 // Screen controls. 87 views::Label* title_label_; 88 views::Label* description_label_; 89 views::RadioButton* full_sync_radio_; 90 views::RadioButton* delta_sync_radio_; 91 views::Textfield* old_password_field_; 92 93 // Notifications receiver. 94 Delegate* delegate_; 95 96 DISALLOW_COPY_AND_ASSIGN(PasswordChangedView); 97}; 98 99} // namespace chromeos 100 101#endif // CHROME_BROWSER_CHROMEOS_LOGIN_PASSWORD_CHANGED_VIEW_H_ 102