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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 namespace app_list { | 82 namespace app_list { |
83 | 83 |
84 class AppListModelObserverBridge : public AppListModelObserver { | 84 class AppListModelObserverBridge : public AppListModelObserver { |
85 public: | 85 public: |
86 AppListModelObserverBridge(AppListViewController* parent); | 86 AppListModelObserverBridge(AppListViewController* parent); |
87 virtual ~AppListModelObserverBridge(); | 87 virtual ~AppListModelObserverBridge(); |
88 | 88 |
89 private: | 89 private: |
90 // Overridden from app_list::AppListModelObserver: | 90 // Overridden from app_list::AppListModelObserver: |
91 virtual void OnAppListModelCurrentUserChanged() OVERRIDE; | 91 virtual void OnAppListModelUsersChanged() OVERRIDE; |
92 virtual void OnAppListModelSigninStatusChanged() OVERRIDE; | 92 virtual void OnAppListModelSigninStatusChanged() OVERRIDE; |
93 | 93 |
94 AppListViewController* parent_; // Weak. Owns us. | 94 AppListViewController* parent_; // Weak. Owns us. |
95 | 95 |
96 DISALLOW_COPY_AND_ASSIGN(AppListModelObserverBridge); | 96 DISALLOW_COPY_AND_ASSIGN(AppListModelObserverBridge); |
97 }; | 97 }; |
98 | 98 |
99 AppListModelObserverBridge::AppListModelObserverBridge( | 99 AppListModelObserverBridge::AppListModelObserverBridge( |
100 AppListViewController* parent) | 100 AppListViewController* parent) |
101 : parent_(parent) { | 101 : parent_(parent) { |
102 [[parent_ appsGridController] model]->AddObserver(this); | 102 [[parent_ appsGridController] model]->AddObserver(this); |
103 } | 103 } |
104 | 104 |
105 AppListModelObserverBridge::~AppListModelObserverBridge() { | 105 AppListModelObserverBridge::~AppListModelObserverBridge() { |
106 [[parent_ appsGridController] model]->RemoveObserver(this); | 106 [[parent_ appsGridController] model]->RemoveObserver(this); |
107 } | 107 } |
108 | 108 |
109 void AppListModelObserverBridge::OnAppListModelCurrentUserChanged() { | 109 void AppListModelObserverBridge::OnAppListModelUsersChanged() { |
110 [parent_ onSigninStatusChanged]; | 110 [parent_ onSigninStatusChanged]; |
111 } | 111 } |
112 | 112 |
113 void AppListModelObserverBridge::OnAppListModelSigninStatusChanged() { | 113 void AppListModelObserverBridge::OnAppListModelSigninStatusChanged() { |
114 [parent_ onSigninStatusChanged]; | 114 [parent_ onSigninStatusChanged]; |
115 } | 115 } |
116 | 116 |
117 } // namespace app_list | 117 } // namespace app_list |
118 | 118 |
119 @implementation AppListViewController | 119 @implementation AppListViewController |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 if (shouldShowSearch) | 315 if (shouldShowSearch) |
316 delegate_->StartSearch(); | 316 delegate_->StartSearch(); |
317 else | 317 else |
318 delegate_->StopSearch(); | 318 delegate_->StopSearch(); |
319 } | 319 } |
320 | 320 |
321 - (app_list::AppListModel*)appListModel { | 321 - (app_list::AppListModel*)appListModel { |
322 return [appsGridController_ model]; | 322 return [appsGridController_ model]; |
323 } | 323 } |
324 | 324 |
325 - (NSString*)currentUserName { | |
326 return base::SysUTF16ToNSString( | |
327 [appsGridController_ model]->current_user_name()); | |
328 } | |
329 | |
330 - (NSString*)currentUserEmail { | |
331 return base::SysUTF16ToNSString( | |
332 [appsGridController_ model]->current_user_email()); | |
333 } | |
334 | |
335 - (void)openResult:(app_list::SearchResult*)result { | 325 - (void)openResult:(app_list::SearchResult*)result { |
336 if (delegate_) | 326 if (delegate_) |
337 delegate_->OpenSearchResult(result, 0 /* event flags */); | 327 delegate_->OpenSearchResult(result, 0 /* event flags */); |
338 | 328 |
339 [appsSearchBoxController_ clearSearch]; | 329 [appsSearchBoxController_ clearSearch]; |
340 } | 330 } |
341 | 331 |
342 - (void)redoSearch { | 332 - (void)redoSearch { |
343 [self modelTextDidChange]; | 333 [self modelTextDidChange]; |
344 } | 334 } |
(...skipping 16 matching lines...) Expand all Loading... |
361 | 351 |
362 [backgroundView_ setHidden:YES]; | 352 [backgroundView_ setHidden:YES]; |
363 signinViewController_.reset( | 353 signinViewController_.reset( |
364 [[SigninViewController alloc] initWithFrame:[backgroundView_ frame] | 354 [[SigninViewController alloc] initWithFrame:[backgroundView_ frame] |
365 cornerRadius:kBubbleCornerRadius | 355 cornerRadius:kBubbleCornerRadius |
366 delegate:signinDelegate]); | 356 delegate:signinDelegate]); |
367 [[self view] addSubview:[signinViewController_ view]]; | 357 [[self view] addSubview:[signinViewController_ view]]; |
368 } | 358 } |
369 | 359 |
370 @end | 360 @end |
OLD | NEW |