Commit 03b69740 authored by noms@chromium.org's avatar noms@chromium.org

Fix crash when locking a profile. The crash is happening because navigating to...

Fix crash when locking a profile. The crash is happening because navigating to a URL triggers the signin header helper code. Since locking shouldn't actually do a Gaia logout, I'm removing all the code related to that.

NOTRY-ing because it's been a week of "extension "RANDR" missing on display ":9" bot errors. 

BUG=NONE
TBR=pkasting@chromium.org
NOTRY=TRUE

Review URL: https://codereview.chromium.org/64313005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235801 0039d316-1c4b-4281-b951-d872f2087c98
parent 48c2e69a
......@@ -45,15 +45,6 @@ bool AvatarMenuActionsChromeOS::ShouldShowEditProfileLink() const {
return false;
}
content::WebContents* AvatarMenuActionsChromeOS::BeginSignOut() {
NOTIMPLEMENTED();
return NULL;
}
void AvatarMenuActionsChromeOS::SetLogoutURL(const std::string& logout_url) {
NOTIMPLEMENTED();
}
void AvatarMenuActionsChromeOS::ActiveBrowserChanged(Browser* browser) {
browser_ = browser;
}
......
......@@ -24,8 +24,6 @@ class AvatarMenuActionsChromeOS : public AvatarMenuActions {
virtual void EditProfile(Profile* profile, size_t index) OVERRIDE;
virtual bool ShouldShowAddNewProfileLink() const OVERRIDE;
virtual bool ShouldShowEditProfileLink() const OVERRIDE;
virtual content::WebContents* BeginSignOut() OVERRIDE;
virtual void SetLogoutURL(const std::string& logout_url) OVERRIDE;
virtual void ActiveBrowserChanged(Browser* browser) OVERRIDE;
private:
......
......@@ -6,7 +6,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/avatar_menu.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_window.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
......@@ -25,10 +25,7 @@ bool PrincipalsPrivateExtensionFunction::RunImpl() {
bool PrincipalsPrivateSignOutFunction::RunImplSafe() {
Browser* browser = GetCurrentBrowser();
if (browser) {
AvatarMenu avatar_menu(
&g_browser_process->profile_manager()->GetProfileInfoCache(), NULL,
browser);
avatar_menu.BeginSignOut();
profiles::LockProfile(browser->profile());
}
return true;
}
......
......@@ -230,11 +230,3 @@ void AvatarMenu::Observe(int type,
if (observer_)
observer_->OnAvatarMenuChanged(this);
}
content::WebContents* AvatarMenu::BeginSignOut() {
return menu_actions_->BeginSignOut();
}
void AvatarMenu::SetLogoutURL(const std::string& logout_url) {
menu_actions_->SetLogoutURL(logout_url);
}
......@@ -128,12 +128,6 @@ class AvatarMenu : public content::NotificationObserver {
// last active browser changes, the menu will need to reference that browser.
void ActiveBrowserChanged(Browser* browser);
// Start the sign-out process for this profile.
content::WebContents* BeginSignOut();
// Use a different URL for logout (for testing only).
void SetLogoutURL(const std::string& logout_url);
// Returns true if the add profile link should be shown.
bool ShouldShowAddNewProfileLink() const;
......
......@@ -31,12 +31,6 @@ class AvatarMenuActions {
// Returns true if the edit profile link should be shown.
virtual bool ShouldShowEditProfileLink() const = 0;
// Starts the sign-out process for this profile.
virtual content::WebContents* BeginSignOut() = 0;
// Sets a different URL to use for logout (for testing only).
virtual void SetLogoutURL(const std::string& logout_url) = 0;
// Updates the browser.
// TODO: Delegate browser actions to remove dependency on Browser class.
virtual void ActiveBrowserChanged(Browser* browser) = 0;
......
......@@ -22,58 +22,6 @@
#include "google_apis/gaia/gaia_urls.h"
#include "net/base/url_util.h"
namespace {
class SignoutTracker : public content::WebContentsObserver {
public:
SignoutTracker(Profile* profile,
const GURL& signout_landing_url,
content::WebContents* contents,
Browser* browser);
virtual void WebContentsDestroyed(content::WebContents* contents) OVERRIDE;
virtual void DidStopLoading(content::RenderViewHost* render_view_host)
OVERRIDE;
private:
scoped_ptr<content::WebContents> contents_;
GURL signout_landing_url_;
Profile* profile_;
Browser* browser_;
DISALLOW_COPY_AND_ASSIGN(SignoutTracker);
};
SignoutTracker::SignoutTracker(Profile* profile,
const GURL& signout_landing_url,
content::WebContents* contents,
Browser* browser)
: WebContentsObserver(contents),
contents_(contents),
signout_landing_url_(signout_landing_url),
profile_(profile),
browser_(browser) {
}
void SignoutTracker::DidStopLoading(content::RenderViewHost* render_view_host) {
// Only close when we reach the final landing; ignore redirects until then.
if (web_contents()->GetURL() == signout_landing_url_) {
if (profiles::IsNewProfileManagementEnabled()) {
DCHECK(profile_);
chrome::ShowUserManager(profile_->GetPath());
}
Observe(NULL);
BrowserList::CloseAllBrowsersWithProfile(profile_);
delete this; /* success */
}
}
void SignoutTracker::WebContentsDestroyed(content::WebContents* contents) {
delete this; /* failure */
}
} // namespace
AvatarMenuActionsDesktop::AvatarMenuActionsDesktop() {
}
......@@ -120,44 +68,6 @@ bool AvatarMenuActionsDesktop::ShouldShowEditProfileLink() const {
return true;
}
content::WebContents* AvatarMenuActionsDesktop::BeginSignOut() {
ProfileManager* profile_manager = g_browser_process->profile_manager();
Profile* current_profile = browser_->profile();
ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
size_t index = cache.GetIndexOfProfileWithPath(current_profile->GetPath());
cache.SetProfileSigninRequiredAtIndex(index, true);
std::string landing_url = signin::GetLandingURL("close", 1).spec();
GURL logout_url(GaiaUrls::GetInstance()->service_logout_url());
logout_url = net::AppendQueryParameter(logout_url, "continue", landing_url);
if (!logout_override_.empty()) {
// We're testing...
landing_url = logout_override_;
logout_url = GURL(logout_override_);
}
content::WebContents::CreateParams create_params(current_profile);
create_params.site_instance =
content::SiteInstance::CreateForURL(current_profile, logout_url);
content::WebContents* contents = content::WebContents::Create(create_params);
// This object may be destructed when the menu closes but we need something
// around to finish the sign-out process and close the profile windows.
new SignoutTracker(current_profile,
GURL(landing_url),
contents,
browser_);
contents->GetController().LoadURL(
logout_url, content::Referrer(),
content::PAGE_TRANSITION_GENERATED, std::string());
return contents; // returned for testing purposes
}
void AvatarMenuActionsDesktop::SetLogoutURL(const std::string& logout_url) {
logout_override_ = logout_url;
}
void AvatarMenuActionsDesktop::ActiveBrowserChanged(Browser* browser) {
browser_ = browser;
}
......@@ -23,8 +23,6 @@ class AvatarMenuActionsDesktop : public AvatarMenuActions {
virtual void EditProfile(Profile* profile, size_t index) OVERRIDE;
virtual bool ShouldShowAddNewProfileLink() const OVERRIDE;
virtual bool ShouldShowEditProfileLink() const OVERRIDE;
virtual content::WebContents* BeginSignOut() OVERRIDE;
virtual void SetLogoutURL(const std::string& logout_url) OVERRIDE;
virtual void ActiveBrowserChanged(Browser* browser) OVERRIDE;
private:
......
......@@ -7,6 +7,7 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/avatar_menu.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_window.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
......@@ -67,8 +68,7 @@ IN_PROC_BROWSER_TEST_F(ProfileListDesktopBrowserTest, SignOut) {
content::Source<Browser>(browser()));
EXPECT_FALSE(cache.ProfileIsSigninRequiredAtIndex(index));
menu->SetLogoutURL("about:blank");
menu->BeginSignOut();
profiles::LockProfile(current_profile);
EXPECT_TRUE(cache.ProfileIsSigninRequiredAtIndex(index));
window_close_observer.Wait(); // rely on test time-out for failure indication
......
......@@ -10,6 +10,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/user_metrics.h"
......@@ -176,4 +177,15 @@ void CloseGuestProfileWindows() {
}
}
void LockProfile(Profile* profile) {
DCHECK(profile);
ProfileInfoCache& cache =
g_browser_process->profile_manager()->GetProfileInfoCache();
size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath());
cache.SetProfileSigninRequiredAtIndex(index, true);
chrome::ShowUserManager(profile->GetPath());
BrowserList::CloseAllBrowsersWithProfile(profile);
}
} // namespace profiles
......@@ -54,6 +54,9 @@ void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type,
// Closes all browser windows that belong to the guest profile.
void CloseGuestProfileWindows();
// Closes all the browser windows for |profile| and opens the user manager.
void LockProfile(Profile* profile);
} // namespace profiles
#endif // CHROME_BROWSER_PROFILES_PROFILE_WINDOW_H_
......@@ -15,6 +15,7 @@
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_info_util.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_window.h"
#include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/ui/browser.h"
......@@ -658,7 +659,7 @@ void AvatarMenuBubbleView::ButtonPressed(views::Button* sender,
chrome::ShowSettingsSubPage(browser_, subpage);
return;
} else if (sender->tag() == IDS_PROFILES_PROFILE_SIGNOUT_BUTTON) {
avatar_menu_->BeginSignOut();
profiles::LockProfile(browser_->profile());
return;
}
......
......@@ -110,9 +110,6 @@ IN_PROC_BROWSER_TEST_F(NewAvatarMenuButtonTest, SignOut) {
menu->GetItemAt(menu->GetActiveProfileIndex());
EXPECT_FALSE(menu_item_before.signin_required);
ui::MouseEvent mouse_ev(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 0);
menu->SetLogoutURL("about:blank");
ProfileChooserView::profile_bubble_->LinkClicked(
static_cast<views::Link*>(
ProfileChooserView::profile_bubble_->signout_current_profile_link_),
......
......@@ -440,7 +440,7 @@ void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) {
// ShowView() will DCHECK if this view is displayed for non signed-in users.
ShowView(ACCOUNT_MANAGEMENT_VIEW, avatar_menu_.get());
} else if (sender == signout_current_profile_link_) {
avatar_menu_->BeginSignOut();
profiles::LockProfile(browser_->profile());
} else if (sender == signin_current_profile_link_) {
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableInlineSignin)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment