| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/app_window/app_window.h" | 5 #include "extensions/browser/app_window/app_window.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 WebContentsModalDialogManager* modal_dialog_manager = | 447 WebContentsModalDialogManager* modal_dialog_manager = |
| 448 WebContentsModalDialogManager::FromWebContents(web_contents()); | 448 WebContentsModalDialogManager::FromWebContents(web_contents()); |
| 449 if (modal_dialog_manager) // May be null in unit tests. | 449 if (modal_dialog_manager) // May be null in unit tests. |
| 450 modal_dialog_manager->SetDelegate(nullptr); | 450 modal_dialog_manager->SetDelegate(nullptr); |
| 451 app_window_contents_->NativeWindowClosed(); | 451 app_window_contents_->NativeWindowClosed(); |
| 452 } | 452 } |
| 453 delete this; | 453 delete this; |
| 454 } | 454 } |
| 455 | 455 |
| 456 void AppWindow::OnNativeWindowChanged() { | 456 void AppWindow::OnNativeWindowChanged() { |
| 457 // This may be called during Init before |native_app_window_| is set. |
| 458 if (!native_app_window_) |
| 459 return; |
| 460 |
| 461 #if defined(OS_MACOSX) |
| 462 // On Mac the user can change the window's fullscreen state. If that has |
| 463 // happened, update AppWindow's internal state. |
| 464 if (native_app_window_->IsFullscreen()) { |
| 465 if (!IsFullscreen()) |
| 466 fullscreen_types_ = FULLSCREEN_TYPE_OS; |
| 467 } else { |
| 468 fullscreen_types_ = FULLSCREEN_TYPE_NONE; |
| 469 } |
| 470 |
| 471 if (cached_always_on_top_) |
| 472 UpdateNativeAlwaysOnTop(); // Same as in SetNativeWindowFullscreen. |
| 473 #endif |
| 474 |
| 457 SaveWindowPosition(); | 475 SaveWindowPosition(); |
| 458 | 476 |
| 459 #if defined(OS_WIN) | 477 #if defined(OS_WIN) |
| 460 if (native_app_window_ && cached_always_on_top_ && !IsFullscreen() && | 478 if (cached_always_on_top_ && !IsFullscreen() && |
| 461 !native_app_window_->IsMaximized() && | 479 !native_app_window_->IsMaximized() && |
| 462 !native_app_window_->IsMinimized()) { | 480 !native_app_window_->IsMinimized()) { |
| 463 UpdateNativeAlwaysOnTop(); | 481 UpdateNativeAlwaysOnTop(); |
| 464 } | 482 } |
| 465 #endif | 483 #endif |
| 466 | 484 |
| 467 if (app_window_contents_ && native_app_window_) | 485 if (app_window_contents_) |
| 468 app_window_contents_->NativeWindowChanged(native_app_window_.get()); | 486 app_window_contents_->NativeWindowChanged(native_app_window_.get()); |
| 469 } | 487 } |
| 470 | 488 |
| 471 void AppWindow::OnNativeWindowActivated() { | 489 void AppWindow::OnNativeWindowActivated() { |
| 472 AppWindowRegistry::Get(browser_context_)->AppWindowActivated(this); | 490 AppWindowRegistry::Get(browser_context_)->AppWindowActivated(this); |
| 473 } | 491 } |
| 474 | 492 |
| 475 content::WebContents* AppWindow::web_contents() const { | 493 content::WebContents* AppWindow::web_contents() const { |
| 476 return app_window_contents_->GetWebContents(); | 494 return app_window_contents_->GetWebContents(); |
| 477 } | 495 } |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 | 963 |
| 946 bool AppWindow::IsWebContentsVisible(content::WebContents* web_contents) { | 964 bool AppWindow::IsWebContentsVisible(content::WebContents* web_contents) { |
| 947 return app_delegate_->IsWebContentsVisible(web_contents); | 965 return app_delegate_->IsWebContentsVisible(web_contents); |
| 948 } | 966 } |
| 949 | 967 |
| 950 WebContentsModalDialogHost* AppWindow::GetWebContentsModalDialogHost() { | 968 WebContentsModalDialogHost* AppWindow::GetWebContentsModalDialogHost() { |
| 951 return native_app_window_.get(); | 969 return native_app_window_.get(); |
| 952 } | 970 } |
| 953 | 971 |
| 954 void AppWindow::SaveWindowPosition() { | 972 void AppWindow::SaveWindowPosition() { |
| 973 DCHECK(native_app_window_); |
| 955 if (window_key_.empty()) | 974 if (window_key_.empty()) |
| 956 return; | 975 return; |
| 957 if (!native_app_window_) | |
| 958 return; | |
| 959 | 976 |
| 960 AppWindowGeometryCache* cache = | 977 AppWindowGeometryCache* cache = |
| 961 AppWindowGeometryCache::Get(browser_context()); | 978 AppWindowGeometryCache::Get(browser_context()); |
| 962 | 979 |
| 963 gfx::Rect bounds = native_app_window_->GetRestoredBounds(); | 980 gfx::Rect bounds = native_app_window_->GetRestoredBounds(); |
| 964 gfx::Rect screen_bounds = | 981 gfx::Rect screen_bounds = |
| 965 gfx::Screen::GetNativeScreen()->GetDisplayMatching(bounds).work_area(); | 982 gfx::Screen::GetNativeScreen()->GetDisplayMatching(bounds).work_area(); |
| 966 ui::WindowShowState window_state = native_app_window_->GetRestoredState(); | 983 ui::WindowShowState window_state = native_app_window_->GetRestoredState(); |
| 967 cache->SaveGeometry( | 984 cache->SaveGeometry( |
| 968 extension_id(), window_key_, bounds, screen_bounds, window_state); | 985 extension_id(), window_key_, bounds, screen_bounds, window_state); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 region.bounds.x(), | 1078 region.bounds.x(), |
| 1062 region.bounds.y(), | 1079 region.bounds.y(), |
| 1063 region.bounds.right(), | 1080 region.bounds.right(), |
| 1064 region.bounds.bottom(), | 1081 region.bounds.bottom(), |
| 1065 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 1082 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 1066 } | 1083 } |
| 1067 return sk_region; | 1084 return sk_region; |
| 1068 } | 1085 } |
| 1069 | 1086 |
| 1070 } // namespace extensions | 1087 } // namespace extensions |
| OLD | NEW |