Commit 9c44406b authored by koz@chromium.org's avatar koz@chromium.org

Make the Remove Extension dialog modal for win app list.

BUG=234594

Review URL: https://chromiumcodereview.appspot.com/15715018

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203107 0039d316-1c4b-4281-b951-d872f2087c98
parent e566d2b0
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "ui/gfx/native_widget_types.h"
class AppListControllerDelegate; class AppListControllerDelegate;
class CommandLine; class CommandLine;
...@@ -61,6 +62,9 @@ class AppListService { ...@@ -61,6 +62,9 @@ class AppListService {
// operating system and shell. // operating system and shell.
virtual void EnableAppList() = 0; virtual void EnableAppList() = 0;
// Get the window the app list is in, or NULL if the app list isn't visible.
virtual gfx::NativeWindow GetAppListWindow() = 0;
// Exposed to allow testing of the controller delegate. // Exposed to allow testing of the controller delegate.
virtual AppListControllerDelegate* CreateControllerDelegate() = 0; virtual AppListControllerDelegate* CreateControllerDelegate() = 0;
......
...@@ -43,6 +43,10 @@ class AppListServiceDisabled : public AppListService { ...@@ -43,6 +43,10 @@ class AppListServiceDisabled : public AppListService {
return NULL; return NULL;
} }
virtual gfx::NativeWindow GetAppListWindow() OVERRIDE {
return NULL;
}
DISALLOW_COPY_AND_ASSIGN(AppListServiceDisabled); DISALLOW_COPY_AND_ASSIGN(AppListServiceDisabled);
}; };
......
...@@ -50,7 +50,6 @@ class AppListServiceMac : public AppListServiceImpl, ...@@ -50,7 +50,6 @@ class AppListServiceMac : public AppListServiceImpl,
} }
void CreateAppList(Profile* profile); void CreateAppList(Profile* profile);
NSWindow* GetNativeWindow();
void ShowWindowNearDock(); void ShowWindowNearDock();
// AppListService overrides: // AppListService overrides:
...@@ -59,6 +58,7 @@ class AppListServiceMac : public AppListServiceImpl, ...@@ -59,6 +58,7 @@ class AppListServiceMac : public AppListServiceImpl,
virtual void DismissAppList() OVERRIDE; virtual void DismissAppList() OVERRIDE;
virtual bool IsAppListVisible() const OVERRIDE; virtual bool IsAppListVisible() const OVERRIDE;
virtual void EnableAppList() OVERRIDE; virtual void EnableAppList() OVERRIDE;
virtual gfx::NativeWindow GetAppListWindow() OVERRIDE;
// AppShimHandler overrides: // AppShimHandler overrides:
virtual bool OnShimLaunch(apps::AppShimHandler::Host* host) OVERRIDE; virtual bool OnShimLaunch(apps::AppShimHandler::Host* host) OVERRIDE;
...@@ -169,7 +169,7 @@ void AppListControllerDelegateCocoa::DismissView() { ...@@ -169,7 +169,7 @@ void AppListControllerDelegateCocoa::DismissView() {
} }
gfx::NativeWindow AppListControllerDelegateCocoa::GetAppListWindow() { gfx::NativeWindow AppListControllerDelegateCocoa::GetAppListWindow() {
return AppListServiceMac::GetInstance()->GetNativeWindow(); return AppListServiceMac::GetInstance()->GetAppListWindow();
} }
bool AppListControllerDelegateCocoa::CanPin() { bool AppListControllerDelegateCocoa::CanPin() {
...@@ -267,7 +267,7 @@ void AppListServiceMac::EnableAppList() { ...@@ -267,7 +267,7 @@ void AppListServiceMac::EnableAppList() {
// TODO(tapted): Implement enable logic here for OSX. // TODO(tapted): Implement enable logic here for OSX.
} }
NSWindow* AppListServiceMac::GetNativeWindow() { NSWindow* AppListServiceMac::GetAppListWindow() {
return [window_controller_ window]; return [window_controller_ window];
} }
...@@ -358,7 +358,7 @@ NSPoint GetAppListWindowOrigin(NSWindow* window) { ...@@ -358,7 +358,7 @@ NSPoint GetAppListWindowOrigin(NSWindow* window) {
} }
void AppListServiceMac::ShowWindowNearDock() { void AppListServiceMac::ShowWindowNearDock() {
NSWindow* window = GetNativeWindow(); NSWindow* window = GetAppListWindow();
DCHECK(window); DCHECK(window);
[window setFrameOrigin:GetAppListWindowOrigin(window)]; [window setFrameOrigin:GetAppListWindowOrigin(window)];
[window makeKeyAndOrderFront:nil]; [window makeKeyAndOrderFront:nil];
......
...@@ -32,6 +32,7 @@ class AppListServiceAsh : public AppListServiceImpl { ...@@ -32,6 +32,7 @@ class AppListServiceAsh : public AppListServiceImpl {
virtual bool IsAppListVisible() const OVERRIDE; virtual bool IsAppListVisible() const OVERRIDE;
virtual void DismissAppList() OVERRIDE; virtual void DismissAppList() OVERRIDE;
virtual void EnableAppList() OVERRIDE; virtual void EnableAppList() OVERRIDE;
virtual gfx::NativeWindow GetAppListWindow() OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(AppListServiceAsh); DISALLOW_COPY_AND_ASSIGN(AppListServiceAsh);
}; };
...@@ -60,6 +61,12 @@ void AppListServiceAsh::DismissAppList() { ...@@ -60,6 +61,12 @@ void AppListServiceAsh::DismissAppList() {
void AppListServiceAsh::EnableAppList() {} void AppListServiceAsh::EnableAppList() {}
gfx::NativeWindow AppListServiceAsh::GetAppListWindow() {
if (ash::Shell::HasInstance())
return ash::Shell::GetInstance()->GetAppListWindow();
return NULL;
}
} // namespace } // namespace
namespace chrome { namespace chrome {
......
...@@ -311,6 +311,7 @@ class AppListController : public AppListServiceImpl { ...@@ -311,6 +311,7 @@ class AppListController : public AppListServiceImpl {
virtual void DismissAppList() OVERRIDE; virtual void DismissAppList() OVERRIDE;
virtual bool IsAppListVisible() const OVERRIDE; virtual bool IsAppListVisible() const OVERRIDE;
virtual void EnableAppList() OVERRIDE; virtual void EnableAppList() OVERRIDE;
virtual gfx::NativeWindow GetAppListWindow() OVERRIDE;
virtual AppListControllerDelegate* CreateControllerDelegate() OVERRIDE; virtual AppListControllerDelegate* CreateControllerDelegate() OVERRIDE;
// AppListServiceImpl overrides: // AppListServiceImpl overrides:
...@@ -409,8 +410,7 @@ void AppListControllerDelegateWin::ViewClosing() { ...@@ -409,8 +410,7 @@ void AppListControllerDelegateWin::ViewClosing() {
} }
gfx::NativeWindow AppListControllerDelegateWin::GetAppListWindow() { gfx::NativeWindow AppListControllerDelegateWin::GetAppListWindow() {
app_list::AppListView* view = AppListController::GetInstance()->GetView(); return AppListController::GetInstance()->GetAppListWindow();
return view ? view->GetWidget()->GetNativeWindow() : NULL;
} }
gfx::ImageSkia AppListControllerDelegateWin::GetWindowIcon() { gfx::ImageSkia AppListControllerDelegateWin::GetWindowIcon() {
...@@ -483,6 +483,12 @@ AppListController::AppListController() ...@@ -483,6 +483,12 @@ AppListController::AppListController()
AppListController::~AppListController() { AppListController::~AppListController() {
} }
gfx::NativeWindow AppListController::GetAppListWindow() {
if (!IsAppListVisible())
return NULL;
return current_view_ ? current_view_->GetWidget()->GetNativeWindow() : NULL;
}
AppListControllerDelegate* AppListController::CreateControllerDelegate() { AppListControllerDelegate* AppListController::CreateControllerDelegate() {
return new AppListControllerDelegateWin(); return new AppListControllerDelegateWin();
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/ui/app_list/app_list_service.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension.h"
...@@ -40,19 +41,15 @@ int HorizontalMargin() { ...@@ -40,19 +41,15 @@ int HorizontalMargin() {
} }
// Returns parent window for extension uninstall dialog. // Returns parent window for extension uninstall dialog.
// For ash, use app list window if it is visible. // For platforms with an app list, use the app list window if it is visible.
// For other platforms or when app list is not visible on ash, // For other platforms or when app list is not visible, use the given browser
// use the given browser window. // window.
// Note this function could return NULL if ash app list is not visible and // Note this function could return NULL if the app list is not visible and
// there is no browser window. // there is no browser window.
gfx::NativeWindow GetParent(Browser* browser) { gfx::NativeWindow GetParent(Browser* browser) {
#if defined(USE_ASH) gfx::NativeWindow window = AppListService::Get()->GetAppListWindow();
if (ash::Shell::HasInstance()) { if (window)
gfx::NativeWindow app_list = ash::Shell::GetInstance()->GetAppListWindow(); return window;
if (app_list)
return app_list;
}
#endif
if (browser && browser->window()) if (browser && browser->window())
return browser->window()->GetNativeWindow(); return browser->window()->GetNativeWindow();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment