OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" | 7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" |
8 | 8 |
9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 return; | 281 return; |
282 DCHECK(browser_->profile()); | 282 DCHECK(browser_->profile()); |
283 ProfileOAuth2TokenService* oauth2_token_service = | 283 ProfileOAuth2TokenService* oauth2_token_service = |
284 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); | 284 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); |
285 DCHECK(oauth2_token_service); | 285 DCHECK(oauth2_token_service); |
286 oauth2_token_service->RemoveObserver(this); | 286 oauth2_token_service->RemoveObserver(this); |
287 token_observer_registered_ = false; | 287 token_observer_registered_ = false; |
288 } | 288 } |
289 | 289 |
290 // OAuth2TokenService::Observer: | 290 // OAuth2TokenService::Observer: |
291 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE { | 291 virtual void OnRefreshTokenAvailable(const std::string& account_id) override { |
292 // Tokens can only be added by adding an account through the inline flow, | 292 // Tokens can only be added by adding an account through the inline flow, |
293 // which is started from the account management view. Refresh it to show the | 293 // which is started from the account management view. Refresh it to show the |
294 // update. | 294 // update. |
295 profiles::BubbleViewMode viewMode = [controller_ viewMode]; | 295 profiles::BubbleViewMode viewMode = [controller_ viewMode]; |
296 if (viewMode == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT || | 296 if (viewMode == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT || |
297 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || | 297 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || |
298 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { | 298 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { |
299 [controller_ initMenuContentsWithView: | 299 [controller_ initMenuContentsWithView: |
300 switches::IsEnableAccountConsistency() ? | 300 switches::IsEnableAccountConsistency() ? |
301 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : | 301 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : |
302 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; | 302 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; |
303 } | 303 } |
304 } | 304 } |
305 | 305 |
306 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE { | 306 virtual void OnRefreshTokenRevoked(const std::string& account_id) override { |
307 // Tokens can only be removed from the account management view. Refresh it | 307 // Tokens can only be removed from the account management view. Refresh it |
308 // to show the update. | 308 // to show the update. |
309 if ([controller_ viewMode] == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) | 309 if ([controller_ viewMode] == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) |
310 [controller_ initMenuContentsWithView: | 310 [controller_ initMenuContentsWithView: |
311 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; | 311 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; |
312 } | 312 } |
313 | 313 |
314 // AvatarMenuObserver: | 314 // AvatarMenuObserver: |
315 virtual void OnAvatarMenuChanged(AvatarMenu* avatar_menu) OVERRIDE { | 315 virtual void OnAvatarMenuChanged(AvatarMenu* avatar_menu) override { |
316 profiles::BubbleViewMode viewMode = [controller_ viewMode]; | 316 profiles::BubbleViewMode viewMode = [controller_ viewMode]; |
317 if (viewMode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || | 317 if (viewMode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || |
318 viewMode == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { | 318 viewMode == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { |
319 [controller_ initMenuContentsWithView:viewMode]; | 319 [controller_ initMenuContentsWithView:viewMode]; |
320 } | 320 } |
321 } | 321 } |
322 | 322 |
323 // content::NotificationObserver: | 323 // content::NotificationObserver: |
324 virtual void Observe( | 324 virtual void Observe( |
325 int type, | 325 int type, |
326 const content::NotificationSource& source, | 326 const content::NotificationSource& source, |
327 const content::NotificationDetails& details) OVERRIDE { | 327 const content::NotificationDetails& details) override { |
328 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_CLOSING, type); | 328 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_CLOSING, type); |
329 if (browser_ == content::Source<Browser>(source).ptr()) { | 329 if (browser_ == content::Source<Browser>(source).ptr()) { |
330 RemoveTokenServiceObserver(); | 330 RemoveTokenServiceObserver(); |
331 // Clean up the bubble's WebContents (used by the Gaia embedded view), to | 331 // Clean up the bubble's WebContents (used by the Gaia embedded view), to |
332 // make sure the guest profile doesn't have any dangling host renderers. | 332 // make sure the guest profile doesn't have any dangling host renderers. |
333 // This can happen if Chrome is quit using Command-Q while the bubble is | 333 // This can happen if Chrome is quit using Command-Q while the bubble is |
334 // still open, which won't give the bubble a chance to be closed and | 334 // still open, which won't give the bubble a chance to be closed and |
335 // clean up the WebContents itself. | 335 // clean up the WebContents itself. |
336 [controller_ cleanUpEmbeddedViewContents]; | 336 [controller_ cleanUpEmbeddedViewContents]; |
337 } | 337 } |
(...skipping 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2192 } | 2192 } |
2193 | 2193 |
2194 - (bool)shouldShowGoIncognito { | 2194 - (bool)shouldShowGoIncognito { |
2195 bool incognitoAvailable = | 2195 bool incognitoAvailable = |
2196 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2196 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
2197 IncognitoModePrefs::DISABLED; | 2197 IncognitoModePrefs::DISABLED; |
2198 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 2198 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
2199 } | 2199 } |
2200 | 2200 |
2201 @end | 2201 @end |
OLD | NEW |