| 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" |
| 11 #include "apps/apps_client.h" | 11 #include "apps/apps_client.h" |
| 12 #include "apps/size_constraints.h" | 12 #include "apps/size_constraints.h" |
| 13 #include "apps/ui/native_app_window.h" | 13 #include "apps/ui/native_app_window.h" |
| 14 #include "apps/ui/web_contents_sizer.h" |
| 14 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/values.h" | 18 #include "base/values.h" |
| 18 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
| 19 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 20 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
| 20 #include "chrome/browser/extensions/suggest_permission_util.h" | 21 #include "chrome/browser/extensions/suggest_permission_util.h" |
| 21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" | 23 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" |
| 23 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 24 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 | 317 |
| 317 if (CommandLine::ForCurrentProcess()->HasSwitch( | 318 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 318 switches::kEnableAppsShowOnFirstPaint)) { | 319 switches::kEnableAppsShowOnFirstPaint)) { |
| 319 // We want to show the window only when the content has been painted. For | 320 // We want to show the window only when the content has been painted. For |
| 320 // that to happen, we need to define a size for the content, otherwise the | 321 // that to happen, we need to define a size for the content, otherwise the |
| 321 // layout will happen in a 0x0 area. | 322 // layout will happen in a 0x0 area. |
| 322 // Note: WebContents::GetView() is guaranteed to be non-null. | 323 // Note: WebContents::GetView() is guaranteed to be non-null. |
| 323 gfx::Insets frame_insets = native_app_window_->GetFrameInsets(); | 324 gfx::Insets frame_insets = native_app_window_->GetFrameInsets(); |
| 324 gfx::Rect initial_bounds = new_params.GetInitialWindowBounds(frame_insets); | 325 gfx::Rect initial_bounds = new_params.GetInitialWindowBounds(frame_insets); |
| 325 initial_bounds.Inset(frame_insets); | 326 initial_bounds.Inset(frame_insets); |
| 326 web_contents->GetView()->SizeContents(initial_bounds.size()); | 327 apps::ResizeWebContents(web_contents, initial_bounds.size()); |
| 327 } | 328 } |
| 328 | 329 |
| 329 // Prevent the browser process from shutting down while this window is open. | 330 // Prevent the browser process from shutting down while this window is open. |
| 330 AppsClient::Get()->IncrementKeepAliveCount(); | 331 AppsClient::Get()->IncrementKeepAliveCount(); |
| 331 | 332 |
| 332 UpdateExtensionAppIcon(); | 333 UpdateExtensionAppIcon(); |
| 333 | 334 |
| 334 AppWindowRegistry::Get(browser_context_)->AddAppWindow(this); | 335 AppWindowRegistry::Get(browser_context_)->AddAppWindow(this); |
| 335 } | 336 } |
| 336 | 337 |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 region.bounds.x(), | 1070 region.bounds.x(), |
| 1070 region.bounds.y(), | 1071 region.bounds.y(), |
| 1071 region.bounds.right(), | 1072 region.bounds.right(), |
| 1072 region.bounds.bottom(), | 1073 region.bounds.bottom(), |
| 1073 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 1074 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 1074 } | 1075 } |
| 1075 return sk_region; | 1076 return sk_region; |
| 1076 } | 1077 } |
| 1077 | 1078 |
| 1078 } // namespace apps | 1079 } // namespace apps |
| OLD | NEW |