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

Side by Side Diff: chrome/browser/ui/app_list/app_list_view_delegate.cc

Issue 22825025: Remove SigninDelegateObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove from gyp file 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" 5 #include "chrome/browser/ui/app_list/app_list_view_delegate.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, 62 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
63 content::Source<Profile>(profile_)); 63 content::Source<Profile>(profile_));
64 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED, 64 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED,
65 content::Source<Profile>(profile_)); 65 content::Source<Profile>(profile_));
66 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, 66 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNED_OUT,
67 content::Source<Profile>(profile_)); 67 content::Source<Profile>(profile_));
68 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this); 68 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this);
69 } 69 }
70 70
71 AppListViewDelegate::~AppListViewDelegate() { 71 AppListViewDelegate::~AppListViewDelegate() {
72 if (signin_delegate_)
73 signin_delegate_->RemoveObserver(this);
74 g_browser_process-> 72 g_browser_process->
75 profile_manager()->GetProfileInfoCache().RemoveObserver(this); 73 profile_manager()->GetProfileInfoCache().RemoveObserver(this);
76 } 74 }
77 75
78 void AppListViewDelegate::OnProfileChanged() { 76 void AppListViewDelegate::OnProfileChanged() {
79 model_->SetSignedIn(!signin_delegate_->NeedSignin()); 77 model_->SetSignedIn(!signin_delegate_->NeedSignin());
80 ProfileInfoCache& cache = 78 ProfileInfoCache& cache =
81 g_browser_process->profile_manager()->GetProfileInfoCache(); 79 g_browser_process->profile_manager()->GetProfileInfoCache();
82 // Populate the current user details. 80 // Populate the current user details.
83 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); 81 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath());
84 // The profile won't exist in the cache if the current app list profile is 82 // The profile won't exist in the cache if the current app list profile is
85 // being deleted. 83 // being deleted.
86 if (profile_index == std::string::npos) 84 if (profile_index == std::string::npos)
87 return; 85 return;
88 86
89 model_->SetCurrentUser(cache.GetNameOfProfileAtIndex(profile_index), 87 model_->SetCurrentUser(cache.GetNameOfProfileAtIndex(profile_index),
90 cache.GetUserNameOfProfileAtIndex(profile_index)); 88 cache.GetUserNameOfProfileAtIndex(profile_index));
91 } 89 }
92 90
93 void AppListViewDelegate::SetModel(app_list::AppListModel* model) { 91 void AppListViewDelegate::SetModel(app_list::AppListModel* model) {
94 if (signin_delegate_)
95 signin_delegate_->RemoveObserver(this);
96 if (model) { 92 if (model) {
97 model_ = model; 93 model_ = model;
98 apps_builder_.reset(new AppsModelBuilder(profile_, 94 apps_builder_.reset(new AppsModelBuilder(profile_,
99 model->apps(), 95 model->apps(),
100 controller_.get())); 96 controller_.get()));
101 apps_builder_->Build(); 97 apps_builder_->Build();
102 98
103 search_controller_.reset(new app_list::SearchController( 99 search_controller_.reset(new app_list::SearchController(
104 profile_, model->search_box(), model->results(), controller_.get())); 100 profile_, model->search_box(), model->results(), controller_.get()));
105 101
106 signin_delegate_.reset(new ChromeSigninDelegate(profile_)); 102 signin_delegate_.reset(new ChromeSigninDelegate(profile_));
107 signin_delegate_->AddObserver(this);
108 103
109 #if defined(USE_ASH) 104 #if defined(USE_ASH)
110 app_sync_ui_state_watcher_.reset(new AppSyncUIStateWatcher(profile_, 105 app_sync_ui_state_watcher_.reset(new AppSyncUIStateWatcher(profile_,
111 model)); 106 model));
112 #endif 107 #endif
113 OnProfileChanged(); 108 OnProfileChanged();
114 } else { 109 } else {
115 model_ = NULL; 110 model_ = NULL;
116 apps_builder_.reset(); 111 apps_builder_.reset();
117 search_controller_.reset(); 112 search_controller_.reset();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 213
219 void AppListViewDelegate::OpenFeedback() { 214 void AppListViewDelegate::OpenFeedback() {
220 chrome::HostDesktopType desktop = chrome::GetHostDesktopTypeForNativeWindow( 215 chrome::HostDesktopType desktop = chrome::GetHostDesktopTypeForNativeWindow(
221 controller_->GetAppListWindow()); 216 controller_->GetAppListWindow());
222 Browser* browser = chrome::FindOrCreateTabbedBrowser( 217 Browser* browser = chrome::FindOrCreateTabbedBrowser(
223 profile_, desktop); 218 profile_, desktop);
224 chrome::ShowFeedbackPage(browser, std::string(), 219 chrome::ShowFeedbackPage(browser, std::string(),
225 chrome::kAppLauncherCategoryTag); 220 chrome::kAppLauncherCategoryTag);
226 } 221 }
227 222
228 void AppListViewDelegate::OnSigninSuccess() {
229 OnProfileChanged();
230 }
231
232 void AppListViewDelegate::Observe( 223 void AppListViewDelegate::Observe(
233 int type, 224 int type,
234 const content::NotificationSource& source, 225 const content::NotificationSource& source,
235 const content::NotificationDetails& details) { 226 const content::NotificationDetails& details) {
236 OnProfileChanged(); 227 OnProfileChanged();
237 } 228 }
238 229
239 void AppListViewDelegate::OnProfileNameChanged( 230 void AppListViewDelegate::OnProfileNameChanged(
240 const base::FilePath& profile_path, 231 const base::FilePath& profile_path,
241 const base::string16& old_profile_name) { 232 const base::string16& old_profile_name) {
242 if (profile_->GetPath() != profile_path) 233 if (profile_->GetPath() != profile_path)
243 return; 234 return;
244 235
245 OnProfileChanged(); 236 OnProfileChanged();
246 } 237 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/app_list_view_delegate.h ('k') | chrome/browser/ui/app_list/chrome_signin_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698