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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 // to allow it to survive the trip without being hosted. 1462 // to allow it to survive the trip without being hosted.
1463 base::mac::NSObjectRetain(widget_view->GetNativeView()); 1463 base::mac::NSObjectRetain(widget_view->GetNativeView());
1464 #endif 1464 #endif
1465 } 1465 }
1466 1466
1467 void WebContentsImpl::ShowCreatedWindow(int route_id, 1467 void WebContentsImpl::ShowCreatedWindow(int route_id,
1468 WindowOpenDisposition disposition, 1468 WindowOpenDisposition disposition,
1469 const gfx::Rect& initial_pos, 1469 const gfx::Rect& initial_pos,
1470 bool user_gesture) { 1470 bool user_gesture) {
1471 WebContentsImpl* contents = GetCreatedWindow(route_id); 1471 WebContentsImpl* contents = GetCreatedWindow(route_id);
1472
1473 gfx::Rect newContentsWindowPos = initial_pos;
1474 if (disposition == PRESENTATION_WINDOW) {
1475 gfx::Screen* screen = gfx::Screen::GetNativeScreen();
1476 gfx::Rect windowBounds;
1477 WebContentsView* view = GetView();
1478 CHECK(view);
1479 view->GetContainerBounds(&windowBounds);
1480 gfx::Display thisDisplay = screen->GetDisplayMatching(windowBounds);
1481
1482 std::vector<gfx::Display> displays = screen->GetAllDisplays();
1483 gfx::Display presentationDisplay;
1484 // TODO: Instead of just finding the next different display,
1485 // enable a screen selection here.
1486 for (std::vector<gfx::Display>::iterator it = displays.begin();
1487 it != displays.end();
1488 ++it) {
1489 if ((*it).id() != thisDisplay.id())
1490 presentationDisplay = *it;
1491 }
1492 if (presentationDisplay.is_valid()) {
1493 newContentsWindowPos = presentationDisplay.work_area();
1494 newContentsWindowPos.Inset(200, 200);
1495 }
1496 }
1497
1472 if (contents) { 1498 if (contents) {
1473 WebContentsDelegate* delegate = GetDelegate(); 1499 WebContentsDelegate* delegate = GetDelegate();
1474 if (delegate) { 1500 if (delegate) {
1475 delegate->AddNewContents( 1501 delegate->AddNewContents(this,
1476 this, contents, disposition, initial_pos, user_gesture, NULL); 1502 contents,
1503 disposition,
1504 newContentsWindowPos,
1505 user_gesture,
1506 NULL);
1477 } 1507 }
1478 } 1508 }
1479 } 1509 }
1480 1510
1481 void WebContentsImpl::ShowCreatedWidget(int route_id, 1511 void WebContentsImpl::ShowCreatedWidget(int route_id,
1482 const gfx::Rect& initial_pos) { 1512 const gfx::Rect& initial_pos) {
1483 ShowCreatedWidget(route_id, false, initial_pos); 1513 ShowCreatedWidget(route_id, false, initial_pos);
1484 } 1514 }
1485 1515
1486 void WebContentsImpl::ShowCreatedFullscreenWidget(int route_id) { 1516 void WebContentsImpl::ShowCreatedFullscreenWidget(int route_id) {
(...skipping 2272 matching lines...) Expand 10 before | Expand all | Expand 10 after
3759 } 3789 }
3760 3790
3761 void WebContentsImpl::OnFrameRemoved( 3791 void WebContentsImpl::OnFrameRemoved(
3762 RenderViewHostImpl* render_view_host, 3792 RenderViewHostImpl* render_view_host,
3763 int64 frame_id) { 3793 int64 frame_id) {
3764 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3794 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3765 FrameDetached(render_view_host, frame_id)); 3795 FrameDetached(render_view_host, frame_id));
3766 } 3796 }
3767 3797
3768 } // namespace content 3798 } // namespace content
OLDNEW
« 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