| 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 #include "chrome/browser/extensions/api/principals_private/principals_private_ap
i.h" | 5 #include "chrome/browser/extensions/api/principals_private/principals_private_ap
i.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/profiles/avatar_menu.h" | 8 #include "chrome/browser/profiles/avatar_menu.h" |
| 9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_window.h" |
| 10 #include "chrome/browser/profiles/profiles_state.h" | 10 #include "chrome/browser/profiles/profiles_state.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
| 13 | 13 |
| 14 namespace extensions { | 14 namespace extensions { |
| 15 | 15 |
| 16 bool PrincipalsPrivateExtensionFunction::RunImpl() { | 16 bool PrincipalsPrivateExtensionFunction::RunImpl() { |
| 17 if (!profiles::IsNewProfileManagementEnabled()) { | 17 if (!profiles::IsNewProfileManagementEnabled()) { |
| 18 SetError( | 18 SetError( |
| 19 "Need to enable new-profile-management to use principalsPrivate API."); | 19 "Need to enable new-profile-management to use principalsPrivate API."); |
| 20 return false; | 20 return false; |
| 21 } | 21 } |
| 22 return RunImplSafe(); | 22 return RunImplSafe(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 bool PrincipalsPrivateSignOutFunction::RunImplSafe() { | 25 bool PrincipalsPrivateSignOutFunction::RunImplSafe() { |
| 26 Browser* browser = GetCurrentBrowser(); | 26 Browser* browser = GetCurrentBrowser(); |
| 27 if (browser) { | 27 if (browser) { |
| 28 AvatarMenu avatar_menu( | 28 profiles::LockProfile(browser->profile()); |
| 29 &g_browser_process->profile_manager()->GetProfileInfoCache(), NULL, | |
| 30 browser); | |
| 31 avatar_menu.BeginSignOut(); | |
| 32 } | 29 } |
| 33 return true; | 30 return true; |
| 34 } | 31 } |
| 35 | 32 |
| 36 bool PrincipalsPrivateShowAvatarBubbleFunction::RunImplSafe() { | 33 bool PrincipalsPrivateShowAvatarBubbleFunction::RunImplSafe() { |
| 37 Browser* browser = GetCurrentBrowser(); | 34 Browser* browser = GetCurrentBrowser(); |
| 38 if (browser) | 35 if (browser) |
| 39 browser->window()->ShowAvatarBubbleFromAvatarButton(); | 36 browser->window()->ShowAvatarBubbleFromAvatarButton(); |
| 40 return true; | 37 return true; |
| 41 } | 38 } |
| 42 | 39 |
| 43 } // namespace extensions | 40 } // namespace extensions |
| OLD | NEW |