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

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: set tile-page-scrollbar color Created 9 years 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..8d4f2f472915c99c53b67dd9fad54c1282bf9237 100644
--- a/chrome/browser/ui/views/aura/app_list_window.cc
+++ b/chrome/browser/ui/views/aura/app_list_window.cc
@@ -6,17 +6,21 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/views/dom_view.h"
+#include "chrome/browser/ui/webui/aura/app_list_ui.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 "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 +30,7 @@ void AppListWindow::DeleteDelegate() {
delete this;
}
-views::View* AppListWindow::GetContentsView() {
+views::View* AppListWindow::GetInitiallyFocusedView() {
return contents_;
}
@@ -38,6 +42,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.
+#if !defined(NDEBUG)
+ return false;
+#else
+ return true;
+#endif
+}
+
+void AppListWindow::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {
+ if (event.windowsKeyCode == ui::VKEY_ESCAPE)
+ 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 +73,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 +95,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 +111,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 +120,8 @@ void AppListWindow::Init() {
widget_->Init(widget_params);
widget_->SetContentsView(contents_);
}
+
+void AppListWindow::SetWidgetIfReady() {
+ if (content_rendered_ && apps_loaded_)
+ callback_.Run(widget_);
+}
« 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