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

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

Issue 8747021: [Aura] Polish app list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 f0aef7ab09ccb0dd38d4bfdc47b956c8956feb68..c14c464fc98c80c2e8652de02814314b38c774b3 100644
--- a/chrome/browser/ui/views/aura/app_list_window.cc
+++ b/chrome/browser/ui/views/aura/app_list_window.cc
@@ -9,14 +9,17 @@
#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 "ui/aura_shell/shell.h"
#include "ui/views/widget/widget.h"
-AppListWindow::AppListWindow(
+AppListWindow::AppListWindow(const gfx::Rect& bounds,
const aura_shell::ShellDelegate::SetWidgetCallback& callback)
: widget_(NULL),
contents_(NULL),
- callback_(callback) {
- Init();
+ callback_(callback),
+ content_rendered_(false),
+ apps_loaded_(false) {
+ Init(bounds);
}
AppListWindow::~AppListWindow() {
@@ -26,7 +29,7 @@ void AppListWindow::DeleteDelegate() {
delete this;
}
-views::View* AppListWindow::GetContentsView() {
+views::View* AppListWindow::GetInitiallyFocusedView() {
return contents_;
}
@@ -38,6 +41,30 @@ const views::Widget* AppListWindow::GetWidget() const {
return widget_;
}
+bool AppListWindow::HandleContextMenu(const ContextMenuParams& params) {
+ // Do not show the context menu for non-debug build.
+#ifndef NDEBUG
sky 2011/11/30 21:50:21 #if !defined(NDEBUG)
xiyuan 2011/11/30 22:26:34 Done.
+ return false;
+#else
+ return true;
+#endif
+}
+
+void AppListWindow::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {
+ if (event.windowsKeyCode == 27) // ESC
sky 2011/11/30 21:50:21 Isn't there a constant you can match against?
xiyuan 2011/11/30 22:26:34 Done. :p
+ Close();
+}
+
+bool AppListWindow::TakeFocus(bool reverse) {
+ // Forward the focus back to web contents.
+ contents_->dom_contents()->tab_contents()->FocusThroughTabTraversal(reverse);
+ return true;
+}
+
+bool AppListWindow::IsPopupOrPanel(const TabContents* source) const {
+ return true;
+}
+
void AppListWindow::OnRenderHostCreated(RenderViewHost* host) {
}
@@ -45,10 +72,21 @@ void AppListWindow::OnTabMainFrameLoaded() {
}
void AppListWindow::OnTabMainFrameFirstRender() {
- callback_.Run(widget_);
+ content_rendered_ = true;
+ SetWidgetIfReady();
+}
+
+void AppListWindow::Close() {
+ // We should be visible when running here and toggle actually closes us.
+ aura_shell::Shell::GetInstance()->ToggleAppList();
}
-void AppListWindow::Init() {
+void AppListWindow::OnAppsLoaded() {
+ apps_loaded_ = true;
+ SetWidgetIfReady();
+}
+
+void AppListWindow::Init(const gfx::Rect& bounds) {
DCHECK(!widget_ && !contents_);
contents_ = new DOMView();
@@ -56,8 +94,10 @@ void AppListWindow::Init() {
TabContents* tab = contents_->dom_contents()->tab_contents();
tab_watcher_.reset(new TabFirstRenderWatcher(tab, this));
+ tab->set_delegate(this);
contents_->LoadURL(GURL(chrome::kChromeUIAppListURL));
+ static_cast<AppListUI*>(tab->web_ui())->set_delegate(this);
// Use a background with transparency to trigger transparent webkit.
SkBitmap background;
@@ -70,10 +110,7 @@ void AppListWindow::Init() {
views::Widget::InitParams widget_params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
- // 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.bounds = bounds;
widget_params.delegate = this;
widget_params.keep_on_top = true;
widget_params.transparent = true;
@@ -82,3 +119,8 @@ void AppListWindow::Init() {
widget_->Init(widget_params);
widget_->SetContentsView(contents_);
}
+
+void AppListWindow::SetWidgetIfReady() {
+ if (content_rendered_ && apps_loaded_)
+ callback_.Run(widget_);
+}

Powered by Google App Engine
This is Rietveld 408576698