OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/views/extensions/native_app_window_views.h" | 5 #include "chrome/browser/ui/views/extensions/native_app_window_views.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 #endif | 34 #endif |
35 | 35 |
36 #if defined(USE_ASH) | 36 #if defined(USE_ASH) |
37 #include "ash/screen_ash.h" | 37 #include "ash/screen_ash.h" |
38 #include "ash/shell.h" | 38 #include "ash/shell.h" |
39 #include "ash/wm/custom_frame_view_ash.h" | 39 #include "ash/wm/custom_frame_view_ash.h" |
40 #include "ash/wm/panels/panel_frame_view.h" | 40 #include "ash/wm/panels/panel_frame_view.h" |
41 #include "ash/wm/window_properties.h" | 41 #include "ash/wm/window_properties.h" |
42 #include "chrome/browser/ui/ash/ash_util.h" | 42 #include "chrome/browser/ui/ash/ash_util.h" |
43 #include "ui/aura/root_window.h" | 43 #include "ui/aura/root_window.h" |
44 #include "ui/aura/window.h" | |
44 #endif | 45 #endif |
45 | 46 |
46 namespace { | 47 namespace { |
47 | 48 |
48 const int kMinPanelWidth = 100; | 49 const int kMinPanelWidth = 100; |
49 const int kMinPanelHeight = 100; | 50 const int kMinPanelHeight = 100; |
50 const int kDefaultPanelWidth = 200; | 51 const int kDefaultPanelWidth = 200; |
51 const int kDefaultPanelHeight = 300; | 52 const int kDefaultPanelHeight = 300; |
52 const int kResizeInsideBoundsSize = 5; | 53 const int kResizeInsideBoundsSize = 5; |
53 | 54 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 } | 260 } |
260 #else | 261 #else |
261 params.bounds = gfx::Rect(preferred_size_); | 262 params.bounds = gfx::Rect(preferred_size_); |
262 #endif | 263 #endif |
263 // TODO(erg): Conceptually, these are toplevel windows, but we theoretically | 264 // TODO(erg): Conceptually, these are toplevel windows, but we theoretically |
264 // could plumb context through to here in some cases. | 265 // could plumb context through to here in some cases. |
265 params.top_level = true; | 266 params.top_level = true; |
266 window_->Init(params); | 267 window_->Init(params); |
267 window_->set_focus_on_creation(create_params.focused); | 268 window_->set_focus_on_creation(create_params.focused); |
268 | 269 |
269 #if !defined(USE_ASH) | 270 #if defined(USE_ASH) |
270 // TODO(oshima|stevenjb): Ideally, we should be able to just pre-determine | 271 if (create_params.state == ui::SHOW_STATE_DETACHED) { |
271 // the exact location and size, but this doesn't work well | 272 gfx::Rect window_bounds(create_params.bounds.x(), |
272 // on non-ash environment where we don't have full control over | 273 create_params.bounds.y(), |
273 // window management. | 274 preferred_size_.width(), |
274 gfx::Rect window_bounds = | 275 preferred_size_.height()); |
275 window_->non_client_view()->GetWindowBoundsForClientBounds( | 276 aura::Window* win = GetNativeWindow(); |
276 create_params.bounds); | 277 win->SetProperty(ash::internal::kPanelAttachedKey, false); |
277 window_->SetBounds(window_bounds); | 278 win->SetDefaultParentByRootWindow( |
flackr
2013/04/26 03:44:38
You seem to be removing restoring bounds for non a
stevenjb
2013/04/26 16:12:17
As I commented, this is not implemented for non-as
| |
279 win->GetRootWindow(), | |
280 win->GetBoundsInScreen()); | |
281 window_->SetBounds(window_bounds); | |
282 } | |
283 #else | |
284 // TODO(stevenjb): NativeAppWindow panels need to be implemented for other | |
285 // platforms. | |
278 #endif | 286 #endif |
279 } | 287 } |
280 | 288 |
281 // BaseWindow implementation. | 289 // BaseWindow implementation. |
282 | 290 |
283 bool NativeAppWindowViews::IsActive() const { | 291 bool NativeAppWindowViews::IsActive() const { |
284 return window_->IsActive(); | 292 return window_->IsActive(); |
285 } | 293 } |
286 | 294 |
287 bool NativeAppWindowViews::IsMaximized() const { | 295 bool NativeAppWindowViews::IsMaximized() const { |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
658 window_->SetFullscreen(fullscreen); | 666 window_->SetFullscreen(fullscreen); |
659 // TODO(jeremya) we need to call RenderViewHost::ExitFullscreen() if we | 667 // TODO(jeremya) we need to call RenderViewHost::ExitFullscreen() if we |
660 // ever drop the window out of fullscreen in response to something that | 668 // ever drop the window out of fullscreen in response to something that |
661 // wasn't the app calling webkitCancelFullScreen(). | 669 // wasn't the app calling webkitCancelFullScreen(). |
662 } | 670 } |
663 | 671 |
664 bool NativeAppWindowViews::IsFullscreenOrPending() const { | 672 bool NativeAppWindowViews::IsFullscreenOrPending() const { |
665 return is_fullscreen_; | 673 return is_fullscreen_; |
666 } | 674 } |
667 | 675 |
676 bool NativeAppWindowViews::IsDetached() const { | |
677 if (!shell_window_->window_type_is_panel()) | |
678 return false; | |
679 #if defined(USE_ASH) | |
680 return !window_->GetNativeWindow()->GetProperty( | |
681 ash::internal::kPanelAttachedKey); | |
682 #else | |
683 return false; | |
684 #endif | |
685 } | |
686 | |
668 views::View* NativeAppWindowViews::GetContentsView() { | 687 views::View* NativeAppWindowViews::GetContentsView() { |
669 return this; | 688 return this; |
670 } | 689 } |
671 | 690 |
672 void NativeAppWindowViews::UpdateWindowIcon() { | 691 void NativeAppWindowViews::UpdateWindowIcon() { |
673 window_->UpdateWindowIcon(); | 692 window_->UpdateWindowIcon(); |
674 } | 693 } |
675 | 694 |
676 void NativeAppWindowViews::UpdateWindowTitle() { | 695 void NativeAppWindowViews::UpdateWindowTitle() { |
677 window_->UpdateWindowTitle(); | 696 window_->UpdateWindowTitle(); |
(...skipping 20 matching lines...) Expand all Loading... | |
698 } | 717 } |
699 | 718 |
700 //------------------------------------------------------------------------------ | 719 //------------------------------------------------------------------------------ |
701 // NativeAppWindow::Create | 720 // NativeAppWindow::Create |
702 | 721 |
703 // static | 722 // static |
704 NativeAppWindow* NativeAppWindow::Create( | 723 NativeAppWindow* NativeAppWindow::Create( |
705 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { | 724 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { |
706 return new NativeAppWindowViews(shell_window, params); | 725 return new NativeAppWindowViews(shell_window, params); |
707 } | 726 } |
OLD | NEW |