| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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_); |
| 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 fullscreen_type_ = FULLSCREEN_TYPE_IMMERSIVE; |
| 439 GetBaseWindow()->SetFullscreen(fullscreen_type_); |
| 440 } else { |
| 441 Fullscreen(); |
| 442 } |
| 443 } |
| 444 |
| 429 void ShellWindow::SetMinimumSize(const gfx::Size& min_size) { | 445 void ShellWindow::SetMinimumSize(const gfx::Size& min_size) { |
| 430 size_constraints_.set_minimum_size(min_size); | 446 size_constraints_.set_minimum_size(min_size); |
| 431 OnSizeConstraintsChanged(); | 447 OnSizeConstraintsChanged(); |
| 432 } | 448 } |
| 433 | 449 |
| 434 void ShellWindow::SetMaximumSize(const gfx::Size& max_size) { | 450 void ShellWindow::SetMaximumSize(const gfx::Size& max_size) { |
| 435 size_constraints_.set_maximum_size(max_size); | 451 size_constraints_.set_maximum_size(max_size); |
| 436 OnSizeConstraintsChanged(); | 452 OnSizeConstraintsChanged(); |
| 437 } | 453 } |
| 438 | 454 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 } | 594 } |
| 579 #endif | 595 #endif |
| 580 | 596 |
| 581 if (!IsExtensionWithPermissionOrSuggestInConsole( | 597 if (!IsExtensionWithPermissionOrSuggestInConsole( |
| 582 APIPermission::kFullscreen, | 598 APIPermission::kFullscreen, |
| 583 extension_, | 599 extension_, |
| 584 source->GetRenderViewHost())) { | 600 source->GetRenderViewHost())) { |
| 585 return; | 601 return; |
| 586 } | 602 } |
| 587 | 603 |
| 588 fullscreen_for_tab_ = enter_fullscreen; | 604 bool window_fullscreen = |
| 589 | 605 (fullscreen_type_ == FULLSCREEN_TYPE_WINDOW || |
| 606 fullscreen_type_ == FULLSCREEN_TYPE_WINDOW_AND_TAB); |
| 590 if (enter_fullscreen) { | 607 if (enter_fullscreen) { |
| 591 native_app_window_->SetFullscreen(true); | 608 fullscreen_type_ = window_fullscreen ? |
| 592 } else if (!fullscreen_for_window_api_) { | 609 FULLSCREEN_TYPE_WINDOW_AND_TAB : FULLSCREEN_TYPE_TAB; |
| 593 native_app_window_->SetFullscreen(false); | 610 } else { |
| 611 fullscreen_type_ = window_fullscreen ? |
| 612 FULLSCREEN_TYPE_WINDOW : FULLSCREEN_TYPE_NONE; |
| 594 } | 613 } |
| 614 GetBaseWindow()->SetFullscreen(fullscreen_type_); |
| 595 } | 615 } |
| 596 | 616 |
| 597 bool ShellWindow::IsFullscreenForTabOrPending( | 617 bool ShellWindow::IsFullscreenForTabOrPending( |
| 598 const content::WebContents* source) const { | 618 const content::WebContents* source) const { |
| 599 return fullscreen_for_tab_; | 619 return (fullscreen_type_ == FULLSCREEN_TYPE_TAB || |
| 620 fullscreen_type_ == FULLSCREEN_TYPE_WINDOW_AND_TAB); |
| 600 } | 621 } |
| 601 | 622 |
| 602 void ShellWindow::Observe(int type, | 623 void ShellWindow::Observe(int type, |
| 603 const content::NotificationSource& source, | 624 const content::NotificationSource& source, |
| 604 const content::NotificationDetails& details) { | 625 const content::NotificationDetails& details) { |
| 605 switch (type) { | 626 switch (type) { |
| 606 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 627 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { |
| 607 const extensions::Extension* unloaded_extension = | 628 const extensions::Extension* unloaded_extension = |
| 608 content::Details<extensions::UnloadedExtensionInfo>( | 629 content::Details<extensions::UnloadedExtensionInfo>( |
| 609 details)->extension; | 630 details)->extension; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 region.bounds.x(), | 770 region.bounds.x(), |
| 750 region.bounds.y(), | 771 region.bounds.y(), |
| 751 region.bounds.right(), | 772 region.bounds.right(), |
| 752 region.bounds.bottom(), | 773 region.bounds.bottom(), |
| 753 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 774 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 754 } | 775 } |
| 755 return sk_region; | 776 return sk_region; |
| 756 } | 777 } |
| 757 | 778 |
| 758 } // namespace apps | 779 } // namespace apps |
| OLD | NEW |