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

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

Issue 210363004: Linux: App windows with frame: chrome and no color are now native. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't need not IsFrameless(); that is implied by has_frame_color_. Created 6 years, 9 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
« no previous file with comments | « chrome/browser/ui/views/apps/chrome_native_app_window_views.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/ui/views/apps/chrome_native_app_window_views.h" 5 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views.h"
6 6
7 #include "apps/ui/views/app_window_frame_view.h" 7 #include "apps/ui/views/app_window_frame_view.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/app_mode/app_mode_utils.h" 10 #include "chrome/browser/app_mode/app_mode_utils.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 views::Widget* widget) {} 203 views::Widget* widget) {}
204 204
205 void ChromeNativeAppWindowViews::InitializeDefaultWindow( 205 void ChromeNativeAppWindowViews::InitializeDefaultWindow(
206 const AppWindow::CreateParams& create_params) { 206 const AppWindow::CreateParams& create_params) {
207 std::string app_name = 207 std::string app_name =
208 web_app::GenerateApplicationNameFromExtensionId( 208 web_app::GenerateApplicationNameFromExtensionId(
209 app_window()->extension()->id()); 209 app_window()->extension()->id());
210 210
211 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); 211 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW);
212 init_params.delegate = this; 212 init_params.delegate = this;
213 init_params.remove_standard_frame = !ShouldUseNativeFrame(); 213 init_params.remove_standard_frame = IsFrameless() || has_frame_color_;
214 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
215 // On Linux, remove the standard frame. Instead, we will use CustomFrameView
216 // to draw a native-like frame.
217 // TODO(mgiuca): Remove this during fix for http://crbug.com/322256.
218 init_params.remove_standard_frame = true;
219 #endif
220 init_params.use_system_default_icon = true; 214 init_params.use_system_default_icon = true;
221 // TODO(erg): Conceptually, these are toplevel windows, but we theoretically 215 // TODO(erg): Conceptually, these are toplevel windows, but we theoretically
222 // could plumb context through to here in some cases. 216 // could plumb context through to here in some cases.
223 init_params.top_level = true; 217 init_params.top_level = true;
224 if (create_params.transparent_background) 218 if (create_params.transparent_background)
225 init_params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 219 init_params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
226 init_params.keep_on_top = create_params.always_on_top; 220 init_params.keep_on_top = create_params.always_on_top;
227 221
228 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 222 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
229 // Set up a custom WM_CLASS for app windows. This allows task switchers in 223 // Set up a custom WM_CLASS for app windows. This allows task switchers in
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 native_window->GetRootWindow(), 324 native_window->GetRootWindow(),
331 native_window->GetBoundsInScreen()); 325 native_window->GetBoundsInScreen());
332 widget()->SetBounds(window_bounds); 326 widget()->SetBounds(window_bounds);
333 } 327 }
334 #else 328 #else
335 // TODO(stevenjb): NativeAppWindow panels need to be implemented for other 329 // TODO(stevenjb): NativeAppWindow panels need to be implemented for other
336 // platforms. 330 // platforms.
337 #endif 331 #endif
338 } 332 }
339 333
340 bool ChromeNativeAppWindowViews::ShouldUseNativeFrame() const {
341 return !IsFrameless() && !has_frame_color_;
342 }
343
344 void ChromeNativeAppWindowViews::InstallEasyResizeTargeterOnContainer() const { 334 void ChromeNativeAppWindowViews::InstallEasyResizeTargeterOnContainer() const {
345 aura::Window* root_window = widget()->GetNativeWindow()->GetRootWindow(); 335 aura::Window* root_window = widget()->GetNativeWindow()->GetRootWindow();
346 gfx::Insets inset(kResizeInsideBoundsSize, kResizeInsideBoundsSize, 336 gfx::Insets inset(kResizeInsideBoundsSize, kResizeInsideBoundsSize,
347 kResizeInsideBoundsSize, kResizeInsideBoundsSize); 337 kResizeInsideBoundsSize, kResizeInsideBoundsSize);
348 root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( 338 root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
349 new wm::EasyResizeWindowTargeter(root_window, inset, inset))); 339 new wm::EasyResizeWindowTargeter(root_window, inset, inset)));
350 } 340 }
351 341
352 apps::AppWindowFrameView* 342 apps::AppWindowFrameView*
353 ChromeNativeAppWindowViews::CreateAppWindowFrameView() { 343 ChromeNativeAppWindowViews::CreateAppWindowFrameView() {
354 // By default the user can resize the window from slightly inside the bounds. 344 // By default the user can resize the window from slightly inside the bounds.
355 int resize_inside_bounds_size = kResizeInsideBoundsSize; 345 int resize_inside_bounds_size = kResizeInsideBoundsSize;
356 int resize_outside_bounds_size = 0; 346 int resize_outside_bounds_size = 0;
357 int resize_outside_scale_for_touch = 1; 347 int resize_outside_scale_for_touch = 1;
358 int resize_area_corner_size = kResizeAreaCornerSize; 348 int resize_area_corner_size = kResizeAreaCornerSize;
359 #if defined(USE_ASH) 349 #if defined(USE_ASH)
360 // For Aura windows on the Ash desktop the sizes are different and the user 350 // For Aura windows on the Ash desktop the sizes are different and the user
361 // can resize the window from slightly outside the bounds as well. 351 // can resize the window from slightly outside the bounds as well.
362 if (chrome::IsNativeWindowInAsh(widget()->GetNativeWindow())) { 352 if (chrome::IsNativeWindowInAsh(widget()->GetNativeWindow())) {
363 resize_inside_bounds_size = ash::kResizeInsideBoundsSize; 353 resize_inside_bounds_size = ash::kResizeInsideBoundsSize;
364 resize_outside_bounds_size = ash::kResizeOutsideBoundsSize; 354 resize_outside_bounds_size = ash::kResizeOutsideBoundsSize;
365 resize_outside_scale_for_touch = ash::kResizeOutsideBoundsScaleForTouch; 355 resize_outside_scale_for_touch = ash::kResizeOutsideBoundsScaleForTouch;
366 resize_area_corner_size = ash::kResizeAreaCornerSize; 356 resize_area_corner_size = ash::kResizeAreaCornerSize;
367 } 357 }
368 #endif 358 #endif
369 apps::AppWindowFrameView* frame_view = new apps::AppWindowFrameView(this); 359 apps::AppWindowFrameView* frame_view = new apps::AppWindowFrameView();
370 frame_view->Init(widget(), 360 frame_view->Init(widget(),
361 has_frame_color_,
371 frame_color_, 362 frame_color_,
363 GetDraggableRegion(),
372 resize_inside_bounds_size, 364 resize_inside_bounds_size,
373 resize_outside_bounds_size, 365 resize_outside_bounds_size,
374 resize_outside_scale_for_touch, 366 resize_outside_scale_for_touch,
375 resize_area_corner_size); 367 resize_area_corner_size);
376 return frame_view; 368 return frame_view;
377 } 369 }
378 370
379 // ui::BaseWindow implementation. 371 // ui::BaseWindow implementation.
380 372
381 ui::WindowShowState ChromeNativeAppWindowViews::GetRestoredState() const { 373 ui::WindowShowState ChromeNativeAppWindowViews::GetRestoredState() const {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 // Non-frameless app windows can be put into immersive fullscreen. 498 // Non-frameless app windows can be put into immersive fullscreen.
507 immersive_fullscreen_controller_.reset( 499 immersive_fullscreen_controller_.reset(
508 new ash::ImmersiveFullscreenController()); 500 new ash::ImmersiveFullscreenController());
509 custom_frame_view->InitImmersiveFullscreenControllerForView( 501 custom_frame_view->InitImmersiveFullscreenControllerForView(
510 immersive_fullscreen_controller_.get()); 502 immersive_fullscreen_controller_.get());
511 custom_frame_view->GetHeaderView()->set_context_menu_controller(this); 503 custom_frame_view->GetHeaderView()->set_context_menu_controller(this);
512 return custom_frame_view; 504 return custom_frame_view;
513 } 505 }
514 } 506 }
515 #endif 507 #endif
516 if (!ShouldUseNativeFrame()) 508 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
509 return CreateAppWindowFrameView();
510 #else
511 if (IsFrameless() || has_frame_color_)
517 return CreateAppWindowFrameView(); 512 return CreateAppWindowFrameView();
513 #endif
518 return views::WidgetDelegateView::CreateNonClientFrameView(widget); 514 return views::WidgetDelegateView::CreateNonClientFrameView(widget);
519 } 515 }
520 516
521 bool ChromeNativeAppWindowViews::WidgetHasHitTestMask() const { 517 bool ChromeNativeAppWindowViews::WidgetHasHitTestMask() const {
522 return shape_ != NULL; 518 return shape_ != NULL;
523 } 519 }
524 520
525 void ChromeNativeAppWindowViews::GetWidgetHitTestMask(gfx::Path* mask) const { 521 void ChromeNativeAppWindowViews::GetWidgetHitTestMask(gfx::Path* mask) const {
526 shape_->getBoundaryPath(mask); 522 shape_->getBoundaryPath(mask);
527 } 523 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 } else { 661 } else {
666 InitializeDefaultWindow(create_params); 662 InitializeDefaultWindow(create_params);
667 } 663 }
668 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( 664 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews(
669 Profile::FromBrowserContext(app_window->browser_context()), 665 Profile::FromBrowserContext(app_window->browser_context()),
670 widget()->GetFocusManager(), 666 widget()->GetFocusManager(),
671 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, 667 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY,
672 NULL)); 668 NULL));
673 669
674 #if defined(OS_WIN) 670 #if defined(OS_WIN)
675 if (!ShouldUseNativeFrame() && 671 if ((IsFrameless() || has_frame_color_) &&
676 chrome::GetHostDesktopTypeForNativeWindow(widget()->GetNativeWindow()) != 672 chrome::GetHostDesktopTypeForNativeWindow(widget()->GetNativeWindow()) !=
677 chrome::HOST_DESKTOP_TYPE_ASH) { 673 chrome::HOST_DESKTOP_TYPE_ASH) {
678 InstallEasyResizeTargeterOnContainer(); 674 InstallEasyResizeTargeterOnContainer();
679 } 675 }
680 #endif 676 #endif
681 } 677 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/apps/chrome_native_app_window_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698