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

Side by Side Diff: ui/app_list/cocoa/apps_grid_controller.mm

Issue 17593006: mac: Update clients of scoped_nsobject.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iwyu, scoped_nsprotocol Created 7 years, 5 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 #import "ui/app_list/cocoa/apps_grid_controller.h" 5 #import "ui/app_list/cocoa/apps_grid_controller.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "ui/app_list/app_list_model.h" 8 #include "ui/app_list/app_list_model.h"
9 #include "ui/app_list/app_list_model_observer.h" 9 #include "ui/app_list/app_list_model_observer.h"
10 #include "ui/app_list/app_list_view_delegate.h" 10 #include "ui/app_list/app_list_view_delegate.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 - (void)userScrolling:(BOOL)isScrolling { 333 - (void)userScrolling:(BOOL)isScrolling {
334 if (isScrolling) { 334 if (isScrolling) {
335 if (animatingScroll_) 335 if (animatingScroll_)
336 [self cancelScrollAnimation]; 336 [self cancelScrollAnimation];
337 } else { 337 } else {
338 [self scrollToPage:[self nearestPageIndex]]; 338 [self scrollToPage:[self nearestPageIndex]];
339 } 339 }
340 } 340 }
341 341
342 - (void)loadAndSetView { 342 - (void)loadAndSetView {
343 scoped_nsobject<PageContainerView> pagesContainer( 343 base::scoped_nsobject<PageContainerView> pagesContainer(
344 [[PageContainerView alloc] initWithFrame:NSZeroRect]); 344 [[PageContainerView alloc] initWithFrame:NSZeroRect]);
345 345
346 NSRect scrollFrame = NSMakeRect(0, kGridTopPadding, kViewWidth, 346 NSRect scrollFrame = NSMakeRect(0, kGridTopPadding, kViewWidth,
347 kViewHeight + kScrollerPadding); 347 kViewHeight + kScrollerPadding);
348 scoped_nsobject<ScrollViewWithNoScrollbars> scrollView( 348 base::scoped_nsobject<ScrollViewWithNoScrollbars> scrollView(
349 [[ScrollViewWithNoScrollbars alloc] initWithFrame:scrollFrame]); 349 [[ScrollViewWithNoScrollbars alloc] initWithFrame:scrollFrame]);
350 [scrollView setBorderType:NSNoBorder]; 350 [scrollView setBorderType:NSNoBorder];
351 [scrollView setLineScroll:kViewWidth]; 351 [scrollView setLineScroll:kViewWidth];
352 [scrollView setPageScroll:kViewWidth]; 352 [scrollView setPageScroll:kViewWidth];
353 [scrollView setDelegate:self]; 353 [scrollView setDelegate:self];
354 [scrollView setDocumentView:pagesContainer]; 354 [scrollView setDocumentView:pagesContainer];
355 [scrollView setDrawsBackground:NO]; 355 [scrollView setDrawsBackground:NO];
356 356
357 [[NSNotificationCenter defaultCenter] 357 [[NSNotificationCenter defaultCenter]
358 addObserver:self 358 addObserver:self
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 for (size_t i = 0; i < [pageContent count]; ++i) { 492 for (size_t i = 0; i < [pageContent count]; ++i) {
493 AppsGridViewItem* item = base::mac::ObjCCastStrict<AppsGridViewItem>( 493 AppsGridViewItem* item = base::mac::ObjCCastStrict<AppsGridViewItem>(
494 [pageView itemAtIndex:i]); 494 [pageView itemAtIndex:i]);
495 [item setModel:static_cast<app_list::AppListItemModel*>( 495 [item setModel:static_cast<app_list::AppListItemModel*>(
496 [[pageContent objectAtIndex:i] pointerValue])]; 496 [[pageContent objectAtIndex:i] pointerValue])];
497 } 497 }
498 } 498 }
499 499
500 - (void)moveItemInView:(size_t)fromIndex 500 - (void)moveItemInView:(size_t)fromIndex
501 toItemIndex:(size_t)toIndex { 501 toItemIndex:(size_t)toIndex {
502 scoped_nsobject<NSValue> item([[items_ objectAtIndex:fromIndex] retain]); 502 base::scoped_nsobject<NSValue> item(
503 [[items_ objectAtIndex:fromIndex] retain]);
503 [items_ removeObjectAtIndex:fromIndex]; 504 [items_ removeObjectAtIndex:fromIndex];
504 [items_ insertObject:item 505 [items_ insertObject:item
505 atIndex:toIndex]; 506 atIndex:toIndex];
506 507
507 size_t fromPageIndex = fromIndex / kItemsPerPage; 508 size_t fromPageIndex = fromIndex / kItemsPerPage;
508 size_t toPageIndex = toIndex / kItemsPerPage; 509 size_t toPageIndex = toIndex / kItemsPerPage;
509 if (fromPageIndex == toPageIndex) { 510 if (fromPageIndex == toPageIndex) {
510 [self updatePageContent:fromPageIndex 511 [self updatePageContent:fromPageIndex
511 resetModel:NO]; // Just reorder items. 512 resetModel:NO]; // Just reorder items.
512 return; 513 return;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 return [self moveSelectionByDelta:-kItemsPerPage]; 678 return [self moveSelectionByDelta:-kItemsPerPage];
678 679
679 if (command == @selector(pageDown:) || 680 if (command == @selector(pageDown:) ||
680 command == @selector(scrollPageDown:)) 681 command == @selector(scrollPageDown:))
681 return [self moveSelectionByDelta:kItemsPerPage]; 682 return [self moveSelectionByDelta:kItemsPerPage];
682 683
683 return NO; 684 return NO;
684 } 685 }
685 686
686 @end 687 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698