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

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 98523003: Implement "presentation" feature for window.open() Base URL: https://github.com/drott/cameo.git@presentationWindowSquashed
Patch Set: Created 7 years 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: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index d9ac63172636991e1e6bc750d49ea34d9cf6129a..2e248c6993e3bf67a733e60c122d32d1d8d066ae 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1469,11 +1469,41 @@ void WebContentsImpl::ShowCreatedWindow(int route_id,
const gfx::Rect& initial_pos,
bool user_gesture) {
WebContentsImpl* contents = GetCreatedWindow(route_id);
+
+ gfx::Rect newContentsWindowPos = initial_pos;
+ if (disposition == PRESENTATION_WINDOW) {
+ gfx::Screen* screen = gfx::Screen::GetNativeScreen();
+ gfx::Rect windowBounds;
+ WebContentsView* view = GetView();
+ CHECK(view);
+ view->GetContainerBounds(&windowBounds);
+ gfx::Display thisDisplay = screen->GetDisplayMatching(windowBounds);
+
+ std::vector<gfx::Display> displays = screen->GetAllDisplays();
+ gfx::Display presentationDisplay;
+ // TODO: Instead of just finding the next different display,
+ // enable a screen selection here.
+ for (std::vector<gfx::Display>::iterator it = displays.begin();
+ it != displays.end();
+ ++it) {
+ if ((*it).id() != thisDisplay.id())
+ presentationDisplay = *it;
+ }
+ if (presentationDisplay.is_valid()) {
+ newContentsWindowPos = presentationDisplay.work_area();
+ newContentsWindowPos.Inset(200, 200);
+ }
+ }
+
if (contents) {
WebContentsDelegate* delegate = GetDelegate();
if (delegate) {
- delegate->AddNewContents(
- this, contents, disposition, initial_pos, user_gesture, NULL);
+ delegate->AddNewContents(this,
+ contents,
+ disposition,
+ newContentsWindowPos,
+ user_gesture,
+ NULL);
}
}
}
« no previous file with comments | « chrome/browser/ui/fullscreen/fullscreen_exit_bubble_type.cc ('k') | content/public/browser/web_contents_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698