#include "chrome/browser/chromeos/login/webui_login_view.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/mobile_config.h"
+#include "chrome/browser/chromeos/net/delay_network_call.h"
#include "chrome/browser/chromeos/policy/auto_enrollment_client.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_view.h"
#include "content/public/browser/web_ui.h"
#include "grit/browser_resources.h"
#include "media/audio/sounds/sounds_manager.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/transform.h"
+#include "ui/keyboard/keyboard_controller.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_delegate.h"
#include "ui/wm/core/window_animations.h"
#include "url/gurl.h"
frame_set->insert(frame);
}
+// A login implementation of WidgetDelegate.
+class LoginWidgetDelegate : public views::WidgetDelegate {
+ public:
+ explicit LoginWidgetDelegate(views::Widget* widget) : widget_(widget) {
+ }
+ virtual ~LoginWidgetDelegate() {}
+
+ // Overridden from WidgetDelegate:
+ virtual void DeleteDelegate() OVERRIDE {
+ delete this;
+ }
+ virtual views::Widget* GetWidget() OVERRIDE {
+ return widget_;
+ }
+ virtual const views::Widget* GetWidget() const OVERRIDE {
+ return widget_;
+ }
+ virtual bool CanActivate() const OVERRIDE {
+ return true;
+ }
+ virtual bool ShouldAdvanceFocusToTopLevelWidget() const OVERRIDE {
+ return true;
+ }
+
+ private:
+ views::Widget* widget_;
+
+ DISALLOW_COPY_AND_ASSIGN(LoginWidgetDelegate);
+};
+
} // namespace
namespace chromeos {
finalize_animation_type_(ANIMATION_WORKSPACE),
animation_weak_ptr_factory_(this),
startup_sound_played_(false),
- startup_sound_honors_spoken_feedback_(false) {
+ startup_sound_honors_spoken_feedback_(false),
+ is_observing_keyboard_(false) {
DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
CrasAudioHandler::Get()->AddAudioObserver(this);
+ if (keyboard::KeyboardController::GetInstance()) {
+ keyboard::KeyboardController::GetInstance()->AddObserver(this);
+ is_observing_keyboard_ = true;
+ }
+
+ ash::Shell::GetInstance()->delegate()->AddVirtualKeyboardStateObserver(this);
// We need to listen to CLOSE_ALL_BROWSERS_REQUEST but not APP_TERMINATING
// because/ APP_TERMINATING will never be fired as long as this keeps
LoginDisplayHostImpl::~LoginDisplayHostImpl() {
DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this);
CrasAudioHandler::Get()->RemoveAudioObserver(this);
+ if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) {
+ keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
+ is_observing_keyboard_ = false;
+ }
+
+ ash::Shell::GetInstance()->delegate()->
+ RemoveVirtualKeyboardStateObserver(this);
views::FocusManager::set_arrow_key_traversal_enabled(false);
ResetLoginWindowAndView();
// Lock container can be transparent after lock screen animation.
aura::Window* lock_container = ash::Shell::GetContainer(
ash::Shell::GetPrimaryRootWindow(),
- ash::internal::kShellWindowId_LockScreenContainersContainer);
+ ash::kShellWindowId_LockScreenContainersContainer);
lock_container->layer()->SetOpacity(1.0);
ash::Shell::GetInstance()->
OnLoginPromptVisible();
}
+////////////////////////////////////////////////////////////////////////////////
+// LoginDisplayHostImpl, chromeos::CrasAudioHandler::AudioObserver
+// implementation:
+
void LoginDisplayHostImpl::OnActiveOutputNodeChanged() {
TryToPlayStartupSound();
}
////////////////////////////////////////////////////////////////////////////////
+// LoginDisplayHostImpl, ash::KeyboardStateObserver:
+// implementation:
+
+void LoginDisplayHostImpl::OnVirtualKeyboardStateChanged(bool activated) {
+ if (keyboard::KeyboardController::GetInstance()) {
+ if (activated) {
+ if (!is_observing_keyboard_) {
+ keyboard::KeyboardController::GetInstance()->AddObserver(this);
+ is_observing_keyboard_ = true;
+ }
+ } else {
+ keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
+ is_observing_keyboard_ = false;
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// LoginDisplayHostImpl, keyboard::KeyboardControllerObserver:
+// implementation:
+
+void LoginDisplayHostImpl::OnKeyboardBoundsChanging(
+ const gfx::Rect& new_bounds) {
+ if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty()) {
+ // Keyboard has been hidden.
+ if (webui_login_display_)
+ webui_login_display_->ShowControlBar(true);
+ } else if (!new_bounds.IsEmpty() && keyboard_bounds_.IsEmpty()) {
+ // Keyboard has been shown.
+ if (webui_login_display_)
+ webui_login_display_->ShowControlBar(false);
+ }
+
+ keyboard_bounds_ = new_bounds;
+}
+
+////////////////////////////////////////////////////////////////////////////////
// LoginDisplayHostImpl, private
void LoginDisplayHostImpl::ShutdownDisplayHost(bool post_quit_task) {
}
void LoginDisplayHostImpl::ScheduleWorkspaceAnimation() {
- if (ash::Shell::GetContainer(
- ash::Shell::GetPrimaryRootWindow(),
- ash::internal::kShellWindowId_DesktopBackgroundContainer)->
- children().empty()) {
+ if (ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(),
+ ash::kShellWindowId_DesktopBackgroundContainer)
+ ->children()
+ .empty()) {
// If there is no background window, don't perform any animation on the
// default and background layer because there is nothing behind it.
return;
}
LOG(WARNING) << "Login WebUI >> Show already initialized UI";
login_window_->Show();
- login_view_->GetWebContents()->GetView()->Focus();
+ login_view_->GetWebContents()->Focus();
login_view_->SetStatusAreaVisible(status_area_saved_visibility_);
login_view_->OnPostponedShow();
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
params.bounds = background_bounds();
- params.show_state = ui::SHOW_STATE_FULLSCREEN;
+ params.show_state = ui::SHOW_STATE_MAXIMIZED;
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
params.parent =
- ash::Shell::GetContainer(
- ash::Shell::GetPrimaryRootWindow(),
- ash::internal::kShellWindowId_LockScreenContainer);
+ ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(),
+ ash::kShellWindowId_LockScreenContainer);
login_window_ = new views::Widget;
+ params.delegate = new LoginWidgetDelegate(login_window_);
login_window_->Init(params);
+
login_view_ = new WebUILoginView();
login_view_->Init();
if (login_view_->webui_visible())
system::InputDeviceSettings::Get()->SetTapToClick(
prefs->GetBoolean(prefs::kOwnerTapToClickEnabled));
}
-
- ui::SetNaturalScroll(CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kNaturalScrollDefault));
+ system::InputDeviceSettings::Get()->SetNaturalScroll(
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kNaturalScrollDefault));
gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size()));
return;
}
+ if (StartupUtils::IsEulaAccepted()) {
+ DelayNetworkCall(
+ ServicesCustomizationDocument::GetInstance()
+ ->EnsureCustomizationAppliedClosure(),
+ base::TimeDelta::FromMilliseconds(kDefaultNetworkRetryDelayMS));
+ }
+
bool show_login_screen =
(first_screen_name.empty() && oobe_complete) ||
first_screen_name == chromeos::WizardController::kLoginScreenName;