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

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

Issue 667923002: Standardize usage of virtual/override/final in ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « ui/app_list/cocoa/apps_search_results_model_bridge.h ('k') | ui/app_list/pagination_model.h » ('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 "ui/app_list/cocoa/apps_search_results_model_bridge.h" 5 #import "ui/app_list/cocoa/apps_search_results_model_bridge.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "ui/app_list/app_list_model.h" 10 #include "ui/app_list/app_list_model.h"
11 #import "ui/app_list/cocoa/apps_search_results_controller.h" 11 #import "ui/app_list/cocoa/apps_search_results_controller.h"
12 #include "ui/app_list/search_result.h" 12 #include "ui/app_list/search_result.h"
13 #include "ui/app_list/search_result_observer.h" 13 #include "ui/app_list/search_result_observer.h"
14 #import "ui/base/cocoa/menu_controller.h" 14 #import "ui/base/cocoa/menu_controller.h"
15 15
16 namespace app_list { 16 namespace app_list {
17 17
18 class AppsSearchResultsModelBridge::ItemObserver : public SearchResultObserver { 18 class AppsSearchResultsModelBridge::ItemObserver : public SearchResultObserver {
19 public: 19 public:
20 ItemObserver(AppsSearchResultsModelBridge* bridge, size_t index) 20 ItemObserver(AppsSearchResultsModelBridge* bridge, size_t index)
21 : bridge_(bridge), row_in_view_(index) { 21 : bridge_(bridge), row_in_view_(index) {
22 // Cache the result, because the results array is updated before notifying 22 // Cache the result, because the results array is updated before notifying
23 // observers (which happens before deleting the SearchResult). 23 // observers (which happens before deleting the SearchResult).
24 result_ = [bridge_->parent_ results]->GetItemAt(index); 24 result_ = [bridge_->parent_ results]->GetItemAt(index);
25 result_->AddObserver(this); 25 result_->AddObserver(this);
26 } 26 }
27 27
28 virtual ~ItemObserver() { 28 ~ItemObserver() override { result_->RemoveObserver(this); }
29 result_->RemoveObserver(this);
30 }
31 29
32 NSMenu* GetContextMenu() { 30 NSMenu* GetContextMenu() {
33 if (!context_menu_controller_) { 31 if (!context_menu_controller_) {
34 ui::MenuModel* menu_model = result_->GetContextMenuModel(); 32 ui::MenuModel* menu_model = result_->GetContextMenuModel();
35 if (!menu_model) 33 if (!menu_model)
36 return nil; 34 return nil;
37 35
38 context_menu_controller_.reset( 36 context_menu_controller_.reset(
39 [[MenuController alloc] initWithModel:menu_model 37 [[MenuController alloc] initWithModel:menu_model
40 useWithPopUpButtonCell:NO]); 38 useWithPopUpButtonCell:NO]);
41 } 39 }
42 return [context_menu_controller_ menu]; 40 return [context_menu_controller_ menu];
43 } 41 }
44 42
45 // SearchResultObserver overrides: 43 // SearchResultObserver overrides:
46 virtual void OnIconChanged() override { 44 void OnIconChanged() override {
47 bridge_->ReloadDataForItems(row_in_view_, 1); 45 bridge_->ReloadDataForItems(row_in_view_, 1);
48 } 46 }
49 virtual void OnActionsChanged() override {} 47 void OnActionsChanged() override {}
50 virtual void OnIsInstallingChanged() override {} 48 void OnIsInstallingChanged() override {}
51 virtual void OnPercentDownloadedChanged() override {} 49 void OnPercentDownloadedChanged() override {}
52 virtual void OnItemInstalled() override {} 50 void OnItemInstalled() override {}
53 virtual void OnItemUninstalled() override; 51 void OnItemUninstalled() override;
54 52
55 private: 53 private:
56 AppsSearchResultsModelBridge* bridge_; // Weak. Owns us. 54 AppsSearchResultsModelBridge* bridge_; // Weak. Owns us.
57 SearchResult* result_; // Weak. Owned by AppListModel::SearchResults. 55 SearchResult* result_; // Weak. Owned by AppListModel::SearchResults.
58 size_t row_in_view_; 56 size_t row_in_view_;
59 base::scoped_nsobject<MenuController> context_menu_controller_; 57 base::scoped_nsobject<MenuController> context_menu_controller_;
60 58
61 DISALLOW_COPY_AND_ASSIGN(ItemObserver); 59 DISALLOW_COPY_AND_ASSIGN(ItemObserver);
62 }; 60 };
63 61
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 126 }
129 127
130 void AppsSearchResultsModelBridge::ListItemsChanged( 128 void AppsSearchResultsModelBridge::ListItemsChanged(
131 size_t start, size_t count) { 129 size_t start, size_t count) {
132 item_observers_.clear(); 130 item_observers_.clear();
133 ReloadDataForItems(start, count); 131 ReloadDataForItems(start, count);
134 UpdateItemObservers(); 132 UpdateItemObservers();
135 } 133 }
136 134
137 } // namespace app_list 135 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/cocoa/apps_search_results_model_bridge.h ('k') | ui/app_list/pagination_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698