| Index: chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc
|
| diff --git a/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc
|
| index 14d80ecafdd11bacf235fe449a7c0d1b8fffed59..c3f0bad94eff227227d13af7f4848b4da33c920b 100644
|
| --- a/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc
|
| +++ b/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc
|
| @@ -9,6 +9,7 @@
|
| #include "ash/shelf/shelf_model.h"
|
| #include "ash/wm/window_state.h"
|
| #include "ash/wm/window_util.h"
|
| +#include "chrome/browser/extensions/webstore_install_with_prompt.h"
|
| #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h"
|
| #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h"
|
| #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
|
| @@ -50,6 +51,14 @@ scoped_ptr<gfx::Image> GetAppListIcon(AppWindow* app_window) {
|
| new gfx::Image(gfx::ImageSkia::CreateFrom1xBitmap(bmp)));
|
| }
|
|
|
| +// Returns true if the app window is visible on screen, i.e. not hidden or
|
| +// minimized.
|
| +bool IsAppWindowVisible(AppWindow* app_window) {
|
| + return app_window &&
|
| + !app_window->is_hidden() &&
|
| + !app_window->GetBaseWindow()->IsMinimized();
|
| +}
|
| +
|
| // Functor for std::find_if used in AppLauncherItemController.
|
| class AppWindowHasWindow {
|
| public:
|
| @@ -151,6 +160,38 @@ void AppWindowLauncherItemController::ActivateIndexedApp(size_t index) {
|
| ShowAndActivateOrMinimize(*it);
|
| }
|
|
|
| +void AppWindowLauncherItemController::InstallApp() {
|
| + // Find a visible window in order to position the install dialog. If there is
|
| + // no visible window, the dialog will be centered on the screen.
|
| + AppWindow* parent_window = NULL;
|
| + if (IsAppWindowVisible(last_active_app_window_)) {
|
| + parent_window = last_active_app_window_;
|
| + } else {
|
| + for (AppWindowList::iterator iter = app_windows_.begin();
|
| + iter != app_windows_.end(); ++iter) {
|
| + if (IsAppWindowVisible(*iter)) {
|
| + parent_window = *iter;
|
| + break;
|
| + }
|
| + }
|
| + }
|
| +
|
| + scoped_refptr<extensions::WebstoreInstallWithPrompt> installer;
|
| + if (parent_window) {
|
| + installer = new extensions::WebstoreInstallWithPrompt(
|
| + app_id(),
|
| + launcher_controller()->profile(),
|
| + parent_window->GetNativeWindow(),
|
| + extensions::WebstoreInstallWithPrompt::Callback());
|
| + } else {
|
| + installer = new extensions::WebstoreInstallWithPrompt(
|
| + app_id(),
|
| + launcher_controller()->profile(),
|
| + extensions::WebstoreInstallWithPrompt::Callback());
|
| + }
|
| + installer->BeginInstall();
|
| +}
|
| +
|
| ChromeLauncherAppMenuItems AppWindowLauncherItemController::GetApplicationList(
|
| int event_flags) {
|
| ChromeLauncherAppMenuItems items;
|
|
|