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

Side by Side Diff: chrome/browser/ui/views/apps/chrome_native_app_window_views_mac.mm

Issue 1146873002: [MacViews] Enable dragging a window by its caption/draggable areas. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change to single repost and [NSWindow setMovableByWindowBackground]. Created 5 years, 6 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #import "chrome/browser/ui/views/apps/chrome_native_app_window_views_mac.h" 5 #import "chrome/browser/ui/views/apps/chrome_native_app_window_views_mac.h"
6 6
7 #import <Cocoa/Cocoa.h>
8
9 #import "base/mac/scoped_nsobject.h"
7 #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" 10 #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h"
8 #include "chrome/browser/ui/views/apps/app_window_native_widget_mac.h" 11 #import "chrome/browser/ui/views/apps/app_window_native_widget_mac.h"
9 #include "chrome/browser/ui/views/apps/native_app_window_frame_view_mac.h" 12 #import "chrome/browser/ui/views/apps/native_app_window_frame_view_mac.h"
13
14 @interface NSView (WebContentsView)
15 - (void)setMouseDownCanMoveWindow:(BOOL)can_move;
16 @end
10 17
11 ChromeNativeAppWindowViewsMac::ChromeNativeAppWindowViewsMac() 18 ChromeNativeAppWindowViewsMac::ChromeNativeAppWindowViewsMac()
12 : is_hidden_with_app_(false) { 19 : is_hidden_with_app_(false) {
13 } 20 }
14 21
15 ChromeNativeAppWindowViewsMac::~ChromeNativeAppWindowViewsMac() { 22 ChromeNativeAppWindowViewsMac::~ChromeNativeAppWindowViewsMac() {
16 } 23 }
17 24
18 void ChromeNativeAppWindowViewsMac::OnBeforeWidgetInit( 25 void ChromeNativeAppWindowViewsMac::OnBeforeWidgetInit(
19 const extensions::AppWindow::CreateParams& create_params, 26 const extensions::AppWindow::CreateParams& create_params,
20 views::Widget::InitParams* init_params, 27 views::Widget::InitParams* init_params,
21 views::Widget* widget) { 28 views::Widget* widget) {
22 DCHECK(!init_params->native_widget); 29 DCHECK(!init_params->native_widget);
23 init_params->remove_standard_frame = IsFrameless(); 30 init_params->remove_standard_frame = IsFrameless();
24 init_params->native_widget = new AppWindowNativeWidgetMac(widget, this); 31 init_params->native_widget = new AppWindowNativeWidgetMac(widget, this);
25 ChromeNativeAppWindowViews::OnBeforeWidgetInit(create_params, init_params, 32 ChromeNativeAppWindowViews::OnBeforeWidgetInit(create_params, init_params,
26 widget); 33 widget);
27 } 34 }
28 35
29 views::NonClientFrameView* 36 views::NonClientFrameView*
30 ChromeNativeAppWindowViewsMac::CreateStandardDesktopAppFrame() { 37 ChromeNativeAppWindowViewsMac::CreateStandardDesktopAppFrame() {
31 return new NativeAppWindowFrameViewMac(widget()); 38 return new NativeAppWindowFrameViewMac(widget(), this);
32 } 39 }
33 40
34 views::NonClientFrameView* 41 views::NonClientFrameView*
35 ChromeNativeAppWindowViewsMac::CreateNonStandardAppFrame() { 42 ChromeNativeAppWindowViewsMac::CreateNonStandardAppFrame() {
36 return new NativeAppWindowFrameViewMac(widget()); 43 return new NativeAppWindowFrameViewMac(widget(), this);
37 } 44 }
38 45
39 void ChromeNativeAppWindowViewsMac::Show() { 46 void ChromeNativeAppWindowViewsMac::Show() {
40 if (is_hidden_with_app_) { 47 if (is_hidden_with_app_) {
41 // If there is a shim to gently request attention, return here. Otherwise 48 // If there is a shim to gently request attention, return here. Otherwise
42 // show the window as usual. 49 // show the window as usual.
43 if (apps::ExtensionAppShimHandler::ActivateAndRequestUserAttentionForWindow( 50 if (apps::ExtensionAppShimHandler::ActivateAndRequestUserAttentionForWindow(
44 app_window())) { 51 app_window())) {
45 return; 52 return;
46 } 53 }
47 } 54 }
48 55
49 ChromeNativeAppWindowViews::Show(); 56 ChromeNativeAppWindowViews::Show();
50 } 57 }
51 58
52 void ChromeNativeAppWindowViewsMac::ShowInactive() { 59 void ChromeNativeAppWindowViewsMac::ShowInactive() {
53 if (is_hidden_with_app_) 60 if (is_hidden_with_app_)
54 return; 61 return;
55 62
56 ChromeNativeAppWindowViews::ShowInactive(); 63 ChromeNativeAppWindowViews::ShowInactive();
57 } 64 }
58 65
59 void ChromeNativeAppWindowViewsMac::FlashFrame(bool flash) { 66 void ChromeNativeAppWindowViewsMac::FlashFrame(bool flash) {
60 apps::ExtensionAppShimHandler::RequestUserAttentionForWindow( 67 apps::ExtensionAppShimHandler::RequestUserAttentionForWindow(
61 app_window(), flash ? apps::APP_SHIM_ATTENTION_CRITICAL 68 app_window(), flash ? apps::APP_SHIM_ATTENTION_CRITICAL
62 : apps::APP_SHIM_ATTENTION_CANCEL); 69 : apps::APP_SHIM_ATTENTION_CANCEL);
63 } 70 }
64 71
72 void ChromeNativeAppWindowViewsMac::UpdateDraggableRegions(
73 const std::vector<extensions::DraggableRegion>& regions) {
74 ChromeNativeAppWindowViews::UpdateDraggableRegions(regions);
75
76 NSView* web_contents_view = app_window()->web_contents()->GetNativeView();
77 [web_contents_view setMouseDownCanMoveWindow:YES];
78 }
79
65 void ChromeNativeAppWindowViewsMac::ShowWithApp() { 80 void ChromeNativeAppWindowViewsMac::ShowWithApp() {
66 is_hidden_with_app_ = false; 81 is_hidden_with_app_ = false;
67 if (!app_window()->is_hidden()) 82 if (!app_window()->is_hidden())
68 ShowInactive(); 83 ShowInactive();
69 } 84 }
70 85
71 void ChromeNativeAppWindowViewsMac::HideWithApp() { 86 void ChromeNativeAppWindowViewsMac::HideWithApp() {
72 is_hidden_with_app_ = true; 87 is_hidden_with_app_ = true;
73 ChromeNativeAppWindowViews::Hide(); 88 ChromeNativeAppWindowViews::Hide();
74 } 89 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698