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

Side by Side Diff: chrome/browser/ui/app_list/app_list_service_mac.mm

Issue 1938473002: Rename gfx::Display/Screen to display::Display/Screen in chrome/content/extensions mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_service_mac_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #import "chrome/browser/ui/app_list/app_list_service_mac.h" 5 #import "chrome/browser/ui/app_list/app_list_service_mac.h"
6 6
7 #include <ApplicationServices/ApplicationServices.h> 7 #include <ApplicationServices/ApplicationServices.h>
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "components/version_info/version_info.h" 42 #include "components/version_info/version_info.h"
43 #include "content/public/browser/browser_thread.h" 43 #include "content/public/browser/browser_thread.h"
44 #include "extensions/browser/extension_system.h" 44 #include "extensions/browser/extension_system.h"
45 #include "extensions/common/manifest_handlers/file_handler_info.h" 45 #include "extensions/common/manifest_handlers/file_handler_info.h"
46 #include "grit/chrome_unscaled_resources.h" 46 #include "grit/chrome_unscaled_resources.h"
47 #include "net/base/url_util.h" 47 #include "net/base/url_util.h"
48 #include "ui/app_list/app_list_switches.h" 48 #include "ui/app_list/app_list_switches.h"
49 #include "ui/app_list/search_box_model.h" 49 #include "ui/app_list/search_box_model.h"
50 #include "ui/base/l10n/l10n_util.h" 50 #include "ui/base/l10n/l10n_util.h"
51 #include "ui/base/resource/resource_bundle.h" 51 #include "ui/base/resource/resource_bundle.h"
52 #include "ui/gfx/display.h" 52 #include "ui/display/display.h"
53 #include "ui/gfx/screen.h" 53 #include "ui/display/screen.h"
54 54
55 namespace gfx { 55 namespace gfx {
56 class ImageSkia; 56 class ImageSkia;
57 } 57 }
58 58
59 // Controller for animations that show or hide the app list. 59 // Controller for animations that show or hide the app list.
60 @interface AppListAnimationController : NSObject<NSAnimationDelegate> { 60 @interface AppListAnimationController : NSObject<NSAnimationDelegate> {
61 @private 61 @private
62 // When closing, the window to close. Retained until the animation ends. 62 // When closing, the window to close. Retained until the animation ends.
63 base::scoped_nsobject<NSWindow> window_; 63 base::scoped_nsobject<NSWindow> window_;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 return nil; // Chrome is active. 172 return nil; // Chrome is active.
173 173
174 return application; 174 return application;
175 } 175 }
176 176
177 return nil; 177 return nil;
178 } 178 }
179 179
180 // Determines which screen edge the dock is aligned to. 180 // Determines which screen edge the dock is aligned to.
181 AppListPositioner::ScreenEdge DockLocationInDisplay( 181 AppListPositioner::ScreenEdge DockLocationInDisplay(
182 const gfx::Display& display) { 182 const display::Display& display) {
183 // Assume the dock occupies part of the work area either on the left, right or 183 // Assume the dock occupies part of the work area either on the left, right or
184 // bottom of the display. Note in the autohide case, it is always 4 pixels. 184 // bottom of the display. Note in the autohide case, it is always 4 pixels.
185 const gfx::Rect work_area = display.work_area(); 185 const gfx::Rect work_area = display.work_area();
186 const gfx::Rect display_bounds = display.bounds(); 186 const gfx::Rect display_bounds = display.bounds();
187 if (work_area.bottom() != display_bounds.bottom()) 187 if (work_area.bottom() != display_bounds.bottom())
188 return AppListPositioner::SCREEN_EDGE_BOTTOM; 188 return AppListPositioner::SCREEN_EDGE_BOTTOM;
189 189
190 if (work_area.x() != display_bounds.x()) 190 if (work_area.x() != display_bounds.x())
191 return AppListPositioner::SCREEN_EDGE_LEFT; 191 return AppListPositioner::SCREEN_EDGE_LEFT;
192 192
193 if (work_area.right() != display_bounds.right()) 193 if (work_area.right() != display_bounds.right())
194 return AppListPositioner::SCREEN_EDGE_RIGHT; 194 return AppListPositioner::SCREEN_EDGE_RIGHT;
195 195
196 return AppListPositioner::SCREEN_EDGE_UNKNOWN; 196 return AppListPositioner::SCREEN_EDGE_UNKNOWN;
197 } 197 }
198 198
199 // If |display|'s work area is too close to its boundary on |dock_edge|, adjust 199 // If |display|'s work area is too close to its boundary on |dock_edge|, adjust
200 // the work area away from the edge by a constant amount to reduce overlap and 200 // the work area away from the edge by a constant amount to reduce overlap and
201 // ensure the dock icon can still be clicked to dismiss the app list. 201 // ensure the dock icon can still be clicked to dismiss the app list.
202 void AdjustWorkAreaForDock(const gfx::Display& display, 202 void AdjustWorkAreaForDock(const display::Display& display,
203 AppListPositioner* positioner, 203 AppListPositioner* positioner,
204 AppListPositioner::ScreenEdge dock_edge) { 204 AppListPositioner::ScreenEdge dock_edge) {
205 const int kAutohideDockThreshold = 10; 205 const int kAutohideDockThreshold = 10;
206 const int kExtraDistance = 50; // A dock with 40 items is about this size. 206 const int kExtraDistance = 50; // A dock with 40 items is about this size.
207 207
208 const gfx::Rect work_area = display.work_area(); 208 const gfx::Rect work_area = display.work_area();
209 const gfx::Rect display_bounds = display.bounds(); 209 const gfx::Rect display_bounds = display.bounds();
210 210
211 switch (dock_edge) { 211 switch (dock_edge) {
212 case AppListPositioner::SCREEN_EDGE_LEFT: 212 case AppListPositioner::SCREEN_EDGE_LEFT:
(...skipping 12 matching lines...) Expand all
225 break; 225 break;
226 case AppListPositioner::SCREEN_EDGE_UNKNOWN: 226 case AppListPositioner::SCREEN_EDGE_UNKNOWN:
227 case AppListPositioner::SCREEN_EDGE_TOP: 227 case AppListPositioner::SCREEN_EDGE_TOP:
228 NOTREACHED(); 228 NOTREACHED();
229 break; 229 break;
230 } 230 }
231 } 231 }
232 232
233 void GetAppListWindowOrigins( 233 void GetAppListWindowOrigins(
234 NSWindow* window, NSPoint* target_origin, NSPoint* start_origin) { 234 NSWindow* window, NSPoint* target_origin, NSPoint* start_origin) {
235 gfx::Screen* const screen = gfx::Screen::GetScreen(); 235 display::Screen* const screen = display::Screen::GetScreen();
236 // Ensure y coordinates are flipped back into AppKit's coordinate system. 236 // Ensure y coordinates are flipped back into AppKit's coordinate system.
237 bool cursor_is_visible = CGCursorIsVisible(); 237 bool cursor_is_visible = CGCursorIsVisible();
238 gfx::Display display; 238 display::Display display;
239 gfx::Point cursor; 239 gfx::Point cursor;
240 if (!cursor_is_visible) { 240 if (!cursor_is_visible) {
241 // If Chrome is the active application, display on the same display as 241 // If Chrome is the active application, display on the same display as
242 // Chrome's keyWindow since this will catch activations triggered, e.g, via 242 // Chrome's keyWindow since this will catch activations triggered, e.g, via
243 // WebStore install. If another application is active, OSX doesn't provide a 243 // WebStore install. If another application is active, OSX doesn't provide a
244 // reliable way to get the display in use. Fall back to the primary display 244 // reliable way to get the display in use. Fall back to the primary display
245 // since it has the menu bar and is likely to be correct, e.g., for 245 // since it has the menu bar and is likely to be correct, e.g., for
246 // activations from Spotlight. 246 // activations from Spotlight.
247 const gfx::NativeView key_view = [[NSApp keyWindow] contentView]; 247 const gfx::NativeView key_view = [[NSApp keyWindow] contentView];
248 display = key_view && [NSApp isActive] ? 248 display = key_view && [NSApp isActive] ?
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } // namespace 280 } // namespace
281 281
282 AppListServiceMac::AppListServiceMac() { 282 AppListServiceMac::AppListServiceMac() {
283 animation_controller_.reset([[AppListAnimationController alloc] init]); 283 animation_controller_.reset([[AppListAnimationController alloc] init]);
284 } 284 }
285 285
286 AppListServiceMac::~AppListServiceMac() {} 286 AppListServiceMac::~AppListServiceMac() {}
287 287
288 // static 288 // static
289 void AppListServiceMac::FindAnchorPoint(const gfx::Size& window_size, 289 void AppListServiceMac::FindAnchorPoint(const gfx::Size& window_size,
290 const gfx::Display& display, 290 const display::Display& display,
291 int primary_display_height, 291 int primary_display_height,
292 bool cursor_is_visible, 292 bool cursor_is_visible,
293 const gfx::Point& cursor, 293 const gfx::Point& cursor,
294 NSPoint* target_origin, 294 NSPoint* target_origin,
295 NSPoint* start_origin) { 295 NSPoint* start_origin) {
296 AppListPositioner positioner(display, window_size, 0); 296 AppListPositioner positioner(display, window_size, 0);
297 AppListPositioner::ScreenEdge dock_location = DockLocationInDisplay(display); 297 AppListPositioner::ScreenEdge dock_location = DockLocationInDisplay(display);
298 298
299 gfx::Point anchor; 299 gfx::Point anchor;
300 // Snap to the dock edge. If the cursor is greater than the window 300 // Snap to the dock edge. If the cursor is greater than the window
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 583
584 - (void)animationDidEnd:(NSAnimation*)animation { 584 - (void)animationDidEnd:(NSAnimation*)animation {
585 content::BrowserThread::PostTask( 585 content::BrowserThread::PostTask(
586 content::BrowserThread::UI, 586 content::BrowserThread::UI,
587 FROM_HERE, 587 FROM_HERE,
588 base::Bind(&AppListServiceMac::WindowAnimationDidEnd, 588 base::Bind(&AppListServiceMac::WindowAnimationDidEnd,
589 base::Unretained(GetActiveInstance()))); 589 base::Unretained(GetActiveInstance())));
590 } 590 }
591 591
592 @end 592 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_service_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698