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

Unified Diff: chrome/browser/ui/views/apps/chrome_native_app_window_views.cc

Issue 213743017: Remove title and icon from chrome apps native style title bars. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed leak in test Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/apps/chrome_native_app_window_views.cc
diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc b/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc
index 6a7bbd873dcd2c29e918fa8900de1e5c9444f8a4..114605fff34b9ab32ed5f7d3dcab1eaa992928b2 100644
--- a/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc
+++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/chrome_switches.h"
#include "extensions/common/extension.h"
+#include "ui/aura/window.h"
#include "ui/base/hit_test.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/gfx/image/image_skia.h"
@@ -46,14 +47,9 @@
#include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/window_tree_client.h"
-#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#endif
-#if defined(USE_AURA)
-#include "ui/aura/window.h"
-#endif
-
using apps::AppWindow;
namespace {
@@ -62,8 +58,6 @@ const int kMinPanelWidth = 100;
const int kMinPanelHeight = 100;
const int kDefaultPanelWidth = 200;
const int kDefaultPanelHeight = 300;
-const int kResizeInsideBoundsSize = 5;
-const int kResizeAreaCornerSize = 16;
struct AcceleratorMapping {
ui::KeyboardCode keycode;
@@ -346,44 +340,44 @@ void ChromeNativeAppWindowViews::InitializePanelWindow(
#endif
}
-void ChromeNativeAppWindowViews::InstallEasyResizeTargeterOnContainer() const {
- aura::Window* window = widget()->GetNativeWindow();
- gfx::Insets inset(kResizeInsideBoundsSize, kResizeInsideBoundsSize,
- kResizeInsideBoundsSize, kResizeInsideBoundsSize);
- // Add the EasyResizeWindowTargeter on the window, not its root window. The
- // root window does not have a delegate, which is needed to handle the event
- // in Linux.
- window->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
- new wm::EasyResizeWindowTargeter(window, inset, inset)));
+views::NonClientFrameView*
+ChromeNativeAppWindowViews::CreateStandardDesktopAppFrame() {
+ return views::WidgetDelegateView::CreateNonClientFrameView(widget());
}
apps::AppWindowFrameView*
-ChromeNativeAppWindowViews::CreateAppWindowFrameView() {
- // By default the user can resize the window from slightly inside the bounds.
- int resize_inside_bounds_size = kResizeInsideBoundsSize;
- int resize_outside_bounds_size = 0;
- int resize_outside_scale_for_touch = 1;
- int resize_area_corner_size = kResizeAreaCornerSize;
+ChromeNativeAppWindowViews::CreateNonStandardAppFrame() {
+ apps::AppWindowFrameView* frame = new apps::AppWindowFrameView(
+ widget(), this, has_frame_color_, frame_color_);
+ frame->Init();
#if defined(USE_ASH)
// For Aura windows on the Ash desktop the sizes are different and the user
// can resize the window from slightly outside the bounds as well.
if (chrome::IsNativeWindowInAsh(widget()->GetNativeWindow())) {
- resize_inside_bounds_size = ash::kResizeInsideBoundsSize;
- resize_outside_bounds_size = ash::kResizeOutsideBoundsSize;
- resize_outside_scale_for_touch = ash::kResizeOutsideBoundsScaleForTouch;
- resize_area_corner_size = ash::kResizeAreaCornerSize;
+ frame->SetResizeSizes(ash::kResizeInsideBoundsSize,
+ ash::kResizeOutsideBoundsSize,
+ ash::kResizeAreaCornerSize);
+ }
+#endif
+
+#if !defined(OS_CHROMEOS)
+ // For non-Ash windows, install an easy resize window targeter, which ensures
+ // that the root window (not the app) receives mouse events on the edges.
+ if (chrome::GetHostDesktopTypeForNativeWindow(widget()->GetNativeWindow()) !=
+ chrome::HOST_DESKTOP_TYPE_ASH) {
+ aura::Window* window = widget()->GetNativeWindow();
+ int resize_inside = frame->resize_inside_bounds_size();
+ gfx::Insets inset(
+ resize_inside, resize_inside, resize_inside, resize_inside);
+ // Add the EasyResizeWindowTargeter on the window, not its root window. The
+ // root window does not have a delegate, which is needed to handle the event
+ // in Linux.
+ window->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
+ new wm::EasyResizeWindowTargeter(window, inset, inset)));
}
#endif
- apps::AppWindowFrameView* frame_view = new apps::AppWindowFrameView();
- frame_view->Init(widget(),
- this,
- has_frame_color_,
- frame_color_,
- resize_inside_bounds_size,
- resize_outside_bounds_size,
- resize_outside_scale_for_touch,
- resize_area_corner_size);
- return frame_view;
+
+ return frame;
}
// ui::BaseWindow implementation.
@@ -510,26 +504,33 @@ views::NonClientFrameView* ChromeNativeAppWindowViews::CreateNonClientFrameView(
return frame_view;
}
- if (!IsFrameless()) {
- ash::CustomFrameViewAsh* custom_frame_view =
- new ash::CustomFrameViewAsh(widget);
- // Non-frameless app windows can be put into immersive fullscreen.
- immersive_fullscreen_controller_.reset(
- new ash::ImmersiveFullscreenController());
- custom_frame_view->InitImmersiveFullscreenControllerForView(
- immersive_fullscreen_controller_.get());
- custom_frame_view->GetHeaderView()->set_context_menu_controller(this);
- return custom_frame_view;
- }
+ if (IsFrameless())
+ return CreateNonStandardAppFrame();
+
+ ash::CustomFrameViewAsh* custom_frame_view =
+ new ash::CustomFrameViewAsh(widget);
+#if defined(OS_CHROMEOS)
+ // Non-frameless app windows can be put into immersive fullscreen.
+ // TODO(pkotwicz): Investigate if immersive fullscreen can be enabled for
+ // Windows Ash.
+ immersive_fullscreen_controller_.reset(
+ new ash::ImmersiveFullscreenController());
+ custom_frame_view->InitImmersiveFullscreenControllerForView(
+ immersive_fullscreen_controller_.get());
+#endif
+ custom_frame_view->GetHeaderView()->set_context_menu_controller(this);
+ return custom_frame_view;
}
#endif
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
- return CreateAppWindowFrameView();
+ // Linux always uses the non standard frame view because the OS draws the
+ // frame (if a frame is needed).
+ return CreateNonStandardAppFrame();
#else
if (IsFrameless() || has_frame_color_)
- return CreateAppWindowFrameView();
+ return CreateNonStandardAppFrame();
#endif
- return views::WidgetDelegateView::CreateNonClientFrameView(widget);
+ return CreateStandardDesktopAppFrame();
}
bool ChromeNativeAppWindowViews::WidgetHasHitTestMask() const {
@@ -685,12 +686,4 @@ void ChromeNativeAppWindowViews::InitializeWindow(
widget()->GetFocusManager(),
extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY,
NULL));
-
-#if !defined(OS_CHROMEOS)
- if ((IsFrameless() || has_frame_color_) &&
- chrome::GetHostDesktopTypeForNativeWindow(widget()->GetNativeWindow()) !=
- chrome::HOST_DESKTOP_TYPE_ASH) {
- InstallEasyResizeTargeterOnContainer();
- }
-#endif
}

Powered by Google App Engine
This is Rietveld 408576698