| 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/app_list_view_controller.h" | 5 #import "ui/app_list/cocoa/app_list_view_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "skia/ext/skia_utils_mac.h" | 10 #include "skia/ext/skia_utils_mac.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 @interface AppListViewController () | 75 @interface AppListViewController () |
| 76 | 76 |
| 77 - (void)loadAndSetView; | 77 - (void)loadAndSetView; |
| 78 - (void)revealSearchResults:(BOOL)show; | 78 - (void)revealSearchResults:(BOOL)show; |
| 79 | 79 |
| 80 @end | 80 @end |
| 81 | 81 |
| 82 namespace app_list { | 82 namespace app_list { |
| 83 | 83 |
| 84 class AppListModelObserverBridge : public AppListModelObserver { | 84 class AppListModelObserverBridge : public AppListModelObserver, |
| 85 public AppListViewDelegateObserver { |
| 85 public: | 86 public: |
| 86 AppListModelObserverBridge(AppListViewController* parent); | 87 AppListModelObserverBridge(AppListViewController* parent); |
| 87 virtual ~AppListModelObserverBridge(); | 88 virtual ~AppListModelObserverBridge(); |
| 88 | 89 |
| 89 private: | 90 private: |
| 90 // Overridden from app_list::AppListModelObserver: | 91 // Overridden from app_list::AppListModelObserver: |
| 91 virtual void OnAppListModelSigninStatusChanged() OVERRIDE; | 92 virtual void OnAppListModelSigninStatusChanged() OVERRIDE; |
| 92 | 93 |
| 94 // Overridden from app_list::AppListViewDelegateObserver: |
| 95 virtual void OnUsersChanged() OVERRIDE; |
| 96 |
| 93 AppListViewController* parent_; // Weak. Owns us. | 97 AppListViewController* parent_; // Weak. Owns us. |
| 94 | 98 |
| 95 DISALLOW_COPY_AND_ASSIGN(AppListModelObserverBridge); | 99 DISALLOW_COPY_AND_ASSIGN(AppListModelObserverBridge); |
| 96 }; | 100 }; |
| 97 | 101 |
| 98 AppListModelObserverBridge::AppListModelObserverBridge( | 102 AppListModelObserverBridge::AppListModelObserverBridge( |
| 99 AppListViewController* parent) | 103 AppListViewController* parent) |
| 100 : parent_(parent) { | 104 : parent_(parent) { |
| 101 [[parent_ appsGridController] model]->AddObserver(this); | 105 [[parent_ appsGridController] model]->AddObserver(this); |
| 106 [parent_ delegate]->AddObserver(this); |
| 102 } | 107 } |
| 103 | 108 |
| 104 AppListModelObserverBridge::~AppListModelObserverBridge() { | 109 AppListModelObserverBridge::~AppListModelObserverBridge() { |
| 105 [[parent_ appsGridController] model]->RemoveObserver(this); | 110 [[parent_ appsGridController] model]->RemoveObserver(this); |
| 111 [parent_ delegate]->RemoveObserver(this); |
| 106 } | 112 } |
| 107 | 113 |
| 108 void AppListModelObserverBridge::OnAppListModelSigninStatusChanged() { | 114 void AppListModelObserverBridge::OnAppListModelSigninStatusChanged() { |
| 109 [parent_ onSigninStatusChanged]; | 115 [parent_ onSigninStatusChanged]; |
| 110 } | 116 } |
| 111 | 117 |
| 118 void AppListModelObserverBridge::OnUsersChanged() { |
| 119 [[parent_ appsSearchBoxController] rebuildMenu]; |
| 120 } |
| 121 |
| 112 } // namespace app_list | 122 } // namespace app_list |
| 113 | 123 |
| 114 @implementation AppListViewController | 124 @implementation AppListViewController |
| 115 | 125 |
| 116 - (id)init { | 126 - (id)init { |
| 117 if ((self = [super init])) { | 127 if ((self = [super init])) { |
| 118 appsGridController_.reset([[AppsGridController alloc] init]); | 128 appsGridController_.reset([[AppsGridController alloc] init]); |
| 119 [self loadAndSetView]; | 129 [self loadAndSetView]; |
| 120 | 130 |
| 121 [self totalPagesChanged]; | 131 [self totalPagesChanged]; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 if (!delegate_) | 172 if (!delegate_) |
| 163 return; | 173 return; |
| 164 [appsGridController_ setDelegate:delegate_.get()]; | 174 [appsGridController_ setDelegate:delegate_.get()]; |
| 165 [appsSearchBoxController_ setDelegate:self]; | 175 [appsSearchBoxController_ setDelegate:self]; |
| 166 [appsSearchResultsController_ setDelegate:self]; | 176 [appsSearchResultsController_ setDelegate:self]; |
| 167 app_list_model_observer_bridge_.reset( | 177 app_list_model_observer_bridge_.reset( |
| 168 new app_list::AppListModelObserverBridge(self)); | 178 new app_list::AppListModelObserverBridge(self)); |
| 169 [self onSigninStatusChanged]; | 179 [self onSigninStatusChanged]; |
| 170 } | 180 } |
| 171 | 181 |
| 182 - (AppsSearchBoxController*)appsSearchBoxController { |
| 183 return appsSearchBoxController_; |
| 184 } |
| 185 |
| 172 -(void)loadAndSetView { | 186 -(void)loadAndSetView { |
| 173 pagerControl_.reset([[AppListPagerView alloc] init]); | 187 pagerControl_.reset([[AppListPagerView alloc] init]); |
| 174 [pagerControl_ setTarget:appsGridController_]; | 188 [pagerControl_ setTarget:appsGridController_]; |
| 175 [pagerControl_ setAction:@selector(onPagerClicked:)]; | 189 [pagerControl_ setAction:@selector(onPagerClicked:)]; |
| 176 | 190 |
| 177 NSRect gridFrame = [[appsGridController_ view] frame]; | 191 NSRect gridFrame = [[appsGridController_ view] frame]; |
| 178 NSRect contentsRect = NSMakeRect(0, kSearchInputHeight + kTopSeparatorSize, | 192 NSRect contentsRect = NSMakeRect(0, kSearchInputHeight + kTopSeparatorSize, |
| 179 NSWidth(gridFrame), NSHeight(gridFrame) + kPagerPreferredHeight - | 193 NSWidth(gridFrame), NSHeight(gridFrame) + kPagerPreferredHeight - |
| 180 [AppsGridController scrollerPadding]); | 194 [AppsGridController scrollerPadding]); |
| 181 | 195 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 354 |
| 341 [backgroundView_ setHidden:YES]; | 355 [backgroundView_ setHidden:YES]; |
| 342 signinViewController_.reset( | 356 signinViewController_.reset( |
| 343 [[SigninViewController alloc] initWithFrame:[backgroundView_ frame] | 357 [[SigninViewController alloc] initWithFrame:[backgroundView_ frame] |
| 344 cornerRadius:kBubbleCornerRadius | 358 cornerRadius:kBubbleCornerRadius |
| 345 delegate:signinDelegate]); | 359 delegate:signinDelegate]); |
| 346 [[self view] addSubview:[signinViewController_ view]]; | 360 [[self view] addSubview:[signinViewController_ view]]; |
| 347 } | 361 } |
| 348 | 362 |
| 349 @end | 363 @end |
| OLD | NEW |