summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/views/extensions/extension_dialog.cc
diff options
context:
space:
mode:
authorrkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-28 05:36:10 +0000
committerrkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-28 05:36:10 +0000
commite165130f2b6c70c9b0bf70d2e787ba9fb86e7655 (patch)
tree90ba0adbea96954b8b631781b9f1207a1e6cfc74 /chrome/browser/ui/views/extensions/extension_dialog.cc
parent508e5cd1ca85d1ab70e3456816120f8533dbafe1 (diff)
downloadchromium_src-e165130f2b6c70c9b0bf70d2e787ba9fb86e7655.zip
chromium_src-e165130f2b6c70c9b0bf70d2e787ba9fb86e7655.tar.gz
chromium_src-e165130f2b6c70c9b0bf70d2e787ba9fb86e7655.tar.bz2
Screensaver at login screen.
This CL adds code to show a screensaver on the login screen. The location of the screensaver and timeout for it to show up are currently hard coded but will be changed to pull from an enterprise policy once work on that end is completed. The screensaver stays active only on the login screen, if any user logs on, we de-activate the screensaver for the rest of the session. Since logout causes a Chrome restart, we will be active on the login screen again. If the screensaver crashes, we reload the extension and show ourselves again. R=sky@chromium.org,xiyuan@chromium.org,yoz@chromium.org BUG=chromium-os:26042 TEST=Tested that the screensaver comes up on the login screen, does not come up once we log in, reloads when I manually crash the screensaver extension process. Also verified that SelectFileDialog on ChromeOS works as intended. Review URL: http://codereview.chromium.org/9455038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123906 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/views/extensions/extension_dialog.cc')
-rw-r--r--chrome/browser/ui/views/extensions/extension_dialog.cc76
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