Chromium Code Reviews| 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 "apps/app_window.h" | 5 #include "apps/app_window.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "apps/app_window_geometry_cache.h" | 9 #include "apps/app_window_geometry_cache.h" |
| 10 #include "apps/app_window_registry.h" | 10 #include "apps/app_window_registry.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 extension_id_(extension->id()), | 238 extension_id_(extension->id()), |
| 239 window_type_(WINDOW_TYPE_DEFAULT), | 239 window_type_(WINDOW_TYPE_DEFAULT), |
| 240 delegate_(delegate), | 240 delegate_(delegate), |
| 241 image_loader_ptr_factory_(this), | 241 image_loader_ptr_factory_(this), |
| 242 fullscreen_types_(FULLSCREEN_TYPE_NONE), | 242 fullscreen_types_(FULLSCREEN_TYPE_NONE), |
| 243 show_on_first_paint_(false), | 243 show_on_first_paint_(false), |
| 244 first_paint_complete_(false), | 244 first_paint_complete_(false), |
| 245 has_been_shown_(false), | 245 has_been_shown_(false), |
| 246 can_send_events_(false), | 246 can_send_events_(false), |
| 247 is_hidden_(false), | 247 is_hidden_(false), |
| 248 cached_always_on_top_(false) { | 248 cached_always_on_top_(false), |
| 249 cached_want_all_keys_(false) { | |
| 249 extensions::ExtensionsBrowserClient* client = | 250 extensions::ExtensionsBrowserClient* client = |
| 250 extensions::ExtensionsBrowserClient::Get(); | 251 extensions::ExtensionsBrowserClient::Get(); |
| 251 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord()) | 252 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord()) |
| 252 << "Only off the record window may be opened in the guest mode."; | 253 << "Only off the record window may be opened in the guest mode."; |
| 253 } | 254 } |
| 254 | 255 |
| 255 void AppWindow::Init(const GURL& url, | 256 void AppWindow::Init(const GURL& url, |
| 256 AppWindowContents* app_window_contents, | 257 AppWindowContents* app_window_contents, |
| 257 const CreateParams& params) { | 258 const CreateParams& params) { |
| 258 // Initialize the render interface and web contents | 259 // Initialize the render interface and web contents |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 507 SaveWindowPosition(); | 508 SaveWindowPosition(); |
| 508 | 509 |
| 509 #if defined(OS_WIN) | 510 #if defined(OS_WIN) |
| 510 if (native_app_window_ && cached_always_on_top_ && | 511 if (native_app_window_ && cached_always_on_top_ && |
| 511 !IsFullscreen(fullscreen_types_) && !native_app_window_->IsMaximized() && | 512 !IsFullscreen(fullscreen_types_) && !native_app_window_->IsMaximized() && |
| 512 !native_app_window_->IsMinimized()) { | 513 !native_app_window_->IsMinimized()) { |
| 513 UpdateNativeAlwaysOnTop(); | 514 UpdateNativeAlwaysOnTop(); |
| 514 } | 515 } |
| 515 #endif | 516 #endif |
| 516 | 517 |
| 518 UpdateNativeInterceptAllKeys(); | |
| 519 | |
| 517 if (app_window_contents_ && native_app_window_) | 520 if (app_window_contents_ && native_app_window_) |
| 518 app_window_contents_->NativeWindowChanged(native_app_window_.get()); | 521 app_window_contents_->NativeWindowChanged(native_app_window_.get()); |
| 519 } | 522 } |
| 520 | 523 |
| 521 void AppWindow::OnNativeWindowActivated() { | 524 void AppWindow::OnNativeWindowActivated() { |
| 522 AppWindowRegistry::Get(browser_context_)->AppWindowActivated(this); | 525 AppWindowRegistry::Get(browser_context_)->AppWindowActivated(this); |
| 523 } | 526 } |
| 524 | 527 |
| 525 content::WebContents* AppWindow::web_contents() const { | 528 content::WebContents* AppWindow::web_contents() const { |
| 526 return app_window_contents_->GetWebContents(); | 529 return app_window_contents_->GetWebContents(); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 730 // overlap the taskbar to be on top. The property will be applied when the | 733 // overlap the taskbar to be on top. The property will be applied when the |
| 731 // window exits fullscreen and moves away from the taskbar. | 734 // window exits fullscreen and moves away from the taskbar. |
| 732 if (!IsFullscreen(fullscreen_types_) && !IntersectsWithTaskbar()) | 735 if (!IsFullscreen(fullscreen_types_) && !IntersectsWithTaskbar()) |
| 733 native_app_window_->SetAlwaysOnTop(always_on_top); | 736 native_app_window_->SetAlwaysOnTop(always_on_top); |
| 734 | 737 |
| 735 OnNativeWindowChanged(); | 738 OnNativeWindowChanged(); |
| 736 } | 739 } |
| 737 | 740 |
| 738 bool AppWindow::IsAlwaysOnTop() const { return cached_always_on_top_; } | 741 bool AppWindow::IsAlwaysOnTop() const { return cached_always_on_top_; } |
| 739 | 742 |
| 743 void AppWindow::SetInterceptAllKeys(bool want_all_keys) { | |
| 744 if (cached_want_all_keys_ == want_all_keys) { | |
| 745 return; | |
| 746 } | |
| 747 | |
| 748 cached_want_all_keys_ = want_all_keys; | |
| 749 UpdateNativeInterceptAllKeys(); | |
| 750 } | |
| 751 | |
| 740 void AppWindow::WindowEventsReady() { | 752 void AppWindow::WindowEventsReady() { |
| 741 can_send_events_ = true; | 753 can_send_events_ = true; |
| 742 SendOnWindowShownIfShown(); | 754 SendOnWindowShownIfShown(); |
| 743 } | 755 } |
| 744 | 756 |
| 745 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { | 757 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { |
| 746 DCHECK(properties); | 758 DCHECK(properties); |
| 747 | 759 |
| 748 properties->SetBoolean("fullscreen", | 760 properties->SetBoolean("fullscreen", |
| 749 native_app_window_->IsFullscreenOrPending()); | 761 native_app_window_->IsFullscreenOrPending()); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 891 // When entering fullscreen or overlapping the taskbar, ensure windows are | 903 // When entering fullscreen or overlapping the taskbar, ensure windows are |
| 892 // not always-on-top. | 904 // not always-on-top. |
| 893 native_app_window_->SetAlwaysOnTop(false); | 905 native_app_window_->SetAlwaysOnTop(false); |
| 894 } else if (!is_on_top && !fullscreen && !intersects_taskbar) { | 906 } else if (!is_on_top && !fullscreen && !intersects_taskbar) { |
| 895 // When exiting fullscreen and moving away from the taskbar, reinstate | 907 // When exiting fullscreen and moving away from the taskbar, reinstate |
| 896 // always-on-top. | 908 // always-on-top. |
| 897 native_app_window_->SetAlwaysOnTop(true); | 909 native_app_window_->SetAlwaysOnTop(true); |
| 898 } | 910 } |
| 899 } | 911 } |
| 900 | 912 |
| 913 void AppWindow::UpdateNativeInterceptAllKeys() { | |
| 914 // This function could be called from OnNativeWindowChanged() even before the | |
| 915 // object is initialized. So make sure that we have a valid object. | |
| 916 if (native_app_window_) { | |
| 917 bool should_intercept_all_keys = | |
| 918 cached_want_all_keys_ && native_app_window_->IsActive(); | |
| 919 native_app_window_->SetInterceptAllKeys(should_intercept_all_keys); | |
|
benwells
2014/07/16 09:39:14
This is going to be called a lot - e.g. when the w
Sriram
2014/07/24 22:38:54
Done.
| |
| 920 } | |
| 921 } | |
| 922 | |
| 901 void AppWindow::SendOnWindowShownIfShown() { | 923 void AppWindow::SendOnWindowShownIfShown() { |
| 902 if (!can_send_events_ || !has_been_shown_) | 924 if (!can_send_events_ || !has_been_shown_) |
| 903 return; | 925 return; |
| 904 | 926 |
| 905 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { | 927 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { |
| 906 app_window_contents_->DispatchWindowShownForTests(); | 928 app_window_contents_->DispatchWindowShownForTests(); |
| 907 } | 929 } |
| 908 } | 930 } |
| 909 | 931 |
| 910 void AppWindow::CloseContents(WebContents* contents) { | 932 void AppWindow::CloseContents(WebContents* contents) { |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1142 region.bounds.x(), | 1164 region.bounds.x(), |
| 1143 region.bounds.y(), | 1165 region.bounds.y(), |
| 1144 region.bounds.right(), | 1166 region.bounds.right(), |
| 1145 region.bounds.bottom(), | 1167 region.bounds.bottom(), |
| 1146 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 1168 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 1147 } | 1169 } |
| 1148 return sk_region; | 1170 return sk_region; |
| 1149 } | 1171 } |
| 1150 | 1172 |
| 1151 } // namespace apps | 1173 } // namespace apps |
| OLD | NEW |