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

Unified Diff: ui/app_list/cocoa/app_list_view_controller.mm

Issue 22268009: Move signin status and current user information into AppListModel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: implemented for mac Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: ui/app_list/cocoa/app_list_view_controller.mm
diff --git a/ui/app_list/cocoa/app_list_view_controller.mm b/ui/app_list/cocoa/app_list_view_controller.mm
index 37b6bf867850458437ed4001aa60b8c749aa84aa..23bc9d0d0f22a24abe194904741f708c6e084426 100644
--- a/ui/app_list/cocoa/app_list_view_controller.mm
+++ b/ui/app_list/cocoa/app_list_view_controller.mm
@@ -9,9 +9,9 @@
#include "skia/ext/skia_utils_mac.h"
#include "ui/app_list/app_list_constants.h"
#include "ui/app_list/app_list_model.h"
+#include "ui/app_list/app_list_model_observer.h"
#include "ui/app_list/app_list_view_delegate.h"
#include "ui/app_list/signin_delegate.h"
-#include "ui/app_list/signin_delegate_observer.h"
#import "ui/app_list/cocoa/app_list_pager_view.h"
#import "ui/app_list/cocoa/apps_grid_controller.h"
#import "ui/app_list/cocoa/signin_view_controller.h"
@@ -81,28 +81,41 @@ const NSTimeInterval kResultsAnimationDuration = 0.2;
namespace app_list {
-class SigninDelegateObserverBridge : public SigninDelegateObserver {
+class AppListModelObserverBridge : public AppListModelObserver {
public:
- SigninDelegateObserverBridge(AppListViewController* parent)
- : parent_(parent) {
- [parent_ signinDelegate]->AddObserver(this);
- }
-
- virtual ~SigninDelegateObserverBridge() {
- [parent_ signinDelegate]->RemoveObserver(this);
- }
+ AppListModelObserverBridge(AppListModel* model,
+ AppListViewController* parent);
+ virtual ~AppListModelObserverBridge();
private:
- // SigninDelegateObserver override:
- virtual void OnSigninSuccess() OVERRIDE {
- [parent_ onSigninStatusChanged];
- }
+ // Overridden from app_list::AppListModelObserver:
+ virtual void OnAppListModelCurrentUserChanged() OVERRIDE;
+ virtual void OnAppListModelSigninStatusChanged() OVERRIDE;
+ AppListModel* model_;
tapted 2013/08/14 03:53:11 prevailing style on the Cocoa side is to not cache
calamity 2013/08/14 09:19:00 Done.
AppListViewController* parent_; // Weak. Owns us.
- DISALLOW_COPY_AND_ASSIGN(SigninDelegateObserverBridge);
+ DISALLOW_COPY_AND_ASSIGN(AppListModelObserverBridge);
};
+AppListModelObserverBridge::AppListModelObserverBridge(
+ AppListModel* model, AppListViewController* parent)
+ : model_(model), parent_(parent) {
+ model_->AddObserver(this);
+}
+
+AppListModelObserverBridge::~AppListModelObserverBridge() {
+ model_->RemoveObserver(this);
+}
+
+void AppListModelObserverBridge::OnAppListModelCurrentUserChanged() {
+ [parent_ onSigninStatusChanged];
+}
+
+void AppListModelObserverBridge::OnAppListModelSigninStatusChanged() {
+ [parent_ onSigninStatusChanged];
+}
+
} // namespace app_list
@implementation AppListViewController
@@ -148,7 +161,7 @@ class SigninDelegateObserverBridge : public SigninDelegateObserver {
withTestModel:(scoped_ptr<app_list::AppListModel>)newModel {
if (delegate_) {
// First clean up, in reverse order.
- signin_observer_bridge_.reset();
+ app_list_model_observer_bridge_.reset();
[appsSearchResultsController_ setDelegate:nil];
[appsSearchBoxController_ setDelegate:nil];
}
@@ -158,6 +171,9 @@ class SigninDelegateObserverBridge : public SigninDelegateObserver {
[appsGridController_ setModel:newModel.Pass()];
[appsSearchBoxController_ setDelegate:self];
[appsSearchResultsController_ setDelegate:self];
+ app_list_model_observer_bridge_.reset(
+ new app_list::AppListModelObserverBridge(
+ [appsGridController_ model], self));
[self onSigninStatusChanged];
}
@@ -321,7 +337,6 @@ class SigninDelegateObserverBridge : public SigninDelegateObserver {
BOOL needsSignin = signinDelegate && signinDelegate->NeedSignin();
if (!needsSignin) {
[[signinViewController_ view] removeFromSuperview];
- signin_observer_bridge_.reset();
signinViewController_.reset();
[backgroundView_ setHidden:NO];
return;
@@ -332,8 +347,6 @@ class SigninDelegateObserverBridge : public SigninDelegateObserver {
[[SigninViewController alloc] initWithFrame:[backgroundView_ frame]
cornerRadius:kBubbleCornerRadius
delegate:signinDelegate]);
- signin_observer_bridge_.reset(
- new app_list::SigninDelegateObserverBridge(self));
[[self view] addSubview:[signinViewController_ view]];
}
@@ -341,4 +354,12 @@ class SigninDelegateObserverBridge : public SigninDelegateObserver {
return delegate_ ? delegate_->GetSigninDelegate() : NULL;
}
+- (const base::string16&)currentUserName {
tapted 2013/08/14 03:53:11 nit: These should be grouped with the other protoc
calamity 2013/08/14 09:19:00 Done.
+ return [appsGridController_ model]->current_user_name();
+}
+
+- (const base::string16&)currentUserEmail {
+ return [appsGridController_ model]->current_user_email();
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698