Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: chrome/browser/ui/views/apps/native_app_window_views.cc

Issue 25536010: Make packaged apps use AppNonClientFrameViewAsh when maximized (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/apps/native_app_window_views.h" 5 #include "chrome/browser/ui/views/apps/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"
11 #include "chrome/app/chrome_command_ids.h" 11 #include "chrome/app/chrome_command_ids.h"
12 #include "chrome/browser/extensions/extension_host.h" 12 #include "chrome/browser/extensions/extension_host.h"
13 #include "chrome/browser/favicon/favicon_tab_helper.h" 13 #include "chrome/browser/favicon/favicon_tab_helper.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/host_desktop.h"
15 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" 16 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h"
16 #include "chrome/browser/ui/views/extensions/shell_window_frame_view.h" 17 #include "chrome/browser/ui/views/extensions/shell_window_frame_view.h"
17 #include "chrome/browser/web_applications/web_app.h" 18 #include "chrome/browser/web_applications/web_app.h"
18 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/extensions/extension.h" 20 #include "chrome/common/extensions/extension.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
22 #include "content/public/browser/render_widget_host_view.h" 23 #include "content/public/browser/render_widget_host_view.h"
23 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
24 #include "content/public/browser/web_contents_view.h" 25 #include "content/public/browser/web_contents_view.h"
25 #include "extensions/common/draggable_region.h" 26 #include "extensions/common/draggable_region.h"
26 #include "ui/views/controls/webview/webview.h" 27 #include "ui/views/controls/webview/webview.h"
27 #include "ui/views/widget/widget.h" 28 #include "ui/views/widget/widget.h"
28 #include "ui/views/window/non_client_view.h" 29 #include "ui/views/window/non_client_view.h"
29 30
30 #if defined(OS_WIN) 31 #if defined(OS_WIN)
31 #include "base/strings/utf_string_conversions.h" 32 #include "base/strings/utf_string_conversions.h"
32 #include "chrome/browser/ui/web_applications/web_app_ui.h" 33 #include "chrome/browser/ui/web_applications/web_app_ui.h"
33 #include "chrome/browser/web_applications/web_app_win.h" 34 #include "chrome/browser/web_applications/web_app_win.h"
34 #include "ui/base/win/shell.h" 35 #include "ui/base/win/shell.h"
35 #include "ui/views/win/hwnd_util.h" 36 #include "ui/views/win/hwnd_util.h"
36 #endif 37 #endif
37 38
38 #if defined(OS_LINUX) 39 #if defined(OS_LINUX)
39 #include "chrome/browser/shell_integration_linux.h" 40 #include "chrome/browser/shell_integration_linux.h"
40 #endif 41 #endif
41 42
42 #if defined(USE_ASH) 43 #if defined(USE_ASH)
44 #include "ash/ash_switches.h"
43 #include "ash/screen_ash.h" 45 #include "ash/screen_ash.h"
44 #include "ash/shell.h" 46 #include "ash/shell.h"
45 #include "ash/wm/custom_frame_view_ash.h" 47 #include "ash/wm/custom_frame_view_ash.h"
46 #include "ash/wm/panels/panel_frame_view.h" 48 #include "ash/wm/panels/panel_frame_view.h"
47 #include "ash/wm/window_state.h" 49 #include "ash/wm/window_state.h"
48 #include "chrome/browser/ui/ash/ash_util.h" 50 #include "chrome/browser/ui/ash/ash_util.h"
51 #include "chrome/browser/ui/views/frame/app_non_client_frame_view_ash.h"
52 #include "chrome/browser/ui/views/frame/non_client_frame_view_switcher_ash.h"
49 #include "ui/aura/client/aura_constants.h" 53 #include "ui/aura/client/aura_constants.h"
50 #include "ui/aura/root_window.h" 54 #include "ui/aura/root_window.h"
51 #include "ui/aura/window.h" 55 #include "ui/aura/window.h"
56 #include "ui/views/widget/native_widget_aura.h"
52 #endif 57 #endif
53 58
54 using apps::ShellWindow; 59 using apps::ShellWindow;
55 60
56 namespace { 61 namespace {
57 62
58 const int kMinPanelWidth = 100; 63 const int kMinPanelWidth = 100;
59 const int kMinPanelHeight = 100; 64 const int kMinPanelHeight = 100;
60 const int kDefaultPanelWidth = 200; 65 const int kDefaultPanelWidth = 200;
61 const int kDefaultPanelHeight = 300; 66 const int kDefaultPanelHeight = 300;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 if (position_specified && !window_bounds.IsEmpty()) 180 if (position_specified && !window_bounds.IsEmpty())
176 init_params.bounds = window_bounds; 181 init_params.bounds = window_bounds;
177 182
178 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 183 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
179 // Set up a custom WM_CLASS for app windows. This allows task switchers in 184 // Set up a custom WM_CLASS for app windows. This allows task switchers in
180 // X11 environments to distinguish them from main browser windows. 185 // X11 environments to distinguish them from main browser windows.
181 init_params.wm_class_name = web_app::GetWMClassFromAppName(app_name); 186 init_params.wm_class_name = web_app::GetWMClassFromAppName(app_name);
182 init_params.wm_class_class = ShellIntegrationLinux::GetProgramClassName(); 187 init_params.wm_class_class = ShellIntegrationLinux::GetProgramClassName();
183 #endif 188 #endif
184 189
190 #if defined(USE_ASH)
191 if (!frameless_ &&
192 ash::switches::UseSameFrameForV1AndV2Apps() &&
193 chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) {
194 // Initialize |frame_switcher_| to switch the non client frame view when
195 // |native_widget| is maximized. |frame_switcher_| must be initialized
196 // before |window_| is inited because it must set a WindowObserver on
197 // |native_widget| before WorkspaceLayoutManager does. This results in
198 // NonClientFrameViewSwitcherAsh getting notified of |native_widget|'s
199 // maximized state changes before WorkspaceLayoutManager and avoids an extra
200 // layout of the web contents when |native_widget| is maximized.
201 views::NativeWidgetAura* native_widget =
202 new views::NativeWidgetAura(window_);
203 frame_switcher_.reset(new NonClientFrameViewSwitcherAsh(
204 window_, native_widget->GetNativeView()));
205
206 init_params.native_widget = native_widget;
207 init_params.context = ash::Shell::GetPrimaryRootWindow();
208 }
209 #endif
210
185 window_->Init(init_params); 211 window_->Init(init_params);
186 212
187 gfx::Rect adjusted_bounds = window_bounds; 213 gfx::Rect adjusted_bounds = window_bounds;
188 adjusted_bounds.Inset(-GetFrameInsets()); 214 adjusted_bounds.Inset(-GetFrameInsets());
189 // Center window if no position was specified. 215 // Center window if no position was specified.
190 if (!position_specified) 216 if (!position_specified)
191 window_->CenterWindow(adjusted_bounds.size()); 217 window_->CenterWindow(adjusted_bounds.size());
192 else if (!adjusted_bounds.IsEmpty() && adjusted_bounds != window_bounds) 218 else if (!adjusted_bounds.IsEmpty() && adjusted_bounds != window_bounds)
193 window_->SetBounds(adjusted_bounds); 219 window_->SetBounds(adjusted_bounds);
194 220
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView( 625 views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView(
600 views::Widget* widget) { 626 views::Widget* widget) {
601 #if defined(USE_ASH) 627 #if defined(USE_ASH)
602 if (chrome::IsNativeViewInAsh(widget->GetNativeView())) { 628 if (chrome::IsNativeViewInAsh(widget->GetNativeView())) {
603 if (shell_window_->window_type_is_panel()) { 629 if (shell_window_->window_type_is_panel()) {
604 ash::PanelFrameView::FrameType frame_type = frameless_ ? 630 ash::PanelFrameView::FrameType frame_type = frameless_ ?
605 ash::PanelFrameView::FRAME_NONE : ash::PanelFrameView::FRAME_ASH; 631 ash::PanelFrameView::FRAME_NONE : ash::PanelFrameView::FRAME_ASH;
606 return new ash::PanelFrameView(widget, frame_type); 632 return new ash::PanelFrameView(widget, frame_type);
607 } 633 }
608 if (!frameless_) { 634 if (!frameless_) {
609 ash::CustomFrameViewAsh* frame = new ash::CustomFrameViewAsh(); 635 if (ash::switches::UseSameFrameForV1AndV2Apps() &&
610 frame->Init(widget); 636 IsMaximized()) {
611 return frame; 637 return new AppNonClientFrameViewAsh(widget);
638 } else {
639 ash::CustomFrameViewAsh* frame = new ash::CustomFrameViewAsh();
640 frame->Init(widget);
641 return frame;
642 }
612 } 643 }
613 } 644 }
614 #endif 645 #endif
615 if (ShouldUseChromeStyleFrame()) { 646 if (ShouldUseChromeStyleFrame()) {
616 ShellWindowFrameView* frame_view = new ShellWindowFrameView(this); 647 ShellWindowFrameView* frame_view = new ShellWindowFrameView(this);
617 frame_view->Init(window_); 648 frame_view->Init(window_);
618 return frame_view; 649 return frame_view;
619 } 650 }
620 return views::WidgetDelegateView::CreateNonClientFrameView(widget); 651 return views::WidgetDelegateView::CreateNonClientFrameView(widget);
621 } 652 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 813
783 void NativeAppWindowViews::HandleKeyboardEvent( 814 void NativeAppWindowViews::HandleKeyboardEvent(
784 const content::NativeWebKeyboardEvent& event) { 815 const content::NativeWebKeyboardEvent& event) {
785 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, 816 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event,
786 GetFocusManager()); 817 GetFocusManager());
787 } 818 }
788 819
789 void NativeAppWindowViews::RenderViewHostChanged() { 820 void NativeAppWindowViews::RenderViewHostChanged() {
790 OnViewWasResized(); 821 OnViewWasResized();
791 } 822 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/apps/native_app_window_views.h ('k') | chrome/browser/ui/views/frame/app_browser_frame_view_ash.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698