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

Unified Diff: chrome/browser/ui/ash/launcher/shell_window_launcher_controller.cc

Issue 11363250: Allow Chrome apps to create Ash Panels (apps v2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac and win builds Created 8 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/ash/launcher/shell_window_launcher_controller.cc
diff --git a/chrome/browser/ui/ash/launcher/shell_window_launcher_controller.cc b/chrome/browser/ui/ash/launcher/shell_window_launcher_controller.cc
index af2b06ce3d853f0e5fa14daee6a0e68b3c4b6f1a..a55016b8a2815841a33103e653e67258a312c9d2 100644
--- a/chrome/browser/ui/ash/launcher/shell_window_launcher_controller.cc
+++ b/chrome/browser/ui/ash/launcher/shell_window_launcher_controller.cc
@@ -9,6 +9,8 @@
#include "ash/shell.h"
#include "ash/wm/window_util.h"
#include "base/stl_util.h"
+#include "base/string_number_conversions.h"
+#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
@@ -19,17 +21,12 @@
namespace {
-// Currently apps have a single launcher item, so the launcher id is the
-// same as the app id. In the future, this may not be true (e.g. for panels).
std::string GetAppLauncherId(ShellWindow* shell_window) {
+ if (shell_window->window_type() == ShellWindow::WINDOW_TYPE_PANEL)
+ return StringPrintf("panel:%d", shell_window->session_id().id());
return shell_window->extension()->id();
}
-bool AppLauncherIdIsForApp(const std::string& app_launcher_id,
- const std::string& app_id) {
- return app_launcher_id == app_id;
-}
-
// Functor for std::find_if used in AppLauncherItemController.
class ShellWindowHasWindow {
public:
@@ -114,7 +111,7 @@ class ShellWindowLauncherController::AppLauncherItemController
virtual void Activate() OVERRIDE {
DCHECK(!shell_windows_.empty());
- ShowAndActivate(shell_windows_.front());
+ shell_windows_.front()->GetBaseWindow()->Activate();
}
virtual void Close() OVERRIDE {
@@ -139,14 +136,14 @@ class ShellWindowLauncherController::AppLauncherItemController
if (first_window->GetBaseWindow()->IsActive())
first_window->GetBaseWindow()->Minimize();
else
- ShowAndActivate(first_window);
+ RestoreOrShow(first_window);
} else {
if (!first_window->GetBaseWindow()->IsActive()) {
- ShowAndActivate(first_window);
+ RestoreOrShow(first_window);
} else {
shell_windows_.pop_front();
shell_windows_.push_back(first_window);
- ShowAndActivate(shell_windows_.front());
+ RestoreOrShow(shell_windows_.front());
}
}
}
@@ -163,8 +160,12 @@ class ShellWindowLauncherController::AppLauncherItemController
private:
typedef std::list<ShellWindow*> ShellWindowList;
- void ShowAndActivate(ShellWindow* shell_window) {
- shell_window->GetBaseWindow()->Show();
+ void RestoreOrShow(ShellWindow* shell_window) {
+ if (shell_window->GetBaseWindow()->IsMinimized())
+ shell_window->GetBaseWindow()->Restore();
+ else
+ shell_window->GetBaseWindow()->Show();
+ // Always activate windows when shown from the launcher.
shell_window->GetBaseWindow()->Activate();
}

Powered by Google App Engine
This is Rietveld 408576698