Chromium Code Reviews| 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_types_(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 fullscreen_types_ |= FULLSCREEN_TYPE_WINDOW_API; |
| 408 GetBaseWindow()->SetFullscreen(true); | 407 GetBaseWindow()->SetFullscreen(fullscreen_types_); |
| 409 } | 408 } |
| 410 | 409 |
| 411 void ShellWindow::Maximize() { | 410 void ShellWindow::Maximize() { |
| 412 GetBaseWindow()->Maximize(); | 411 GetBaseWindow()->Maximize(); |
| 413 } | 412 } |
| 414 | 413 |
| 415 void ShellWindow::Minimize() { | 414 void ShellWindow::Minimize() { |
| 416 GetBaseWindow()->Minimize(); | 415 GetBaseWindow()->Minimize(); |
| 417 } | 416 } |
| 418 | 417 |
| 419 void ShellWindow::Restore() { | 418 void ShellWindow::Restore() { |
| 420 fullscreen_for_window_api_ = false; | 419 if (fullscreen_types_ != FULLSCREEN_TYPE_NONE) { |
| 421 fullscreen_for_tab_ = false; | 420 fullscreen_types_ = FULLSCREEN_TYPE_NONE; |
|
benwells
2013/11/14 00:06:54
Is there a logical change here? It was checking Is
pkotwicz
2013/11/14 01:05:24
This is not a logical change as far as I can tell.
| |
| 422 if (GetBaseWindow()->IsFullscreenOrPending()) { | 421 GetBaseWindow()->SetFullscreen(fullscreen_types_); |
| 423 GetBaseWindow()->SetFullscreen(false); | |
| 424 } else { | 422 } else { |
| 425 GetBaseWindow()->Restore(); | 423 GetBaseWindow()->Restore(); |
| 426 } | 424 } |
| 427 } | 425 } |
| 428 | 426 |
| 427 void ShellWindow::OSFullscreen() { | |
| 428 #if !defined(OS_MACOSX) | |
| 429 // Do not enter fullscreen mode if disallowed by pref. | |
| 430 if (!profile()->GetPrefs()->GetBoolean(prefs::kAppFullscreenAllowed)) | |
| 431 return; | |
| 432 #endif | |
| 433 fullscreen_types_ |= FULLSCREEN_TYPE_OS; | |
| 434 GetBaseWindow()->SetFullscreen(fullscreen_types_); | |
| 435 } | |
| 436 | |
| 429 void ShellWindow::SetMinimumSize(const gfx::Size& min_size) { | 437 void ShellWindow::SetMinimumSize(const gfx::Size& min_size) { |
| 430 size_constraints_.set_minimum_size(min_size); | 438 size_constraints_.set_minimum_size(min_size); |
| 431 OnSizeConstraintsChanged(); | 439 OnSizeConstraintsChanged(); |
| 432 } | 440 } |
| 433 | 441 |
| 434 void ShellWindow::SetMaximumSize(const gfx::Size& max_size) { | 442 void ShellWindow::SetMaximumSize(const gfx::Size& max_size) { |
| 435 size_constraints_.set_maximum_size(max_size); | 443 size_constraints_.set_maximum_size(max_size); |
| 436 OnSizeConstraintsChanged(); | 444 OnSizeConstraintsChanged(); |
| 437 } | 445 } |
| 438 | 446 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 } | 586 } |
| 579 #endif | 587 #endif |
| 580 | 588 |
| 581 if (!IsExtensionWithPermissionOrSuggestInConsole( | 589 if (!IsExtensionWithPermissionOrSuggestInConsole( |
| 582 APIPermission::kFullscreen, | 590 APIPermission::kFullscreen, |
| 583 extension_, | 591 extension_, |
| 584 source->GetRenderViewHost())) { | 592 source->GetRenderViewHost())) { |
| 585 return; | 593 return; |
| 586 } | 594 } |
| 587 | 595 |
| 588 fullscreen_for_tab_ = enter_fullscreen; | 596 if (enter_fullscreen) |
| 589 | 597 fullscreen_types_ |= FULLSCREEN_TYPE_HTML_API; |
| 590 if (enter_fullscreen) { | 598 else |
| 591 native_app_window_->SetFullscreen(true); | 599 fullscreen_types_ ^= FULLSCREEN_TYPE_HTML_API; |
| 592 } else if (!fullscreen_for_window_api_) { | 600 GetBaseWindow()->SetFullscreen(fullscreen_types_); |
| 593 native_app_window_->SetFullscreen(false); | |
| 594 } | |
| 595 } | 601 } |
| 596 | 602 |
| 597 bool ShellWindow::IsFullscreenForTabOrPending( | 603 bool ShellWindow::IsFullscreenForTabOrPending( |
| 598 const content::WebContents* source) const { | 604 const content::WebContents* source) const { |
| 599 return fullscreen_for_tab_; | 605 return (fullscreen_types_ & FULLSCREEN_TYPE_HTML_API); |
| 600 } | 606 } |
| 601 | 607 |
| 602 void ShellWindow::Observe(int type, | 608 void ShellWindow::Observe(int type, |
| 603 const content::NotificationSource& source, | 609 const content::NotificationSource& source, |
| 604 const content::NotificationDetails& details) { | 610 const content::NotificationDetails& details) { |
| 605 switch (type) { | 611 switch (type) { |
| 606 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 612 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { |
| 607 const extensions::Extension* unloaded_extension = | 613 const extensions::Extension* unloaded_extension = |
| 608 content::Details<extensions::UnloadedExtensionInfo>( | 614 content::Details<extensions::UnloadedExtensionInfo>( |
| 609 details)->extension; | 615 details)->extension; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 749 region.bounds.x(), | 755 region.bounds.x(), |
| 750 region.bounds.y(), | 756 region.bounds.y(), |
| 751 region.bounds.right(), | 757 region.bounds.right(), |
| 752 region.bounds.bottom(), | 758 region.bounds.bottom(), |
| 753 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 759 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 754 } | 760 } |
| 755 return sk_region; | 761 return sk_region; |
| 756 } | 762 } |
| 757 | 763 |
| 758 } // namespace apps | 764 } // namespace apps |
| OLD | NEW |