Logo Search packages:      
Sourcecode: chromium-browser version File versions  Download package


// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.


#include <string>
#include <vector>

#include "base/ref_counted.h"
#include "base/task.h"
#include "base/timer.h"
#include "chrome/browser/chromeos/login/login_status_consumer.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/user_controller.h"
#include "chrome/browser/chromeos/wm_message_listener.h"
#include "gfx/size.h"

namespace views {
class Wiget;

namespace chromeos {

class Authenticator;
class BackgroundView;

// ExistingUserController is used to handle login when someone has already
// logged into the machine. When Init is invoked a UserController is created for
// each of the Users's in the UserManager (including one for guest), and the
// window manager is then told to show the windows. If the user clicks on the
// guest entry the WizardWindow is swapped in.
// To use ExistingUserController create an instance of it and invoke Init.
// ExistingUserController maintains it's own life cycle and deletes itself when
// the user logs in (or chooses to see other settings).
class ExistingUserController : public WmMessageListener::Observer,
                               public UserController::Delegate,
                               public LoginStatusConsumer {
  // Initializes views for known users. |background_bounds| determines the
  // bounds of background view.
  ExistingUserController(const std::vector<UserManager::User>& users,
                         const gfx::Rect& background_bounds);

  // Creates and shows the appropriate set of windows.
  void Init();

  friend class DeleteTask<ExistingUserController>;


  // Cover for invoking the destructor. Used by delete_timer_.
  void Delete();

  // WmMessageListener::Observer:
  virtual void ProcessWmMessage(const WmIpc::Message& message,
                                GdkWindow* window);

  // UserController::Delegate:
  virtual void Login(UserController* source, const string16& password);

  // LoginStatusConsumer:
  virtual void OnLoginFailure(const std::string& error);
  virtual void OnLoginSuccess(const std::string& username,
                              const std::string& credentials);

  // Bounds of the background window.
  const gfx::Rect background_bounds_;

  // Background window/view.
  views::Widget* background_window_;
  BackgroundView* background_view_;

  // The set of UserControllers.
  std::vector<UserController*> controllers_;

  // Used for logging in.
  scoped_refptr<Authenticator> authenticator_;

  // Index of view loggin in.
  size_t index_of_view_logging_in_;

  // See comment in ProcessWmMessage.
  base::OneShotTimer<ExistingUserController> delete_timer_;


}  // namespace chromeos


Generated by  Doxygen 1.6.0   Back to index