OLD | NEW |
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_view_item.h" | 5 #import "ui/app_list/cocoa/apps_grid_view_item.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
11 #include "skia/ext/skia_utils_mac.h" | 11 #include "skia/ext/skia_utils_mac.h" |
12 #include "ui/app_list/app_list_constants.h" | 12 #include "ui/app_list/app_list_constants.h" |
13 #include "ui/app_list/app_list_item.h" | 13 #include "ui/app_list/app_list_item.h" |
14 #include "ui/app_list/app_list_item_observer.h" | 14 #include "ui/app_list/app_list_item_observer.h" |
15 #import "ui/app_list/cocoa/apps_grid_controller.h" | 15 #import "ui/app_list/cocoa/apps_grid_controller.h" |
| 16 #import "ui/app_list/cocoa/apps_pagination_model_observer.h" |
16 #import "ui/base/cocoa/menu_controller.h" | 17 #import "ui/base/cocoa/menu_controller.h" |
17 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
18 #include "ui/gfx/font.h" | 19 #include "ui/gfx/font.h" |
19 #include "ui/gfx/image/image_skia_operations.h" | 20 #include "ui/gfx/image/image_skia_operations.h" |
20 #include "ui/gfx/image/image_skia_util_mac.h" | 21 #include "ui/gfx/image/image_skia_util_mac.h" |
21 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 22 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 // Padding from the top of the tile to the top of the app icon. | 26 // Padding from the top of the tile to the top of the app icon. |
(...skipping 20 matching lines...) Expand all Loading... |
46 // Bridged methods from app_list::AppListItemObserver: | 47 // Bridged methods from app_list::AppListItemObserver: |
47 // Update the title, correctly setting the color if the button is highlighted. | 48 // Update the title, correctly setting the color if the button is highlighted. |
48 - (void)updateButtonTitle; | 49 - (void)updateButtonTitle; |
49 | 50 |
50 // Update the button image after ensuring its dimensions are |kIconSize|. | 51 // Update the button image after ensuring its dimensions are |kIconSize|. |
51 - (void)updateButtonImage; | 52 - (void)updateButtonImage; |
52 | 53 |
53 // Ensure the page this item is on is the visible page in the grid. | 54 // Ensure the page this item is on is the visible page in the grid. |
54 - (void)ensureVisible; | 55 - (void)ensureVisible; |
55 | 56 |
56 // Add or remove a progress bar from the view. | 57 // Adds a progress bar to the view if |isInstalling|, otherwise removes it. |
57 - (void)setItemIsInstalling:(BOOL)isInstalling; | 58 - (void)setItemIsInstalling:(BOOL)isInstalling; |
58 | 59 |
59 // Update the progress bar to represent |percent|, or make it indeterminate if | 60 // Update the progress bar to represent |percent|, or make it indeterminate if |
60 // |percent| is -1, when unpacking begins. | 61 // |percent| is -1, when unpacking begins. |
61 - (void)setPercentDownloaded:(int)percent; | 62 - (void)setPercentDownloaded:(int)percent; |
62 | 63 |
63 @end | 64 @end |
64 | 65 |
65 namespace app_list { | 66 namespace app_list { |
66 | 67 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 [button setHidden:YES]; | 382 [button setHidden:YES]; |
382 return imageRep; | 383 return imageRep; |
383 } | 384 } |
384 | 385 |
385 - (void)ensureVisible { | 386 - (void)ensureVisible { |
386 NSCollectionView* collectionView = [self collectionView]; | 387 NSCollectionView* collectionView = [self collectionView]; |
387 AppsGridController* gridController = | 388 AppsGridController* gridController = |
388 base::mac::ObjCCastStrict<AppsGridController>([collectionView delegate]); | 389 base::mac::ObjCCastStrict<AppsGridController>([collectionView delegate]); |
389 size_t pageIndex = [gridController pageIndexForCollectionView:collectionView]; | 390 size_t pageIndex = [gridController pageIndexForCollectionView:collectionView]; |
390 [gridController scrollToPage:pageIndex]; | 391 [gridController scrollToPage:pageIndex]; |
| 392 |
| 393 // If the item just completed a user-initiated install, additionally clear |
| 394 // search results to reveal the item in the grid. |
| 395 if ([self model]->percent_downloaded() == -1) |
| 396 [[gridController paginationObserver] ensureAppsPagesVisible]; |
391 } | 397 } |
392 | 398 |
393 - (void)setItemIsInstalling:(BOOL)isInstalling { | 399 - (void)setItemIsInstalling:(BOOL)isInstalling { |
394 if (!isInstalling == !progressIndicator_) | 400 if (!isInstalling == !progressIndicator_) |
395 return; | 401 return; |
396 | 402 |
397 [self ensureVisible]; | 403 [self ensureVisible]; |
398 if (!isInstalling) { | 404 if (!isInstalling) { |
399 [progressIndicator_ removeFromSuperview]; | 405 [progressIndicator_ removeFromSuperview]; |
400 progressIndicator_.reset(); | 406 progressIndicator_.reset(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 } | 495 } |
490 | 496 |
491 // Workaround for http://crbug.com/324365: AppKit in Mavericks tries to call | 497 // Workaround for http://crbug.com/324365: AppKit in Mavericks tries to call |
492 // - [NSButtonCell item] when inspecting accessibility. Without this, an | 498 // - [NSButtonCell item] when inspecting accessibility. Without this, an |
493 // unrecognized selector exception is thrown inside AppKit, crashing Chrome. | 499 // unrecognized selector exception is thrown inside AppKit, crashing Chrome. |
494 - (id)item { | 500 - (id)item { |
495 return nil; | 501 return nil; |
496 } | 502 } |
497 | 503 |
498 @end | 504 @end |
OLD | NEW |