| 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 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 window_type_(WINDOW_TYPE_DEFAULT), | 237 window_type_(WINDOW_TYPE_DEFAULT), |
| 238 delegate_(delegate), | 238 delegate_(delegate), |
| 239 image_loader_ptr_factory_(this), | 239 image_loader_ptr_factory_(this), |
| 240 fullscreen_types_(FULLSCREEN_TYPE_NONE), | 240 fullscreen_types_(FULLSCREEN_TYPE_NONE), |
| 241 show_on_first_paint_(false), | 241 show_on_first_paint_(false), |
| 242 first_paint_complete_(false), | 242 first_paint_complete_(false), |
| 243 has_been_shown_(false), | 243 has_been_shown_(false), |
| 244 can_send_events_(false), | 244 can_send_events_(false), |
| 245 is_hidden_(false), | 245 is_hidden_(false), |
| 246 cached_always_on_top_(false), | 246 cached_always_on_top_(false), |
| 247 requested_transparent_background_(false) { | 247 requested_transparent_background_(false), |
| 248 cached_want_all_keys_(false) { |
| 248 extensions::ExtensionsBrowserClient* client = | 249 extensions::ExtensionsBrowserClient* client = |
| 249 extensions::ExtensionsBrowserClient::Get(); | 250 extensions::ExtensionsBrowserClient::Get(); |
| 250 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord()) | 251 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord()) |
| 251 << "Only off the record window may be opened in the guest mode."; | 252 << "Only off the record window may be opened in the guest mode."; |
| 252 } | 253 } |
| 253 | 254 |
| 254 void AppWindow::Init(const GURL& url, | 255 void AppWindow::Init(const GURL& url, |
| 255 AppWindowContents* app_window_contents, | 256 AppWindowContents* app_window_contents, |
| 256 const CreateParams& params) { | 257 const CreateParams& params) { |
| 257 // Initialize the render interface and web contents | 258 // Initialize the render interface and web contents |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 // that to happen, we need to define a size for the content, otherwise the | 345 // that to happen, we need to define a size for the content, otherwise the |
| 345 // layout will happen in a 0x0 area. | 346 // layout will happen in a 0x0 area. |
| 346 gfx::Insets frame_insets = native_app_window_->GetFrameInsets(); | 347 gfx::Insets frame_insets = native_app_window_->GetFrameInsets(); |
| 347 gfx::Rect initial_bounds = new_params.GetInitialWindowBounds(frame_insets); | 348 gfx::Rect initial_bounds = new_params.GetInitialWindowBounds(frame_insets); |
| 348 initial_bounds.Inset(frame_insets); | 349 initial_bounds.Inset(frame_insets); |
| 349 apps::ResizeWebContents(web_contents, initial_bounds.size()); | 350 apps::ResizeWebContents(web_contents, initial_bounds.size()); |
| 350 } | 351 } |
| 351 } | 352 } |
| 352 | 353 |
| 353 AppWindow::~AppWindow() { | 354 AppWindow::~AppWindow() { |
| 355 if (cached_want_all_keys_) { |
| 356 native_app_window_->SetInterceptAllKeys(false); |
| 357 cached_want_all_keys_ = false; |
| 358 } |
| 359 |
| 354 // Unregister now to prevent getting NOTIFICATION_APP_TERMINATING if we're the | 360 // Unregister now to prevent getting NOTIFICATION_APP_TERMINATING if we're the |
| 355 // last window open. | 361 // last window open. |
| 356 registrar_.RemoveAll(); | 362 registrar_.RemoveAll(); |
| 357 | 363 |
| 358 // Remove shutdown prevention. | 364 // Remove shutdown prevention. |
| 359 AppsClient::Get()->DecrementKeepAliveCount(); | 365 AppsClient::Get()->DecrementKeepAliveCount(); |
| 360 } | 366 } |
| 361 | 367 |
| 362 void AppWindow::RequestMediaAccessPermission( | 368 void AppWindow::RequestMediaAccessPermission( |
| 363 content::WebContents* web_contents, | 369 content::WebContents* web_contents, |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 // overlap the taskbar to be on top. The property will be applied when the | 756 // overlap the taskbar to be on top. The property will be applied when the |
| 751 // window exits fullscreen and moves away from the taskbar. | 757 // window exits fullscreen and moves away from the taskbar. |
| 752 if (!IsFullscreen() && !IntersectsWithTaskbar()) | 758 if (!IsFullscreen() && !IntersectsWithTaskbar()) |
| 753 native_app_window_->SetAlwaysOnTop(always_on_top); | 759 native_app_window_->SetAlwaysOnTop(always_on_top); |
| 754 | 760 |
| 755 OnNativeWindowChanged(); | 761 OnNativeWindowChanged(); |
| 756 } | 762 } |
| 757 | 763 |
| 758 bool AppWindow::IsAlwaysOnTop() const { return cached_always_on_top_; } | 764 bool AppWindow::IsAlwaysOnTop() const { return cached_always_on_top_; } |
| 759 | 765 |
| 766 void AppWindow::SetInterceptAllKeys(bool want_all_keys) { |
| 767 if (cached_want_all_keys_ != want_all_keys) { |
| 768 native_app_window_->SetInterceptAllKeys(want_all_keys); |
| 769 cached_want_all_keys_ = want_all_keys; |
| 770 } |
| 771 } |
| 772 |
| 760 void AppWindow::WindowEventsReady() { | 773 void AppWindow::WindowEventsReady() { |
| 761 can_send_events_ = true; | 774 can_send_events_ = true; |
| 762 SendOnWindowShownIfShown(); | 775 SendOnWindowShownIfShown(); |
| 763 } | 776 } |
| 764 | 777 |
| 765 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { | 778 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { |
| 766 DCHECK(properties); | 779 DCHECK(properties); |
| 767 | 780 |
| 768 properties->SetBoolean("fullscreen", | 781 properties->SetBoolean("fullscreen", |
| 769 native_app_window_->IsFullscreenOrPending()); | 782 native_app_window_->IsFullscreenOrPending()); |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 region.bounds.x(), | 1162 region.bounds.x(), |
| 1150 region.bounds.y(), | 1163 region.bounds.y(), |
| 1151 region.bounds.right(), | 1164 region.bounds.right(), |
| 1152 region.bounds.bottom(), | 1165 region.bounds.bottom(), |
| 1153 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 1166 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 1154 } | 1167 } |
| 1155 return sk_region; | 1168 return sk_region; |
| 1156 } | 1169 } |
| 1157 | 1170 |
| 1158 } // namespace apps | 1171 } // namespace apps |
| OLD | NEW |