This source file includes following definitions.
- ShowUserManager
- ShowUserManagerWithTutorial
- HideUserManager
- Show
- Hide
- IsShowing
- OnGuestProfileCreated
- GetPreferredSize
- CanResize
- CanMaximize
- GetWindowTitle
- GetDialogButtons
- WindowClosing
- UseNewStyleForThisDialog
#include "chrome/browser/ui/views/user_manager_view.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/profiles/profile_window.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/views/auto_keep_alive.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/webview/webview.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
#if defined(USE_ASH)
#include "ash/wm/window_util.h"
#endif
#if defined(OS_WIN)
#include "chrome/browser/shell_integration.h"
#include "ui/base/win/shell.h"
#include "ui/views/win/hwnd_util.h"
#include "win8/util/win8_util.h"
#endif
namespace {
const int kWindowWidth = 900;
const int kWindowHeight = 700;
}
namespace chrome {
void ShowUserManager(const base::FilePath& profile_path_to_focus) {
UserManagerView::Show(
profile_path_to_focus, profiles::USER_MANAGER_NO_TUTORIAL);
}
void ShowUserManagerWithTutorial(profiles::UserManagerTutorialMode tutorial) {
UserManagerView::Show(base::FilePath(), tutorial);
}
void HideUserManager() {
UserManagerView::Hide();
}
}
UserManagerView* UserManagerView::instance_ = NULL;
UserManagerView::UserManagerView(Profile* profile)
: web_view_(new views::WebView(profile)) {
SetLayoutManager(new views::FillLayout);
AddChildView(web_view_);
}
UserManagerView::~UserManagerView() {
}
void UserManagerView::Show(const base::FilePath& profile_path_to_focus,
profiles::UserManagerTutorialMode tutorial_mode) {
ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::OPEN_USER_MANAGER);
if (instance_) {
instance_->GetWidget()->Activate();
return;
}
profiles::CreateGuestProfileForUserManager(
profile_path_to_focus,
tutorial_mode,
base::Bind(&UserManagerView::OnGuestProfileCreated));
}
void UserManagerView::Hide() {
if (instance_)
instance_->GetWidget()->Close();
}
bool UserManagerView::IsShowing() {
return instance_ ? instance_->GetWidget()->IsActive() : false;
}
void UserManagerView::OnGuestProfileCreated(Profile* guest_profile,
const std::string& url) {
instance_ = new UserManagerView(guest_profile);
DialogDelegate::CreateDialogWidget(instance_, NULL, NULL);
gfx::NativeWindow window = instance_->GetWidget()->GetNativeWindow();
instance_->keep_alive_.reset(new AutoKeepAlive(window));
#if defined(OS_WIN)
ui::win::SetAppIdForWindow(
ShellIntegration::GetChromiumModelIdForProfile(
guest_profile->GetPath()),
views::HWNDForWidget(instance_->GetWidget()));
#endif
instance_->GetWidget()->Show();
instance_->web_view_->LoadInitialURL(GURL(url));
instance_->web_view_->RequestFocus();
}
gfx::Size UserManagerView::GetPreferredSize() {
return gfx::Size(kWindowWidth, kWindowHeight);
}
bool UserManagerView::CanResize() const {
return true;
}
bool UserManagerView::CanMaximize() const {
return true;
}
base::string16 UserManagerView::GetWindowTitle() const {
return l10n_util::GetStringUTF16(IDS_USER_MANAGER_SCREEN_TITLE);
}
int UserManagerView::GetDialogButtons() const {
return ui::DIALOG_BUTTON_NONE;
}
void UserManagerView::WindowClosing() {
if (instance_ == this)
instance_ = NULL;
}
bool UserManagerView::UseNewStyleForThisDialog() const {
return false;
}