diff options
Diffstat (limited to 'chrome/browser/ui/views/extensions/extension_dialog.cc')
-rw-r--r-- | chrome/browser/ui/views/extensions/extension_dialog.cc | 76 |
1 files changed, 43 insertions, 33 deletions
diff --git a/chrome/browser/ui/views/extensions/extension_dialog.cc b/chrome/browser/ui/views/extensions/extension_dialog.cc index 35f8220..9f0ec8f 100644 --- a/chrome/browser/ui/views/extensions/extension_dialog.cc +++ b/chrome/browser/ui/views/extensions/extension_dialog.cc @@ -19,12 +19,13 @@ #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" #include "googleurl/src/gurl.h" +#include "ui/gfx/screen.h" #include "ui/views/background.h" #include "ui/views/widget/widget.h" #if defined(USE_AURA) +#include "ash/shell.h" #include "ui/aura/root_window.h" -#include "ui/aura/window.h" #endif using content::WebContents; @@ -58,19 +59,27 @@ ExtensionDialog* ExtensionDialog::Show( int height, const string16& title, ExtensionDialogObserver* observer) { - return ExtensionDialog::ShowInternal(url, browser, web_contents, width, - height, false, title, observer); + ExtensionHost* host = CreateExtensionHost(url, browser, NULL); + if (!host) + return NULL; + host->set_associated_web_contents(web_contents); + + return ExtensionDialog::ShowInternal(url, browser, host, width, height, + false, title, observer); } #if defined(USE_AURA) // static ExtensionDialog* ExtensionDialog::ShowFullscreen( const GURL& url, - Browser* browser, - WebContents* web_contents, + Profile* profile, const string16& title, ExtensionDialogObserver* observer) { - return ExtensionDialog::ShowInternal(url, browser, web_contents, 0, 0, + ExtensionHost* host = CreateExtensionHost(url, NULL, profile); + if (!host) + return NULL; + + return ExtensionDialog::ShowInternal(url, NULL, host, 0, 0, true, title, observer); } #endif @@ -78,22 +87,18 @@ ExtensionDialog* ExtensionDialog::ShowFullscreen( // static ExtensionDialog* ExtensionDialog::ShowInternal(const GURL& url, Browser* browser, - content::WebContents* web_contents, + ExtensionHost* host, int width, int height, bool fullscreen, const string16& title, ExtensionDialogObserver* observer) { - CHECK(browser); - ExtensionHost* host = CreateExtensionHost(url, browser); - if (!host) - return NULL; - host->set_associated_web_contents(web_contents); - + CHECK(fullscreen || browser); ExtensionDialog* dialog = new ExtensionDialog(host, observer); dialog->set_title(title); + if (fullscreen) - dialog->InitWindowFullscreen(browser); + dialog->InitWindowFullscreen(); else dialog->InitWindow(browser, width, height); @@ -110,36 +115,41 @@ ExtensionDialog* ExtensionDialog::ShowInternal(const GURL& url, // static ExtensionHost* ExtensionDialog::CreateExtensionHost(const GURL& url, - Browser* browser) { - ExtensionProcessManager* manager = - browser->profile()->GetExtensionProcessManager(); + Browser* browser, + Profile* profile) { + // Prefer picking the extension manager from the profile if given. + ExtensionProcessManager* manager = NULL; + if (profile) + manager = profile->GetExtensionProcessManager(); + else + manager = browser->profile()->GetExtensionProcessManager(); + DCHECK(manager); if (!manager) return NULL; - return manager->CreateDialogHost(url, browser); + if (browser) + return manager->CreateDialogHost(url, browser); + else + return manager->CreatePopupHost(url, NULL); } #if defined(USE_AURA) -void ExtensionDialog::InitWindowFullscreen(Browser* browser) { - gfx::NativeWindow parent = browser->window()->GetNativeHandle(); - - // Create the window as a child of the root window. - window_ = browser::CreateFramelessViewsWindow( - parent->GetRootWindow(), this); - // Make sure we're always on top by putting ourselves at the top - // of the z-order of the child windows of the root window. - parent->GetRootWindow()->StackChildAtTop(window_->GetNativeWindow()); - - int width = parent->GetRootWindow()->GetHostSize().width(); - int height = parent->GetRootWindow()->GetHostSize().height(); - window_->SetBounds(gfx::Rect(0, 0, width, height)); - +void ExtensionDialog::InitWindowFullscreen() { + aura::RootWindow* root_window = ash::Shell::GetRootWindow(); + gfx::Rect screen_rect = + gfx::Screen::GetMonitorAreaNearestWindow(root_window); + + // We want to be the fullscreen topmost child of the root window. + window_ = browser::CreateFramelessViewsWindow(root_window, this); + window_->StackAtTop(); + window_->SetBounds(screen_rect); window_->Show(); + // TODO(jamescook): Remove redundant call to Activate()? window_->Activate(); } #else -void ExtensionDialog::InitWindowFullscreen(Browser* browser) { +void ExtensionDialog::InitWindowFullscreen() { NOTIMPLEMENTED(); } #endif |