diff options
author | oshima <oshima@chromium.org> | 2015-10-27 14:16:08 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-27 21:16:50 +0000 |
commit | 8fcc8af20a3d41b0512e3b1486e4dc7de528a72b (patch) | |
tree | a1c05b121ec2e8694dcaca9ef54b9817801d40e6 | |
parent | f1c777e3f97a16cc6a3aa922a23602fa59412989 (diff) | |
download | chromium_src-8fcc8af20a3d41b0512e3b1486e4dc7de528a72b.zip chromium_src-8fcc8af20a3d41b0512e3b1486e4dc7de528a72b.tar.gz chromium_src-8fcc8af20a3d41b0512e3b1486e4dc7de528a72b.tar.bz2 |
Reland of Add dimming to the background during sign in (patchset #1 id:1 of https://codereview.chromium.org/1424513003/ )
Reason for revert:
The asan issue has been fixed in the new CL https://codereview.chromium.org/1426573004/
Original issue's description:
> Revert of Add dimming to the background during sign in (patchset #4 id:160001 of https://codereview.chromium.org/1400153002/ )
>
> Reason for revert:
> https://code.google.com/p/chromium/issues/detail?id=547178
>
> Original issue's description:
> > Add dimming to the background during sign in
> >
> > * Add option to put the dim layer at the bottom. Login screen put this dim layer at the bottom of login container containers so that
> > dim layer stays during login transition.
> >
> > BUG=478438
> > TEST=ScreenDimmer.DimAtBottom
> >
> > Committed: https://crrev.com/c527600749bfc6970ba39e4ed6b24404b0f7b256
> > Cr-Commit-Position: refs/heads/master@{#355481}
>
> TBR=dzhioev@chromium.org,alemate@chromium.org,oshima@chromium.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=478438
>
> Committed: https://crrev.com/ccb7824284975a271967334f86b4fc7a17378de5
> Cr-Commit-Position: refs/heads/master@{#355885}
TBR=dzhioev@chromium.org,alemate@chromium.org,dalecurtis@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=478438
Review URL: https://codereview.chromium.org/1413523005
Cr-Commit-Position: refs/heads/master@{#356396}
-rw-r--r-- | ash/wm/screen_dimmer.cc | 9 | ||||
-rw-r--r-- | ash/wm/screen_dimmer.h | 3 | ||||
-rw-r--r-- | ash/wm/screen_dimmer_unittest.cc | 27 | ||||
-rw-r--r-- | chrome/browser/ui/webui/chromeos/login/oobe_ui.cc | 21 | ||||
-rw-r--r-- | chrome/browser/ui/webui/chromeos/login/oobe_ui.h | 2 |
5 files changed, 60 insertions, 2 deletions
diff --git a/ash/wm/screen_dimmer.cc b/ash/wm/screen_dimmer.cc index 6c74888..559faaf 100644 --- a/ash/wm/screen_dimmer.cc +++ b/ash/wm/screen_dimmer.cc @@ -53,7 +53,10 @@ ScreenDimmer* ScreenDimmer::GetForRoot() { } ScreenDimmer::ScreenDimmer(int container_id) - : container_id_(container_id), target_opacity_(0.5f), is_dimming_(false) { + : container_id_(container_id), + target_opacity_(0.5f), + is_dimming_(false), + at_bottom_(false) { Shell::GetInstance()->AddShellObserver(this); } @@ -93,6 +96,10 @@ void ScreenDimmer::Update(bool should_dim) { dim = new DimWindow(container); dim->SetDimOpacity(target_opacity_); } + if (at_bottom_) + dim->parent()->StackChildAtBottom(dim); + else + dim->parent()->StackChildAtTop(dim); dim->Show(); } else { if (dim) { diff --git a/ash/wm/screen_dimmer.h b/ash/wm/screen_dimmer.h index 6d26e68..9d8779e 100644 --- a/ash/wm/screen_dimmer.h +++ b/ash/wm/screen_dimmer.h @@ -41,6 +41,8 @@ class ASH_EXPORT ScreenDimmer : ShellObserver { // Dim or undim the layers. void SetDimming(bool should_dim); + void set_at_bottom(bool at_bottom) { at_bottom_ = at_bottom; } + bool is_dimming() const { return is_dimming_; } // Find a ScreenDimmer in the container, or nullptr if it does not exist. @@ -63,6 +65,7 @@ class ASH_EXPORT ScreenDimmer : ShellObserver { // Are we currently dimming the screen? bool is_dimming_; + bool at_bottom_; DISALLOW_COPY_AND_ASSIGN(ScreenDimmer); }; diff --git a/ash/wm/screen_dimmer_unittest.cc b/ash/wm/screen_dimmer_unittest.cc index 9b1bdc6..084105e 100644 --- a/ash/wm/screen_dimmer_unittest.cc +++ b/ash/wm/screen_dimmer_unittest.cc @@ -10,7 +10,8 @@ #include "ash/wm/dim_window.h" #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" -#include "ui/aura/window_event_dispatcher.h" +//#include "ui/aura/window_event_dispatcher.h" +#include "ui/aura/test/test_windows.h" #include "ui/compositor/layer.h" namespace ash { @@ -86,5 +87,29 @@ TEST_F(ScreenDimmerTest, RootDimmer) { EXPECT_EQ(nullptr, ScreenDimmer::FindForTest(-1)); } +TEST_F(ScreenDimmerTest, DimAtBottom) { + ScreenDimmer* root_dimmer = ScreenDimmer::GetForRoot(); + aura::Window* root_window = Shell::GetPrimaryRootWindow(); + scoped_ptr<aura::Window> window( + aura::test::CreateTestWindowWithId(1, root_window)); + root_dimmer->SetDimming(true); + std::vector<aura::Window*>::const_iterator dim_iter = + std::find(root_window->children().begin(), root_window->children().end(), + GetDimWindow()); + ASSERT_TRUE(dim_iter != root_window->children().end()); + // Dim layer is at top. + EXPECT_EQ(*dim_iter, *root_window->children().rbegin()); + + root_dimmer->SetDimming(false); + root_dimmer->set_at_bottom(true); + root_dimmer->SetDimming(true); + + dim_iter = std::find(root_window->children().begin(), + root_window->children().end(), GetDimWindow()); + ASSERT_TRUE(dim_iter != root_window->children().end()); + // Dom layer is at the bottom. + EXPECT_EQ(*dim_iter, *root_window->children().begin()); +} + } // namespace test } // namespace ash diff --git a/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc b/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc index 70fa6ee..d34af39 100644 --- a/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc +++ b/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc @@ -4,6 +4,8 @@ #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" +#include "ash/shell_window_ids.h" +#include "ash/wm/screen_dimmer.h" #include "base/command_line.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" @@ -381,6 +383,9 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url) OobeUI::~OobeUI() { core_handler_->SetDelegate(nullptr); network_dropdown_handler_->RemoveObserver(error_screen_handler_); + ash::ScreenDimmer::GetForContainer( + ash::kShellWindowId_LockScreenContainersContainer) + ->SetDimming(false); } CoreOobeActor* OobeUI::GetCoreOobeActor() { @@ -539,6 +544,12 @@ void OobeUI::InitializeScreenMaps() { screen_names_[SCREEN_OOBE_HOST_PAIRING] = kScreenHostPairing; screen_names_[SCREEN_DEVICE_DISABLED] = kScreenDeviceDisabled; + dim_overlay_screen_ids_.push_back(SCREEN_CONFIRM_PASSWORD); + dim_overlay_screen_ids_.push_back(SCREEN_GAIA_SIGNIN); + dim_overlay_screen_ids_.push_back(SCREEN_OOBE_ENROLLMENT); + dim_overlay_screen_ids_.push_back(SCREEN_PASSWORD_CHANGED); + dim_overlay_screen_ids_.push_back(SCREEN_USER_IMAGE_PICKER); + screen_ids_.clear(); for (size_t i = 0; i < screen_names_.size(); ++i) screen_ids_[screen_names_[i]] = static_cast<Screen>(i); @@ -634,7 +645,17 @@ void OobeUI::OnCurrentScreenChanged(const std::string& screen) { previous_screen_ = current_screen_; DCHECK(screen_ids_.count(screen)) << "Screen should be registered in InitializeScreenMaps()"; + LOG(ERROR) << "OnCurrentScreenChanged:" << screen; Screen new_screen = screen_ids_[screen]; + + bool should_dim = + std::find(dim_overlay_screen_ids_.begin(), dim_overlay_screen_ids_.end(), + new_screen) != dim_overlay_screen_ids_.end(); + ash::ScreenDimmer* screen_dimmer = ash::ScreenDimmer::GetForContainer( + ash::kShellWindowId_LockScreenContainersContainer); + screen_dimmer->set_at_bottom(true); + screen_dimmer->SetDimming(should_dim); + FOR_EACH_OBSERVER(Observer, observer_list_, OnCurrentScreenChanged(current_screen_, new_screen)); diff --git a/chrome/browser/ui/webui/chromeos/login/oobe_ui.h b/chrome/browser/ui/webui/chromeos/login/oobe_ui.h index 72e8568..d710683 100644 --- a/chrome/browser/ui/webui/chromeos/login/oobe_ui.h +++ b/chrome/browser/ui/webui/chromeos/login/oobe_ui.h @@ -246,6 +246,8 @@ class OobeUI : public OobeDisplay, // Maps screen ids to JS screen names. std::vector<std::string> screen_names_; + std::vector<Screen> dim_overlay_screen_ids_; + // Flag that indicates whether JS part is fully loaded and ready to accept // calls. bool ready_; |