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

Side by Side Diff: apps/shell_window.cc

Issue 59043013: Add flag to enable immersive fullscreen for v2 apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "apps/shell_window.h" 5 #include "apps/shell_window.h"
6 6
7 #include "apps/shell_window_geometry_cache.h" 7 #include "apps/shell_window_geometry_cache.h"
8 #include "apps/shell_window_registry.h" 8 #include "apps/shell_window_registry.h"
9 #include "apps/ui/native_app_window.h" 9 #include "apps/ui/native_app_window.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 ShellWindow::ShellWindow(Profile* profile, 135 ShellWindow::ShellWindow(Profile* profile,
136 Delegate* delegate, 136 Delegate* delegate,
137 const extensions::Extension* extension) 137 const extensions::Extension* extension)
138 : profile_(profile), 138 : profile_(profile),
139 extension_(extension), 139 extension_(extension),
140 extension_id_(extension->id()), 140 extension_id_(extension->id()),
141 window_type_(WINDOW_TYPE_DEFAULT), 141 window_type_(WINDOW_TYPE_DEFAULT),
142 delegate_(delegate), 142 delegate_(delegate),
143 image_loader_ptr_factory_(this), 143 image_loader_ptr_factory_(this),
144 fullscreen_for_window_api_(false), 144 fullscreen_type_(FULLSCREEN_TYPE_NONE),
145 fullscreen_for_tab_(false),
146 show_on_first_paint_(false), 145 show_on_first_paint_(false),
147 first_paint_complete_(false) { 146 first_paint_complete_(false) {
148 } 147 }
149 148
150 void ShellWindow::Init(const GURL& url, 149 void ShellWindow::Init(const GURL& url,
151 ShellWindowContents* shell_window_contents, 150 ShellWindowContents* shell_window_contents,
152 const CreateParams& params) { 151 const CreateParams& params) {
153 // Initialize the render interface and web contents 152 // Initialize the render interface and web contents
154 shell_window_contents_.reset(shell_window_contents); 153 shell_window_contents_.reset(shell_window_contents);
155 shell_window_contents_->Initialize(profile(), url); 154 shell_window_contents_->Initialize(profile(), url);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 native_app_window_->UpdateWindowIcon(); 396 native_app_window_->UpdateWindowIcon();
398 ShellWindowRegistry::Get(profile_)->ShellWindowIconChanged(this); 397 ShellWindowRegistry::Get(profile_)->ShellWindowIconChanged(this);
399 } 398 }
400 399
401 void ShellWindow::Fullscreen() { 400 void ShellWindow::Fullscreen() {
402 #if !defined(OS_MACOSX) 401 #if !defined(OS_MACOSX)
403 // Do not enter fullscreen mode if disallowed by pref. 402 // Do not enter fullscreen mode if disallowed by pref.
404 if (!profile()->GetPrefs()->GetBoolean(prefs::kAppFullscreenAllowed)) 403 if (!profile()->GetPrefs()->GetBoolean(prefs::kAppFullscreenAllowed))
405 return; 404 return;
406 #endif 405 #endif
407 fullscreen_for_window_api_ = true; 406 bool tab_fullscreen =
408 GetBaseWindow()->SetFullscreen(true); 407 (fullscreen_type_ == FULLSCREEN_TYPE_TAB ||
408 fullscreen_type_ == FULLSCREEN_TYPE_WINDOW_AND_TAB);
409 fullscreen_type_ = tab_fullscreen ?
410 FULLSCREEN_TYPE_WINDOW_AND_TAB : FULLSCREEN_TYPE_WINDOW;
411 GetBaseWindow()->SetFullscreen(fullscreen_type_);
409 } 412 }
410 413
411 void ShellWindow::Maximize() { 414 void ShellWindow::Maximize() {
412 GetBaseWindow()->Maximize(); 415 GetBaseWindow()->Maximize();
413 } 416 }
414 417
415 void ShellWindow::Minimize() { 418 void ShellWindow::Minimize() {
416 GetBaseWindow()->Minimize(); 419 GetBaseWindow()->Minimize();
417 } 420 }
418 421
419 void ShellWindow::Restore() { 422 void ShellWindow::Restore() {
420 fullscreen_for_window_api_ = false; 423 if (fullscreen_type_ != FULLSCREEN_TYPE_NONE) {
421 fullscreen_for_tab_ = false; 424 fullscreen_type_ = FULLSCREEN_TYPE_NONE;
422 if (GetBaseWindow()->IsFullscreenOrPending()) { 425 GetBaseWindow()->SetFullscreen(FULLSCREEN_TYPE_NONE);
423 GetBaseWindow()->SetFullscreen(false);
424 } else { 426 } else {
425 GetBaseWindow()->Restore(); 427 GetBaseWindow()->Restore();
426 } 428 }
427 } 429 }
428 430
431 void ShellWindow::ImmersiveFullscreen() {
432 #if !defined(OS_MACOSX)
433 // Do not enter fullscreen mode if disallowed by pref.
434 if (!profile()->GetPrefs()->GetBoolean(prefs::kAppFullscreenAllowed))
435 return;
436 #endif
437 if (!GetBaseWindow()->SupportsImmersiveFullscreen())
438 return;
439 fullscreen_type_ = FULLSCREEN_TYPE_IMMERSIVE;
440 GetBaseWindow()->SetFullscreen(fullscreen_type_);
441 }
442
429 void ShellWindow::SetMinimumSize(const gfx::Size& min_size) { 443 void ShellWindow::SetMinimumSize(const gfx::Size& min_size) {
430 size_constraints_.set_minimum_size(min_size); 444 size_constraints_.set_minimum_size(min_size);
431 OnSizeConstraintsChanged(); 445 OnSizeConstraintsChanged();
432 } 446 }
433 447
434 void ShellWindow::SetMaximumSize(const gfx::Size& max_size) { 448 void ShellWindow::SetMaximumSize(const gfx::Size& max_size) {
435 size_constraints_.set_maximum_size(max_size); 449 size_constraints_.set_maximum_size(max_size);
436 OnSizeConstraintsChanged(); 450 OnSizeConstraintsChanged();
437 } 451 }
438 452
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 } 592 }
579 #endif 593 #endif
580 594
581 if (!IsExtensionWithPermissionOrSuggestInConsole( 595 if (!IsExtensionWithPermissionOrSuggestInConsole(
582 APIPermission::kFullscreen, 596 APIPermission::kFullscreen,
583 extension_, 597 extension_,
584 source->GetRenderViewHost())) { 598 source->GetRenderViewHost())) {
585 return; 599 return;
586 } 600 }
587 601
588 fullscreen_for_tab_ = enter_fullscreen; 602 bool window_fullscreen =
589 603 (fullscreen_type_ == FULLSCREEN_TYPE_WINDOW ||
604 fullscreen_type_ == FULLSCREEN_TYPE_WINDOW_AND_TAB);
590 if (enter_fullscreen) { 605 if (enter_fullscreen) {
591 native_app_window_->SetFullscreen(true); 606 fullscreen_type_ = window_fullscreen ?
592 } else if (!fullscreen_for_window_api_) { 607 FULLSCREEN_TYPE_WINDOW_AND_TAB : FULLSCREEN_TYPE_TAB;
593 native_app_window_->SetFullscreen(false); 608 } else {
609 fullscreen_type_ = window_fullscreen ?
610 FULLSCREEN_TYPE_WINDOW : FULLSCREEN_TYPE_NONE;
594 } 611 }
612 GetBaseWindow()->SetFullscreen(fullscreen_type_);
595 } 613 }
596 614
597 bool ShellWindow::IsFullscreenForTabOrPending( 615 bool ShellWindow::IsFullscreenForTabOrPending(
598 const content::WebContents* source) const { 616 const content::WebContents* source) const {
599 return fullscreen_for_tab_; 617 return (fullscreen_type_ == FULLSCREEN_TYPE_TAB ||
618 fullscreen_type_ == FULLSCREEN_TYPE_WINDOW_AND_TAB);
600 } 619 }
601 620
602 void ShellWindow::Observe(int type, 621 void ShellWindow::Observe(int type,
603 const content::NotificationSource& source, 622 const content::NotificationSource& source,
604 const content::NotificationDetails& details) { 623 const content::NotificationDetails& details) {
605 switch (type) { 624 switch (type) {
606 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { 625 case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
607 const extensions::Extension* unloaded_extension = 626 const extensions::Extension* unloaded_extension =
608 content::Details<extensions::UnloadedExtensionInfo>( 627 content::Details<extensions::UnloadedExtensionInfo>(
609 details)->extension; 628 details)->extension;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 region.bounds.x(), 768 region.bounds.x(),
750 region.bounds.y(), 769 region.bounds.y(),
751 region.bounds.right(), 770 region.bounds.right(),
752 region.bounds.bottom(), 771 region.bounds.bottom(),
753 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); 772 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
754 } 773 }
755 return sk_region; 774 return sk_region;
756 } 775 }
757 776
758 } // namespace apps 777 } // namespace apps
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698