Commit f9e0290c authored by James Cook's avatar James Cook Committed by Commit Bot

cros: Clean up ash::FirstRunHelper

Clean up before making it work with out-of-process ash (go/mustash).

* Make FirstRunHelper a concrete class
* Eliminate ash::Shell::CreateFirstRunHelper
* Move some methods to FirstRunController in chrome

Bug: 756057
Test: existing ash_unittests, browser_tests
Change-Id: I6d3660f64e2184a03c2f92b204200a26b5f7dab8
Reviewed-on: https://chromium-review.googlesource.com/990725Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547557}
parent ed5330ab
...@@ -183,8 +183,6 @@ component("ash") { ...@@ -183,8 +183,6 @@ component("ash") {
"first_run/desktop_cleaner.h", "first_run/desktop_cleaner.h",
"first_run/first_run_helper.cc", "first_run/first_run_helper.cc",
"first_run/first_run_helper.h", "first_run/first_run_helper.h",
"first_run/first_run_helper_impl.cc",
"first_run/first_run_helper_impl.h",
"focus_cycler.cc", "focus_cycler.cc",
"focus_cycler.h", "focus_cycler.h",
"frame/caption_buttons/caption_button_types.h", "frame/caption_buttons/caption_button_types.h",
......
...@@ -4,10 +4,50 @@ ...@@ -4,10 +4,50 @@
#include "ash/first_run/first_run_helper.h" #include "ash/first_run/first_run_helper.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/shelf/app_list_button.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_bubble.h"
#include "base/logging.h"
#include "ui/app_list/views/app_list_view.h"
#include "ui/aura/window.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
namespace ash { namespace ash {
namespace {
views::Widget* CreateFirstRunWindow() {
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
params.bounds = display::Screen::GetScreen()->GetPrimaryDisplay().bounds();
params.show_state = ui::SHOW_STATE_FULLSCREEN;
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
params.parent = Shell::GetContainer(Shell::GetPrimaryRootWindow(),
ash::kShellWindowId_OverlayContainer);
views::Widget* window = new views::Widget;
window->Init(params);
return window;
}
} // namespace
FirstRunHelper::FirstRunHelper() = default; FirstRunHelper::FirstRunHelper() : widget_(CreateFirstRunWindow()) {
FirstRunHelper::~FirstRunHelper() = default; Shell::Get()->overlay_filter()->Activate(this);
}
FirstRunHelper::~FirstRunHelper() {
Shell::Get()->overlay_filter()->Deactivate(this);
if (IsTrayBubbleOpened())
CloseTrayBubble();
widget_->Close();
}
void FirstRunHelper::AddObserver(Observer* observer) { void FirstRunHelper::AddObserver(Observer* observer) {
observers_.AddObserver(observer); observers_.AddObserver(observer);
...@@ -17,4 +57,57 @@ void FirstRunHelper::RemoveObserver(Observer* observer) { ...@@ -17,4 +57,57 @@ void FirstRunHelper::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer); observers_.RemoveObserver(observer);
} }
} // namespace chromeos views::Widget* FirstRunHelper::GetOverlayWidget() {
return widget_;
}
gfx::Rect FirstRunHelper::GetAppListButtonBounds() {
Shelf* shelf = Shelf::ForWindow(Shell::GetPrimaryRootWindow());
AppListButton* app_button = shelf->shelf_widget()->GetAppListButton();
return app_button->GetBoundsInScreen();
}
void FirstRunHelper::OpenTrayBubble() {
SystemTray* tray = Shell::Get()->GetPrimarySystemTray();
tray->ShowPersistentDefaultView();
}
void FirstRunHelper::CloseTrayBubble() {
SystemTray* tray = Shell::Get()->GetPrimarySystemTray();
DCHECK(tray->HasSystemBubble()) << "Tray bubble is closed already.";
tray->CloseBubble();
}
bool FirstRunHelper::IsTrayBubbleOpened() {
SystemTray* tray = Shell::Get()->GetPrimarySystemTray();
return tray->HasSystemBubble();
}
gfx::Rect FirstRunHelper::GetTrayBubbleBounds() {
SystemTray* tray = Shell::Get()->GetPrimarySystemTray();
views::View* bubble = tray->GetSystemBubble()->bubble_view();
return bubble->GetBoundsInScreen();
}
gfx::Rect FirstRunHelper::GetHelpButtonBounds() {
SystemTray* tray = Shell::Get()->GetPrimarySystemTray();
views::View* help_button = tray->GetHelpButtonView();
return help_button->GetBoundsInScreen();
}
// OverlayEventFilter::Delegate:
void FirstRunHelper::Cancel() {
for (auto& observer : observers_)
observer.OnCancelled();
}
bool FirstRunHelper::IsCancelingKeyEvent(ui::KeyEvent* event) {
return event->key_code() == ui::VKEY_ESCAPE;
}
aura::Window* FirstRunHelper::GetWindow() {
return widget_->GetNativeWindow();
}
} // namespace ash
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#define ASH_FIRST_RUN_FIRST_RUN_HELPER_H_ #define ASH_FIRST_RUN_FIRST_RUN_HELPER_H_
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/first_run/desktop_cleaner.h"
#include "ash/wm/overlay_event_filter.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/observer_list.h" #include "base/observer_list.h"
...@@ -22,7 +24,7 @@ namespace ash { ...@@ -22,7 +24,7 @@ namespace ash {
// Interface used by first-run tutorial to manipulate and retrieve information // Interface used by first-run tutorial to manipulate and retrieve information
// about shell elements. // about shell elements.
// All returned coordinates are in screen coordinate system. // All returned coordinates are in screen coordinate system.
class ASH_EXPORT FirstRunHelper { class ASH_EXPORT FirstRunHelper : public OverlayEventFilter::Delegate {
public: public:
class Observer { class Observer {
public: public:
...@@ -39,32 +41,39 @@ class ASH_EXPORT FirstRunHelper { ...@@ -39,32 +41,39 @@ class ASH_EXPORT FirstRunHelper {
void RemoveObserver(Observer* observer); void RemoveObserver(Observer* observer);
// Returns widget to place tutorial UI into it. // Returns widget to place tutorial UI into it.
virtual views::Widget* GetOverlayWidget() = 0; views::Widget* GetOverlayWidget();
// Returns bounds of application list button. // Returns bounds of application list button.
virtual gfx::Rect GetAppListButtonBounds() = 0; gfx::Rect GetAppListButtonBounds();
// Opens and closes system tray bubble. // Opens and closes system tray bubble.
virtual void OpenTrayBubble() = 0; void OpenTrayBubble();
virtual void CloseTrayBubble() = 0; void CloseTrayBubble();
// Returns |true| iff system tray bubble is opened now. // Returns |true| iff system tray bubble is opened now.
virtual bool IsTrayBubbleOpened() = 0; bool IsTrayBubbleOpened();
// Returns bounds of system tray bubble. You must open bubble before calling // Returns bounds of system tray bubble. You must open bubble before calling
// this method. // this method.
virtual gfx::Rect GetTrayBubbleBounds() = 0; gfx::Rect GetTrayBubbleBounds();
// Returns bounds of help app button from system tray buble. You must open // Returns bounds of help app button from system tray buble. You must open
// bubble before calling this method. // bubble before calling this method.
virtual gfx::Rect GetHelpButtonBounds() = 0; gfx::Rect GetHelpButtonBounds();
protected: // OverlayEventFilter::Delegate:
base::ObserverList<Observer>& observers() { return observers_; } void Cancel() override;
bool IsCancelingKeyEvent(ui::KeyEvent* event) override;
aura::Window* GetWindow() override;
private: private:
base::ObserverList<Observer> observers_; base::ObserverList<Observer> observers_;
// The first run dialog window.
views::Widget* widget_;
DesktopCleaner cleaner_;
DISALLOW_COPY_AND_ASSIGN(FirstRunHelper); DISALLOW_COPY_AND_ASSIGN(FirstRunHelper);
}; };
......
// Copyright 2013 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 "ash/first_run/first_run_helper_impl.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/shelf/app_list_button.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_bubble.h"
#include "base/logging.h"
#include "ui/app_list/views/app_list_view.h"
#include "ui/aura/window.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
namespace ash {
namespace {
views::Widget* CreateFirstRunWindow() {
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
params.bounds = display::Screen::GetScreen()->GetPrimaryDisplay().bounds();
params.show_state = ui::SHOW_STATE_FULLSCREEN;
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
params.parent = Shell::GetContainer(Shell::GetPrimaryRootWindow(),
ash::kShellWindowId_OverlayContainer);
views::Widget* window = new views::Widget;
window->Init(params);
return window;
}
} // anonymous namespace
FirstRunHelperImpl::FirstRunHelperImpl() : widget_(CreateFirstRunWindow()) {
Shell::Get()->overlay_filter()->Activate(this);
}
FirstRunHelperImpl::~FirstRunHelperImpl() {
Shell::Get()->overlay_filter()->Deactivate(this);
if (IsTrayBubbleOpened())
CloseTrayBubble();
widget_->Close();
}
views::Widget* FirstRunHelperImpl::GetOverlayWidget() {
return widget_;
}
gfx::Rect FirstRunHelperImpl::GetAppListButtonBounds() {
Shelf* shelf = Shelf::ForWindow(Shell::GetPrimaryRootWindow());
AppListButton* app_button = shelf->shelf_widget()->GetAppListButton();
return app_button->GetBoundsInScreen();
}
void FirstRunHelperImpl::Cancel() {
for (auto& observer : observers())
observer.OnCancelled();
}
bool FirstRunHelperImpl::IsCancelingKeyEvent(ui::KeyEvent* event) {
return event->key_code() == ui::VKEY_ESCAPE;
}
aura::Window* FirstRunHelperImpl::GetWindow() {
return widget_->GetNativeWindow();
}
void FirstRunHelperImpl::OpenTrayBubble() {
SystemTray* tray = Shell::Get()->GetPrimarySystemTray();
tray->ShowPersistentDefaultView();
}
void FirstRunHelperImpl::CloseTrayBubble() {
SystemTray* tray = Shell::Get()->GetPrimarySystemTray();
DCHECK(tray->HasSystemBubble()) << "Tray bubble is closed already.";
tray->CloseBubble();
}
bool FirstRunHelperImpl::IsTrayBubbleOpened() {
SystemTray* tray = Shell::Get()->GetPrimarySystemTray();
return tray->HasSystemBubble();
}
gfx::Rect FirstRunHelperImpl::GetTrayBubbleBounds() {
SystemTray* tray = Shell::Get()->GetPrimarySystemTray();
views::View* bubble = tray->GetSystemBubble()->bubble_view();
return bubble->GetBoundsInScreen();
}
gfx::Rect FirstRunHelperImpl::GetHelpButtonBounds() {
SystemTray* tray = Shell::Get()->GetPrimarySystemTray();
views::View* help_button = tray->GetHelpButtonView();
return help_button->GetBoundsInScreen();
}
} // namespace ash
// Copyright 2013 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.
#ifndef ASH_FIRST_RUN_FIRST_RUN_HELPER_IMPL_H_
#define ASH_FIRST_RUN_FIRST_RUN_HELPER_IMPL_H_
#include "ash/first_run/desktop_cleaner.h"
#include "ash/first_run/first_run_helper.h"
#include "ash/wm/overlay_event_filter.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
namespace ash {
class FirstRunHelperImpl : public FirstRunHelper,
public OverlayEventFilter::Delegate {
public:
FirstRunHelperImpl();
~FirstRunHelperImpl() override;
// Overriden from FirstRunHelper.
views::Widget* GetOverlayWidget() override;
gfx::Rect GetAppListButtonBounds() override;
void OpenTrayBubble() override;
void CloseTrayBubble() override;
bool IsTrayBubbleOpened() override;
gfx::Rect GetTrayBubbleBounds() override;
gfx::Rect GetHelpButtonBounds() override;
// Overriden from OverlayEventFilter::Delegate.
void Cancel() override;
bool IsCancelingKeyEvent(ui::KeyEvent* event) override;
aura::Window* GetWindow() override;
private:
views::Widget* widget_;
DesktopCleaner cleaner_;
DISALLOW_COPY_AND_ASSIGN(FirstRunHelperImpl);
};
} // namespace ash
#endif // ASH_FIRST_RUN_FIRST_RUN_HELPER_IMPL_H_
...@@ -62,7 +62,7 @@ class FirstRunHelperTest : public AshTestBase, public FirstRunHelper::Observer { ...@@ -62,7 +62,7 @@ class FirstRunHelperTest : public AshTestBase, public FirstRunHelper::Observer {
void SetUp() override { void SetUp() override {
AshTestBase::SetUp(); AshTestBase::SetUp();
CheckContainersAreVisible(); CheckContainersAreVisible();
helper_.reset(ash::Shell::Get()->CreateFirstRunHelper()); helper_ = std::make_unique<FirstRunHelper>();
helper_->AddObserver(this); helper_->AddObserver(this);
helper_->GetOverlayWidget()->Show(); helper_->GetOverlayWidget()->Show();
} }
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#include "ash/display/screen_position_controller.h" #include "ash/display/screen_position_controller.h"
#include "ash/display/window_tree_host_manager.h" #include "ash/display/window_tree_host_manager.h"
#include "ash/drag_drop/drag_drop_controller.h" #include "ash/drag_drop/drag_drop_controller.h"
#include "ash/first_run/first_run_helper_impl.h"
#include "ash/focus_cycler.h" #include "ash/focus_cycler.h"
#include "ash/frame/custom_frame_view_ash.h" #include "ash/frame/custom_frame_view_ash.h"
#include "ash/high_contrast/high_contrast_controller.h" #include "ash/high_contrast/high_contrast_controller.h"
...@@ -500,10 +499,6 @@ SystemTray* Shell::GetPrimarySystemTray() { ...@@ -500,10 +499,6 @@ SystemTray* Shell::GetPrimarySystemTray() {
return GetPrimaryRootWindowController()->GetSystemTray(); return GetPrimaryRootWindowController()->GetSystemTray();
} }
FirstRunHelper* Shell::CreateFirstRunHelper() {
return new FirstRunHelperImpl;
}
void Shell::SetLargeCursorSizeInDip(int large_cursor_size_in_dip) { void Shell::SetLargeCursorSizeInDip(int large_cursor_size_in_dip) {
window_tree_host_manager_->cursor_window_controller() window_tree_host_manager_->cursor_window_controller()
->SetLargeCursorSizeInDip(large_cursor_size_in_dip); ->SetLargeCursorSizeInDip(large_cursor_size_in_dip);
......
...@@ -100,7 +100,6 @@ class DockedMagnifierController; ...@@ -100,7 +100,6 @@ class DockedMagnifierController;
class DragDropController; class DragDropController;
class EventClientImpl; class EventClientImpl;
class EventTransformationHandler; class EventTransformationHandler;
class FirstRunHelper;
class FocusCycler; class FocusCycler;
class HighContrastController; class HighContrastController;
class HighlighterController; class HighlighterController;
...@@ -526,10 +525,6 @@ class ASH_EXPORT Shell : public SessionObserver, ...@@ -526,10 +525,6 @@ class ASH_EXPORT Shell : public SessionObserver,
root_window_for_new_windows_ = root; root_window_for_new_windows_ = root;
} }
// Creates instance of FirstRunHelper. Caller is responsible for deleting
// returned object.
ash::FirstRunHelper* CreateFirstRunHelper();
void SetLargeCursorSizeInDip(int large_cursor_size_in_dip); void SetLargeCursorSizeInDip(int large_cursor_size_in_dip);
// Updates cursor compositing on/off. Native cursor is disabled when cursor // Updates cursor compositing on/off. Native cursor is disabled when cursor
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ash/first_run/first_run_helper.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/system/tray/system_tray.h" #include "ash/system/tray/system_tray.h"
#include "chrome/browser/chromeos/first_run/first_run.h" #include "chrome/browser/chromeos/first_run/first_run.h"
...@@ -101,10 +100,6 @@ class FirstRunUIBrowserTest : public InProcessBrowserTest, ...@@ -101,10 +100,6 @@ class FirstRunUIBrowserTest : public InProcessBrowserTest,
test::JSChecker& js() { return js_; } test::JSChecker& js() { return js_; }
ash::FirstRunHelper* shell_helper() {
return controller()->shell_helper_.get();
}
FirstRunController* controller() { FirstRunController* controller() {
return FirstRunController::GetInstanceForTest(); return FirstRunController::GetInstanceForTest();
} }
...@@ -123,20 +118,19 @@ IN_PROC_BROWSER_TEST_F(FirstRunUIBrowserTest, FirstRunFlow) { ...@@ -123,20 +118,19 @@ IN_PROC_BROWSER_TEST_F(FirstRunUIBrowserTest, FirstRunFlow) {
LaunchTutorial(); LaunchTutorial();
WaitForInitialization(); WaitForInitialization();
WaitForStep(first_run::kAppListStep); WaitForStep(first_run::kAppListStep);
EXPECT_FALSE(shell_helper()->IsTrayBubbleOpened()); EXPECT_FALSE(controller()->IsTrayBubbleOpened());
AdvanceStep(); AdvanceStep();
WaitForStep(first_run::kTrayStep); WaitForStep(first_run::kTrayStep);
EXPECT_TRUE(shell_helper()->IsTrayBubbleOpened()); EXPECT_TRUE(controller()->IsTrayBubbleOpened());
AdvanceStep(); AdvanceStep();
WaitForStep(first_run::kHelpStep); WaitForStep(first_run::kHelpStep);
EXPECT_TRUE(shell_helper()->IsTrayBubbleOpened()); EXPECT_TRUE(controller()->IsTrayBubbleOpened());
AdvanceStep(); AdvanceStep();
WaitForFinalization(); WaitForFinalization();
content::RunAllPendingInMessageLoop(); content::RunAllPendingInMessageLoop();
EXPECT_EQ(controller(), (void*)NULL); EXPECT_EQ(controller(), nullptr);
// shell_helper() is destructed already, thats why we call Shell directly. // controller() is destructed already, that's why we call Shell directly.
EXPECT_FALSE(ash::Shell::Get()->GetPrimarySystemTray()->HasSystemBubble()); EXPECT_FALSE(ash::Shell::Get()->GetPrimarySystemTray()->HasSystemBubble());
} }
} // namespace chromeos } // namespace chromeos
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#include "chrome/browser/chromeos/first_run/first_run_controller.h" #include "chrome/browser/chromeos/first_run/first_run_controller.h"
#include "ash/shell.h" #include "ash/first_run/first_run_helper.h"
#include "ash/public/cpp/shelf_prefs.h"
#include "base/location.h" #include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
...@@ -18,6 +19,8 @@ ...@@ -18,6 +19,8 @@
#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/chrome_pages.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
namespace { namespace {
...@@ -62,6 +65,41 @@ void FirstRunController::Stop() { ...@@ -62,6 +65,41 @@ void FirstRunController::Stop() {
g_first_run_controller_instance = NULL; g_first_run_controller_instance = NULL;
} }
gfx::Rect FirstRunController::GetAppListButtonBounds() const {
return shell_helper_->GetAppListButtonBounds();
}
void FirstRunController::OpenTrayBubble() {
shell_helper_->OpenTrayBubble();
}
void FirstRunController::CloseTrayBubble() {
shell_helper_->CloseTrayBubble();
}
bool FirstRunController::IsTrayBubbleOpened() const {
return shell_helper_->IsTrayBubbleOpened();
}
gfx::Rect FirstRunController::GetTrayBubbleBounds() const {
return shell_helper_->GetTrayBubbleBounds();
}
gfx::Rect FirstRunController::GetHelpButtonBounds() const {
return shell_helper_->GetHelpButtonBounds();
}
gfx::Size FirstRunController::GetOverlaySize() const {
return shell_helper_->GetOverlayWidget()->GetWindowBoundsInScreen().size();
}
ash::ShelfAlignment FirstRunController::GetShelfAlignment() const {
DCHECK(user_profile_);
return ash::GetShelfAlignmentPref(
user_profile_->GetPrefs(),
display::Screen::GetScreen()->GetPrimaryDisplay().id());
}
FirstRunController* FirstRunController::GetInstanceForTest() { FirstRunController* FirstRunController::GetInstanceForTest() {
return g_first_run_controller_instance; return g_first_run_controller_instance;
} }
...@@ -78,7 +116,7 @@ void FirstRunController::Init() { ...@@ -78,7 +116,7 @@ void FirstRunController::Init() {
user_profile_ = ProfileHelper::Get()->GetProfileByUserUnsafe( user_profile_ = ProfileHelper::Get()->GetProfileByUserUnsafe(
user_manager->GetActiveUser()); user_manager->GetActiveUser());
shell_helper_.reset(ash::Shell::Get()->CreateFirstRunHelper()); shell_helper_ = std::make_unique<ash::FirstRunHelper>();
shell_helper_->AddObserver(this); shell_helper_->AddObserver(this);
FirstRunView* view = new FirstRunView(); FirstRunView* view = new FirstRunView();
...@@ -160,12 +198,9 @@ void FirstRunController::OnCancelled() { ...@@ -160,12 +198,9 @@ void FirstRunController::OnCancelled() {
} }
void FirstRunController::RegisterSteps() { void FirstRunController::RegisterSteps() {
steps_.push_back(make_linked_ptr( steps_.push_back(make_linked_ptr(new first_run::AppListStep(this, actor_)));
new first_run::AppListStep(shell_helper_.get(), actor_))); steps_.push_back(make_linked_ptr(new first_run::TrayStep(this, actor_)));
steps_.push_back(make_linked_ptr( steps_.push_back(make_linked_ptr(new first_run::HelpStep(this, actor_)));
new first_run::TrayStep(shell_helper_.get(), actor_)));
steps_.push_back(make_linked_ptr(
new first_run::HelpStep(shell_helper_.get(), actor_)));
} }
void FirstRunController::ShowNextStep() { void FirstRunController::ShowNextStep() {
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#include <vector> #include <vector>
#include "ash/first_run/first_run_helper.h" #include "ash/first_run/first_run_helper.h"
#include "ash/public/cpp/shelf_types.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/linked_ptr.h" #include "base/memory/linked_ptr.h"
#include "base/time/time.h" #include "base/time/time.h"
...@@ -49,6 +49,30 @@ class FirstRunController : public FirstRunActor::Delegate, ...@@ -49,6 +49,30 @@ class FirstRunController : public FirstRunActor::Delegate,
// Finalizes first-run tutorial and destroys UI. // Finalizes first-run tutorial and destroys UI.
static void Stop(); static void Stop();
// Returns bounds of application list button in screen coordinates.
gfx::Rect GetAppListButtonBounds() const;
// Opens and closes system tray bubble.
void OpenTrayBubble();
void CloseTrayBubble();
// Returns |true| iff system tray bubble is opened now.
bool IsTrayBubbleOpened() const;
// Returns bounds of system tray bubble in screen coordinates. The bubble
// must be open.
gfx::Rect GetTrayBubbleBounds() const;
// Returns bounds of help app button from system tray bubble in screen
// coordinates. The bubble must be open.
gfx::Rect GetHelpButtonBounds() const;
// Returns the size of the semi-transparent overlay window in DIPs.
gfx::Size GetOverlaySize() const;
// Returns the shelf alignment on the primary display.
ash::ShelfAlignment GetShelfAlignment() const;
private: private:
friend class FirstRunUIBrowserTest; friend class FirstRunUIBrowserTest;
......
...@@ -9,11 +9,8 @@ ...@@ -9,11 +9,8 @@
#include <cctype> #include <cctype>
#include <memory> #include <memory>
#include "ash/first_run/first_run_helper.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h" #include "chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h"
#include "ui/gfx/geometry/size.h"
#include "ui/views/widget/widget.h"
namespace { namespace {
...@@ -40,11 +37,10 @@ namespace chromeos { ...@@ -40,11 +37,10 @@ namespace chromeos {
namespace first_run { namespace first_run {
Step::Step(const std::string& name, Step::Step(const std::string& name,
ash::FirstRunHelper* shell_helper, FirstRunController* controller,
FirstRunActor* actor) FirstRunActor* actor)
: name_(name), : name_(name), first_run_controller_(controller), actor_(actor) {
shell_helper_(shell_helper), DCHECK(first_run_controller_);
actor_(actor) {
} }
Step::~Step() { RecordCompletion(); } Step::~Step() { RecordCompletion(); }
...@@ -64,10 +60,6 @@ void Step::OnAfterHide() { ...@@ -64,10 +60,6 @@ void Step::OnAfterHide() {
DoOnAfterHide(); DoOnAfterHide();
} }
gfx::Size Step::GetOverlaySize() const {
return shell_helper()->GetOverlayWidget()->GetWindowBoundsInScreen().size();
}
void Step::RecordCompletion() { void Step::RecordCompletion() {
if (show_time_.is_null()) if (show_time_.is_null())
return; return;
......
...@@ -10,24 +10,17 @@ ...@@ -10,24 +10,17 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/time/time.h" #include "base/time/time.h"
namespace ash {
class FirstRunHelper;
}
namespace gfx {
class Size;
}
namespace chromeos { namespace chromeos {
class FirstRunActor; class FirstRunActor;
class FirstRunController;
namespace first_run { namespace first_run {
class Step { class Step {
public: public:
Step(const std::string& name, Step(const std::string& name,
ash::FirstRunHelper* shell_helper, FirstRunController* controller,
FirstRunActor* actor); FirstRunActor* actor);
virtual ~Step(); virtual ~Step();
...@@ -43,9 +36,8 @@ class Step { ...@@ -43,9 +36,8 @@ class Step {
const std::string& name() const { return name_; } const std::string& name() const { return name_; }
protected: protected:
ash::FirstRunHelper* shell_helper() const { return shell_helper_; } FirstRunController* first_run_controller() { return first_run_controller_; }
FirstRunActor* actor() const { return actor_; } FirstRunActor* actor() const { return actor_; }
gfx::Size GetOverlaySize() const;
// Called from Show method. // Called from Show method.
virtual void DoShow() = 0; virtual void DoShow() = 0;
...@@ -63,7 +55,7 @@ class Step { ...@@ -63,7 +55,7 @@ class Step {
void RecordCompletion(); void RecordCompletion();
std::string name_; std::string name_;
ash::FirstRunHelper* shell_helper_; FirstRunController* first_run_controller_;
FirstRunActor* actor_; FirstRunActor* actor_;
base::Time show_time_; base::Time show_time_;
...@@ -74,4 +66,3 @@ class Step { ...@@ -74,4 +66,3 @@ class Step {
} // namespace chromeos } // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_FIRST_RUN_STEP_H_ #endif // CHROME_BROWSER_CHROMEOS_FIRST_RUN_STEP_H_
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "chrome/browser/chromeos/first_run/steps/app_list_step.h" #include "chrome/browser/chromeos/first_run/steps/app_list_step.h"
#include "ash/first_run/first_run_helper.h" #include "chrome/browser/chromeos/first_run/first_run_controller.h"
#include "chrome/browser/chromeos/first_run/step_names.h" #include "chrome/browser/chromeos/first_run/step_names.h"
#include "chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h" #include "chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
...@@ -18,13 +18,11 @@ const int kCircleRadius = 30; ...@@ -18,13 +18,11 @@ const int kCircleRadius = 30;
namespace chromeos { namespace chromeos {
namespace first_run { namespace first_run {
AppListStep::AppListStep(ash::FirstRunHelper* shell_helper, AppListStep::AppListStep(FirstRunController* controller, FirstRunActor* actor)
FirstRunActor* actor) : Step(kAppListStep, controller, actor) {}
: Step(kAppListStep, shell_helper, actor) {
}
void AppListStep::DoShow() { void AppListStep::DoShow() {
gfx::Rect button_bounds = shell_helper()->GetAppListButtonBounds(); gfx::Rect button_bounds = first_run_controller()->GetAppListButtonBounds();
gfx::Point center = button_bounds.CenterPoint(); gfx::Point center = button_bounds.CenterPoint();
actor()->AddRoundHole(center.x(), center.y(), kCircleRadius); actor()->AddRoundHole(center.x(), center.y(), kCircleRadius);
actor()->ShowStepPointingTo(name(), center.x(), center.y(), kCircleRadius); actor()->ShowStepPointingTo(name(), center.x(), center.y(), kCircleRadius);
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#ifndef CHROME_BROWSER_CHROMEOS_FIRST_RUN_STEPS_APP_LIST_STEP_H_ #ifndef CHROME_BROWSER_CHROMEOS_FIRST_RUN_STEPS_APP_LIST_STEP_H_
#define CHROME_BROWSER_CHROMEOS_FIRST_RUN_STEPS_APP_LIST_STEP_H_ #define CHROME_BROWSER_CHROMEOS_FIRST_RUN_STEPS_APP_LIST_STEP_H_
#include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/chromeos/first_run/step.h" #include "chrome/browser/chromeos/first_run/step.h"
...@@ -14,7 +13,7 @@ namespace first_run { ...@@ -14,7 +13,7 @@ namespace first_run {
class AppListStep : public Step { class AppListStep : public Step {
public: public:
AppListStep(ash::FirstRunHelper* shell_helper, FirstRunActor* actor); AppListStep(FirstRunController* controller, FirstRunActor* actor);
private: private:
// Overriden from Step. // Overriden from Step.
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "chrome/browser/chromeos/first_run/steps/help_step.h" #include "chrome/browser/chromeos/first_run/steps/help_step.h"
#include "ash/first_run/first_run_helper.h" #include "chrome/browser/chromeos/first_run/first_run_controller.h"
#include "chrome/browser/chromeos/first_run/step_names.h" #include "chrome/browser/chromeos/first_run/step_names.h"
#include "chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h" #include "chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
...@@ -18,21 +18,20 @@ const int kCircleRadius = 19; ...@@ -18,21 +18,20 @@ const int kCircleRadius = 19;
namespace chromeos { namespace chromeos {
namespace first_run { namespace first_run {
HelpStep::HelpStep(ash::FirstRunHelper* shell_helper, FirstRunActor* actor) HelpStep::HelpStep(FirstRunController* controller, FirstRunActor* actor)
: Step(kHelpStep, shell_helper, actor) { : Step(kHelpStep, controller, actor) {}
}
void HelpStep::DoShow() { void HelpStep::DoShow() {
if (!shell_helper()->IsTrayBubbleOpened()) if (!first_run_controller()->IsTrayBubbleOpened())
shell_helper()->OpenTrayBubble(); first_run_controller()->OpenTrayBubble();
gfx::Rect button_bounds = shell_helper()->GetHelpButtonBounds(); gfx::Rect button_bounds = first_run_controller()->GetHelpButtonBounds();
gfx::Point center = button_bounds.CenterPoint(); gfx::Point center = button_bounds.CenterPoint();
actor()->AddRoundHole(center.x(), center.y(), kCircleRadius); actor()->AddRoundHole(center.x(), center.y(), kCircleRadius);
actor()->ShowStepPointingTo(name(), center.x(), center.y(), kCircleRadius); actor()->ShowStepPointingTo(name(), center.x(), center.y(), kCircleRadius);
} }
void HelpStep::DoOnAfterHide() { void HelpStep::DoOnAfterHide() {
shell_helper()->CloseTrayBubble(); first_run_controller()->CloseTrayBubble();
} }
} // namespace first_run } // namespace first_run
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#ifndef CHROME_BROWSER_CHROMEOS_FIRST_RUN_STEPS_HELP_STEP_H_ #ifndef CHROME_BROWSER_CHROMEOS_FIRST_RUN_STEPS_HELP_STEP_H_
#define CHROME_BROWSER_CHROMEOS_FIRST_RUN_STEPS_HELP_STEP_H_ #define CHROME_BROWSER_CHROMEOS_FIRST_RUN_STEPS_HELP_STEP_H_
#include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/chromeos/first_run/step.h" #include "chrome/browser/chromeos/first_run/step.h"
...@@ -14,7 +13,7 @@ namespace first_run { ...@@ -14,7 +13,7 @@ namespace first_run {
class HelpStep : public Step { class HelpStep : public Step {
public: public:
HelpStep(ash::FirstRunHelper* shell_helper, FirstRunActor* actor); HelpStep(FirstRunController* controller, FirstRunActor* actor);
private: private:
// Overriden from Step. // Overriden from Step.
......
...@@ -4,10 +4,9 @@ ...@@ -4,10 +4,9 @@
#include "chrome/browser/chromeos/first_run/steps/tray_step.h" #include "chrome/browser/chromeos/first_run/steps/tray_step.h"
#include "ash/first_run/first_run_helper.h" #include "ash/public/cpp/shelf_types.h"
#include "ash/shelf/shelf.h"
#include "ash/shell.h"
#include "base/i18n/rtl.h" #include "base/i18n/rtl.h"
#include "chrome/browser/chromeos/first_run/first_run_controller.h"
#include "chrome/browser/chromeos/first_run/step_names.h" #include "chrome/browser/chromeos/first_run/step_names.h"
#include "chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h" #include "chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
...@@ -16,25 +15,26 @@ ...@@ -16,25 +15,26 @@
namespace chromeos { namespace chromeos {
namespace first_run { namespace first_run {
TrayStep::TrayStep(ash::FirstRunHelper* shell_helper, FirstRunActor* actor) TrayStep::TrayStep(FirstRunController* controller, FirstRunActor* actor)
: Step(kTrayStep, shell_helper, actor) { : Step(kTrayStep, controller, actor) {}
}
void TrayStep::DoShow() { void TrayStep::DoShow() {
if (!shell_helper()->IsTrayBubbleOpened()) if (!first_run_controller()->IsTrayBubbleOpened())
shell_helper()->OpenTrayBubble(); first_run_controller()->OpenTrayBubble();
gfx::Rect bounds = shell_helper()->GetTrayBubbleBounds(); gfx::Rect bounds = first_run_controller()->GetTrayBubbleBounds();
actor()->AddRectangularHole(bounds.x(), bounds.y(), bounds.width(), actor()->AddRectangularHole(bounds.x(), bounds.y(), bounds.width(),
bounds.height()); bounds.height());
FirstRunActor::StepPosition position; FirstRunActor::StepPosition position;
position.SetTop(bounds.y()); position.SetTop(bounds.y());
ash::ShelfAlignment alignment = ash::ShelfAlignment alignment = first_run_controller()->GetShelfAlignment();
ash::Shelf::ForWindow(ash::Shell::GetPrimaryRootWindow())->alignment();
if ((!base::i18n::IsRTL() && alignment != ash::SHELF_ALIGNMENT_LEFT) || if ((!base::i18n::IsRTL() && alignment != ash::SHELF_ALIGNMENT_LEFT) ||
alignment == ash::SHELF_ALIGNMENT_RIGHT) alignment == ash::SHELF_ALIGNMENT_RIGHT) {
position.SetRight(GetOverlaySize().width() - bounds.x()); // Compute pixel inset from right side of screen.
else const gfx::Size overlay_size = first_run_controller()->GetOverlaySize();
position.SetRight(overlay_size.width() - bounds.x());
} else {
position.SetLeft(bounds.right()); position.SetLeft(bounds.right());
}
actor()->ShowStepPositioned(name(), position); actor()->ShowStepPositioned(name(), position);
} }
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#ifndef CHROME_BROWSER_CHROMEOS_FIRST_RUN_STEPS_TRAY_STEP_H_ #ifndef CHROME_BROWSER_CHROMEOS_FIRST_RUN_STEPS_TRAY_STEP_H_
#define CHROME_BROWSER_CHROMEOS_FIRST_RUN_STEPS_TRAY_STEP_H_ #define CHROME_BROWSER_CHROMEOS_FIRST_RUN_STEPS_TRAY_STEP_H_
#include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/chromeos/first_run/step.h" #include "chrome/browser/chromeos/first_run/step.h"
...@@ -14,7 +13,7 @@ namespace first_run { ...@@ -14,7 +13,7 @@ namespace first_run {
class TrayStep : public Step { class TrayStep : public Step {
public: public:
TrayStep(ash::FirstRunHelper* shell_helper, FirstRunActor* actor); TrayStep(FirstRunController* controller, FirstRunActor* actor);
private: private:
// Overriden from Step. // Overriden from Step.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment