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

Unified Diff: chrome/browser/ui/views/extensions/extension_dialog.cc

Issue 10584026: Allow ChromeOS file selection dialog to be shown from shell windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tidy up Created 8 years, 6 months 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/views/extensions/extension_dialog.cc
diff --git a/chrome/browser/ui/views/extensions/extension_dialog.cc b/chrome/browser/ui/views/extensions/extension_dialog.cc
index e9f9f032d3ae88e05a97517fcff5297567b2b48b..d70e747bd92054652871337b9ac4f7c903db634e 100644
--- a/chrome/browser/ui/views/extensions/extension_dialog.cc
+++ b/chrome/browser/ui/views/extensions/extension_dialog.cc
@@ -7,8 +7,7 @@
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/base_window.h"
#include "chrome/browser/ui/views/extensions/extension_dialog_observer.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/notification_details.h"
@@ -51,18 +50,19 @@ ExtensionDialog::~ExtensionDialog() {
// static
ExtensionDialog* ExtensionDialog::Show(
const GURL& url,
- Browser* browser,
+ BaseWindow* base_window,
+ Profile* profile,
WebContents* web_contents,
int width,
int height,
const string16& title,
ExtensionDialogObserver* observer) {
- ExtensionHost* host = CreateExtensionHost(url, browser, NULL);
+ ExtensionHost* host = CreateExtensionHost(url, profile);
if (!host)
return NULL;
host->SetAssociatedWebContents(web_contents);
- return ExtensionDialog::ShowInternal(url, browser, host, width, height,
+ return ExtensionDialog::ShowInternal(url, base_window, host, width, height,
false, title, observer);
}
@@ -73,7 +73,7 @@ ExtensionDialog* ExtensionDialog::ShowFullscreen(
Profile* profile,
const string16& title,
ExtensionDialogObserver* observer) {
- ExtensionHost* host = CreateExtensionHost(url, NULL, profile);
+ ExtensionHost* host = CreateExtensionHost(url, profile);
if (!host)
return NULL;
@@ -84,21 +84,21 @@ ExtensionDialog* ExtensionDialog::ShowFullscreen(
// static
ExtensionDialog* ExtensionDialog::ShowInternal(const GURL& url,
- Browser* browser,
+ BaseWindow* base_window,
ExtensionHost* host,
int width,
int height,
bool fullscreen,
const string16& title,
ExtensionDialogObserver* observer) {
- CHECK(fullscreen || browser);
+ CHECK(fullscreen || base_window);
ExtensionDialog* dialog = new ExtensionDialog(host, observer);
dialog->set_title(title);
if (fullscreen)
dialog->InitWindowFullscreen();
else
- dialog->InitWindow(browser, width, height);
+ dialog->InitWindow(base_window, width, height);
// Show a white background while the extension loads. This is prettier than
// flashing a black unfilled window frame.
@@ -113,19 +113,14 @@ ExtensionDialog* ExtensionDialog::ShowInternal(const GURL& url,
// static
ExtensionHost* ExtensionDialog::CreateExtensionHost(const GURL& url,
- 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(profile);
+ ExtensionProcessManager* manager = profile->GetExtensionProcessManager();
DCHECK(manager);
if (!manager)
return NULL;
- return manager->CreateDialogHost(url, browser);
+ return manager->CreateDialogHost(url);
}
#if defined(USE_AURA)
@@ -155,14 +150,25 @@ void ExtensionDialog::InitWindowFullscreen() {
#endif
-void ExtensionDialog::InitWindow(Browser* browser, int width, int height) {
- gfx::NativeWindow parent = browser->window()->GetNativeWindow();
+void ExtensionDialog::InitWindow(BaseWindow* base_window,
+ int width,
+ int height) {
+ gfx::NativeWindow parent = base_window->GetNativeWindow();
window_ = views::Widget::CreateWindowWithParent(this, parent);
// Center the window over the browser.
- gfx::Point center = browser->window()->GetBounds().CenterPoint();
+ gfx::Point center = base_window->GetBounds().CenterPoint();
int x = center.x() - width / 2;
int y = center.y() - height / 2;
+ // Ensure the top left and top right of the window are on screen, with
+ // priority given to the top left.
+ gfx::Rect screen_rect = gfx::Screen::GetDisplayNearestPoint(center).bounds();
+ if (y < screen_rect.y())
sky 2012/06/25 14:23:15 Replace all this with AdjustToFit
benwells 2012/06/25 17:52:59 Done.
+ y = screen_rect.y();
+ if (x + width > screen_rect.right())
+ x = screen_rect.right() - width;
+ if (x < screen_rect.x())
+ x = screen_rect.x();
window_->SetBounds(gfx::Rect(x, y, width, height));
window_->Show();
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_dialog.h ('k') | chrome/browser/ui/views/select_file_dialog_extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698