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

Unified Diff: ui/aura_shell/launcher/launcher.cc

Issue 8247012: Positions the launcher in the bottom left corner. Adds ShellDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaks Created 9 years, 2 months 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
« no previous file with comments | « ui/aura_shell/launcher/launcher.h ('k') | ui/aura_shell/launcher/launcher_model.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura_shell/launcher/launcher.cc
diff --git a/ui/aura_shell/launcher/launcher.cc b/ui/aura_shell/launcher/launcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5835b2725cffa93ac3208361c41c39ad0288df8c
--- /dev/null
+++ b/ui/aura_shell/launcher/launcher.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 2011 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 "ui/aura_shell/launcher/launcher.h"
+
+#include "ui/aura/toplevel_window_container.h"
+#include "ui/aura_shell/launcher/launcher_model.h"
+#include "ui/aura_shell/launcher/launcher_view.h"
+#include "ui/aura_shell/shell.h"
+#include "ui/aura_shell/shell_delegate.h"
+#include "ui/aura_shell/shell_window_ids.h"
+#include "ui/gfx/compositor/layer.h"
+#include "views/widget/widget.h"
+
+namespace aura_shell {
+
+Launcher::Launcher(aura::ToplevelWindowContainer* window_container)
+ : window_container_(window_container),
+ widget_(NULL) {
+ window_container->AddObserver(this);
+
+ model_.reset(new LauncherModel);
+
+ widget_ = new views::Widget;
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
+ params.parent = Shell::GetInstance()->GetContainer(
+ aura_shell::internal::kShellWindowId_LauncherContainer);
+ internal::LauncherView* launcher_view =
+ new internal::LauncherView(model_.get());
+ launcher_view->Init();
+ params.delegate = launcher_view;
+ widget_->Init(params);
+ widget_->GetNativeWindow()->layer()->SetOpacity(0.8f);
+ gfx::Size pref = static_cast<views::View*>(launcher_view)->GetPreferredSize();
+ widget_->SetBounds(gfx::Rect(0, 0, pref.width(), pref.height()));
+ widget_->SetContentsView(launcher_view);
+ widget_->Show();
+ widget_->GetNativeView()->set_name("LauncherView");
+}
+
+Launcher::~Launcher() {
+ window_container_->RemoveObserver(this);
+}
+
+void Launcher::OnWindowAdded(aura::Window* new_window) {
+ ShellDelegate* delegate = Shell::GetInstance()->delegate();
+ if (!delegate)
+ return;
+ LauncherItem item;
+ item.window = new_window;
+ if (!delegate->ConfigureLauncherItem(&item))
+ return; // The delegate doesn't want to show this item in the launcher.
+ model_->Add(model_->items().size(), item);
+}
+
+void Launcher::OnWillRemoveWindow(aura::Window* window) {
+ const LauncherItems& items(model_->items());
+ for (LauncherItems::const_iterator i = items.begin(); i != items.end(); ++i) {
+ if (i->window == window) {
+ model_->RemoveItemAt(i - items.begin());
+ break;
+ }
+ }
+}
+
+} // namespace aura_shell
« no previous file with comments | « ui/aura_shell/launcher/launcher.h ('k') | ui/aura_shell/launcher/launcher_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698