#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGED_USER_IMPORT_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGED_USER_IMPORT_HANDLER_H_
#include "base/callback_list.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "chrome/browser/managed_mode/managed_user_sync_service_observer.h"
#include "chrome/browser/ui/webui/options/options_ui.h"
#include "components/signin/core/browser/signin_error_controller.h"
namespace base {
class DictionaryValue;
class ListValue;
}
namespace options {
class ManagedUserImportHandler : public OptionsPageUIHandler,
public ManagedUserSyncServiceObserver,
public SigninErrorController::Observer {
public:
typedef base::CallbackList<void(const std::string&, const std::string&)>
CallbackList;
ManagedUserImportHandler();
virtual ~ManagedUserImportHandler();
virtual void GetLocalizedValues(
base::DictionaryValue* localized_strings) OVERRIDE;
virtual void InitializeHandler() OVERRIDE;
virtual void RegisterMessages() OVERRIDE;
virtual void OnManagedUserAcknowledged(const std::string& managed_user_id)
OVERRIDE {}
virtual void OnManagedUsersSyncingStopped() OVERRIDE {}
virtual void OnManagedUsersChanged() OVERRIDE;
virtual void OnErrorChanged() OVERRIDE;
private:
void FetchManagedUsers();
void RequestManagedUserImportUpdate(const base::ListValue* args);
void SendExistingManagedUsers(const base::DictionaryValue* dict);
void ClearManagedUsersAndShowError();
bool IsAccountConnected() const;
bool HasAuthError() const;
void OnSharedSettingChanged(const std::string& managed_user_id,
const std::string& key);
scoped_ptr<CallbackList::Subscription> subscription_;
ScopedObserver<SigninErrorController, ManagedUserImportHandler> observer_;
base::WeakPtrFactory<ManagedUserImportHandler> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ManagedUserImportHandler);
};
}
#endif