Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(454)

Unified Diff: chrome/browser/ui/views/aura/app_list_window.cc

Issue 8558031: [Aura] Refactor and update app list window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync, change initial size close to final size to avoid CardSlider resize animation Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/aura/app_list_window.cc
diff --git a/chrome/browser/ui/views/aura/app_list_window.cc b/chrome/browser/ui/views/aura/app_list_window.cc
index 5bf0d6a7118168dd0dbc544c47ffe2bbad07e5f5..75dc673db1c7f73086129b3af3aa8ce97c15509f 100644
--- a/chrome/browser/ui/views/aura/app_list_window.cc
+++ b/chrome/browser/ui/views/aura/app_list_window.cc
@@ -4,63 +4,19 @@
#include "chrome/browser/ui/views/aura/app_list_window.h"
-#include "base/bind.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/views/dom_view.h"
#include "chrome/common/url_constants.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
#include "views/widget/widget.h"
-#include "ui/aura/desktop.h"
-#include "ui/gfx/compositor/layer_animator.h"
-#include "ui/gfx/screen.h"
-namespace {
-
-// Gets preferred bounds of app list window in show/hide state.
-gfx::Rect GetPreferredBounds(bool show) {
- // The y-axis offset used at the beginning of showing animation.
- static const int kMoveUpAnimationOffset = 50;
-
- gfx::Point cursor = gfx::Screen::GetCursorScreenPoint();
- gfx::Rect work_area = gfx::Screen::GetMonitorWorkAreaNearestPoint(cursor);
- gfx::Rect widget_bounds(work_area);
- widget_bounds.Inset(150, 100);
- if (!show)
- widget_bounds.Offset(0, kMoveUpAnimationOffset);
-
- return widget_bounds;
-}
-
-ui::Layer* GetWidgetLayer(views::Widget* widget) {
- return widget->GetNativeView()->layer();
-}
-
-} // namespace
-
-// static
-AppListWindow* AppListWindow::instance_ = NULL;
-
-// static
-void AppListWindow::SetVisible(bool visible) {
- if (!instance_) {
- instance_ = new AppListWindow;
- instance_->Init();
- }
-
- instance_->DoSetVisible(visible);
-}
-
-// static
-bool AppListWindow::IsVisible() {
- return instance_ && instance_->is_visible_;
-}
-
-AppListWindow::AppListWindow()
+AppListWindow::AppListWindow(
+ const aura_shell::ShellDelegate::SetWidgetCallback& callback)
: widget_(NULL),
contents_(NULL),
- is_visible_(false),
- content_rendered_(false) {
+ callback_(callback) {
+ Init();
}
AppListWindow::~AppListWindow() {
@@ -74,11 +30,6 @@ views::View* AppListWindow::GetContentsView() {
return contents_;
}
-void AppListWindow::WindowClosing() {
- aura::Desktop::GetInstance()->RemoveObserver(this);
- widget_ = NULL;
-}
-
views::Widget* AppListWindow::GetWidget() {
return widget_;
}
@@ -87,25 +38,6 @@ const views::Widget* AppListWindow::GetWidget() const {
return widget_;
}
-void AppListWindow::OnActiveWindowChanged(aura::Window* active) {
- if (widget_ && !widget_->IsActive() && is_visible_)
- DoSetVisible(false);
-}
-
-void AppListWindow::OnLayerAnimationEnded(
- const ui::LayerAnimationSequence* sequence) {
- if (!is_visible_ )
- widget_->Close();
-}
-
-void AppListWindow::OnLayerAnimationAborted(
- const ui::LayerAnimationSequence* sequence) {
-}
-
-void AppListWindow::OnLayerAnimationScheduled(
- const ui::LayerAnimationSequence* sequence) {
-}
-
void AppListWindow::OnRenderHostCreated(RenderViewHost* host) {
}
@@ -113,13 +45,7 @@ void AppListWindow::OnTabMainFrameLoaded() {
}
void AppListWindow::OnTabMainFrameFirstRender() {
- content_rendered_ = true;
-
- // Do deferred show animation if necessary.
- if (is_visible_ && GetWidgetLayer(widget_)->opacity() == 0) {
- is_visible_ = false;
- DoSetVisible(true);
- }
+ callback_.Run(widget_);
}
void AppListWindow::Init() {
@@ -130,7 +56,6 @@ void AppListWindow::Init() {
TabContents* tab = contents_->dom_contents()->tab_contents();
tab_watcher_.reset(new TabFirstRenderWatcher(tab, this));
- content_rendered_ = false;
contents_->LoadURL(GURL(chrome::kChromeUIAppListURL));
@@ -145,7 +70,10 @@ void AppListWindow::Init() {
views::Widget::InitParams widget_params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
- widget_params.bounds = GetPreferredBounds(false);
+ // A non-empty bounds so that we get rendered notification. Make the size
+ // close the final size so that card slider resize handler does no generate
+ // unexpected animation.
+ widget_params.bounds = gfx::Rect(0, 0, 900, 700);
widget_params.delegate = this;
widget_params.keep_on_top = true;
widget_params.transparent = true;
@@ -153,32 +81,4 @@ void AppListWindow::Init() {
widget_ = new views::Widget;
widget_->Init(widget_params);
widget_->SetContentsView(contents_);
- widget_->SetOpacity(0);
-
- GetWidgetLayer(widget_)->GetAnimator()->AddObserver(this);
- aura::Desktop::GetInstance()->AddObserver(this);
-}
-
-void AppListWindow::DoSetVisible(bool visible) {
- if (visible == is_visible_)
- return;
-
- is_visible_ = visible;
-
- // Skip show animation if contents is not rendered.
- // TODO(xiyuan): Should we show a loading UI if it takes too long?
- if (visible && !content_rendered_)
- return;
-
- ui::Layer* layer = GetWidgetLayer(widget_);
- ui::LayerAnimator::ScopedSettings settings(layer->GetAnimator());
- layer->SetBounds(GetPreferredBounds(visible));
- layer->SetOpacity(visible ? 1.0 : 0.0);
-
- if (visible) {
- widget_->Show();
- widget_->Activate();
- } else {
- instance_ = NULL; // Closing and don't reuse this instance_.
- }
}
« no previous file with comments | « chrome/browser/ui/views/aura/app_list_window.h ('k') | chrome/browser/ui/views/aura/chrome_shell_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698