Skip to content

Commit

Permalink
nw2: support fullscreen in new-win-policy
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerwang committed Nov 18, 2019
1 parent 5ac1df9 commit 38ca557
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions chrome/browser/ui/browser_navigator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include <string>
#include <utility>

#include "chrome/browser/ui/views/frame/browser_frame.h"
#include "chrome/browser/ui/views/frame/browser_view.h"

#include "base/command_line.h"
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
Expand Down Expand Up @@ -392,6 +395,11 @@ class ScopedBrowserShower {
(*contents_)->Focus();
window->Activate();
}
} else if (params_->window_action == NavigateParams::SHOW_WINDOW_FULLSCREEN) {
BrowserWindow* window = params_->browser->window();
BrowserFrame* frame = BrowserView::GetBrowserViewForBrowser(params_->browser)->frame();
frame->SetFullscreen(true);
window->Show();
}
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/browser_navigator_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ struct NavigateParams {
SHOW_WINDOW,
// Show the browser window after navigating but do not activate.
SHOW_WINDOW_INACTIVE,
SHOW_FULLSCREEN
SHOW_WINDOW_FULLSCREEN
};
// Default is NO_ACTION (don't show or activate the window).
// If disposition is NEW_WINDOW or NEW_POPUP, and |window_action| is set to
Expand Down
4 changes: 3 additions & 1 deletion chrome/browser/ui/browser_tabstrip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ void AddWebContents(Browser* browser,
int height = 0; int width = 0;
int x = 0; int y = 0;
bool has_frame = true;
bool fullscreen = false;
if (!manifest.empty()) {
std::unique_ptr<base::Value> val = base::JSONReader().ReadToValueDeprecated(manifest);
if (val && val->is_dict()) {
Expand All @@ -79,13 +80,14 @@ void AddWebContents(Browser* browser,
if (mnfst->GetInteger("y", &y))
rect.set_y(y);
mnfst->GetBoolean("frame", &has_frame);
mnfst->GetBoolean("fullscreen", &fullscreen);
}
}
NavigateParams params(browser, std::move(new_contents));
params.source_contents = source_contents;
params.disposition = disposition;
params.window_bounds = rect;
params.window_action = NavigateParams::SHOW_WINDOW;
params.window_action = fullscreen ? NavigateParams::SHOW_WINDOW_FULLSCREEN : NavigateParams::SHOW_WINDOW;
params.frameless = !has_frame;
// At this point, we're already beyond the popup blocker. Even if the popup
// was created without a user gesture, we have to set |user_gesture| to true,
Expand Down

0 comments on commit 38ca557

Please sign in to comment.