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

Unified Diff: chrome/browser/ui/extensions/shell_window.cc

Issue 13609003: fullscreen in apps v2 ShellWindow via app.window.create. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 7 years, 8 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/extensions/shell_window.cc
diff --git a/chrome/browser/ui/extensions/shell_window.cc b/chrome/browser/ui/extensions/shell_window.cc
index 2b521eeab8ab5d16927f7318ec53b9656f663b42..8312f0ff62c2c5cdca85dccf475f245f184a9c48 100644
--- a/chrome/browser/ui/extensions/shell_window.cc
+++ b/chrome/browser/ui/extensions/shell_window.cc
@@ -73,7 +73,11 @@ ShellWindow::CreateParams::CreateParams()
frame(ShellWindow::FRAME_CHROME),
transparent_background(false),
bounds(INT_MIN, INT_MIN, 0, 0),
- creator_process_id(0), hidden(false), resizable(true), focused(true) {
+ creator_process_id(0),
+ state(STATE_NORMAL),
+ hidden(false),
+ resizable(true),
+ focused(true) {
}
ShellWindow::CreateParams::~CreateParams() {
@@ -95,7 +99,9 @@ ShellWindow::ShellWindow(Profile* profile,
: profile_(profile),
extension_(extension),
window_type_(WINDOW_TYPE_DEFAULT),
- ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_ptr_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_ptr_factory_(this)),
+ fullscreen_for_window_api_(false),
+ fullscreen_for_tab_(false) {
}
void ShellWindow::Init(const GURL& url,
@@ -163,6 +169,20 @@ void ShellWindow::Init(const GURL& url,
native_app_window_.reset(NativeAppWindow::Create(this, new_params));
OnNativeWindowChanged();
+ switch (params.state) {
+ case CreateParams::STATE_NORMAL:
+ break;
+ case CreateParams::STATE_FULLSCREEN:
+ Fullscreen();
+ break;
+ case CreateParams::STATE_MAXIMIZED:
+ Maximize();
+ break;
+ case CreateParams::STATE_MINIMIZED:
+ Minimize();
+ break;
+ }
+
if (!params.hidden) {
if (window_type_is_panel())
GetBaseWindow()->ShowInactive(); // Panels are not activated by default.
@@ -380,6 +400,29 @@ void ShellWindow::UpdateAppIcon(const gfx::Image& image) {
extensions::ShellWindowRegistry::Get(profile_)->ShellWindowIconChanged(this);
}
+void ShellWindow::Fullscreen() {
+ fullscreen_for_window_api_ = true;
+ GetBaseWindow()->SetFullscreen(true);
+}
+
+void ShellWindow::Maximize() {
+ GetBaseWindow()->Maximize();
+}
+
+void ShellWindow::Minimize() {
+ GetBaseWindow()->Minimize();
+}
+
+void ShellWindow::Restore() {
+ fullscreen_for_window_api_ = false;
+ fullscreen_for_tab_ = false;
+ if (GetBaseWindow()->IsFullscreenOrPending()) {
+ GetBaseWindow()->SetFullscreen(false);
+ } else {
+ GetBaseWindow()->Restore();
+ }
+}
+
//------------------------------------------------------------------------------
// Private methods
@@ -453,18 +496,25 @@ void ShellWindow::NavigationStateChanged(
void ShellWindow::ToggleFullscreenModeForTab(content::WebContents* source,
bool enter_fullscreen) {
- bool has_permission = IsExtensionWithPermissionOrSuggestInConsole(
+ if (!IsExtensionWithPermissionOrSuggestInConsole(
APIPermission::kFullscreen,
extension_,
- source->GetRenderViewHost());
+ source->GetRenderViewHost())) {
+ return;
+ }
- if (has_permission)
- native_app_window_->SetFullscreen(enter_fullscreen);
+ fullscreen_for_tab_ = enter_fullscreen;
+
+ if (enter_fullscreen) {
+ native_app_window_->SetFullscreen(true);
+ } else if (!fullscreen_for_window_api_) {
+ native_app_window_->SetFullscreen(false);
+ }
}
bool ShellWindow::IsFullscreenForTabOrPending(
const content::WebContents* source) const {
- return native_app_window_->IsFullscreenOrPending();
+ return fullscreen_for_tab_;
}
void ShellWindow::Observe(int type,
« no previous file with comments | « chrome/browser/ui/extensions/shell_window.h ('k') | chrome/common/extensions/api/app_current_window_internal.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698