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

Side by Side Diff: chrome/browser/chromeos/login/merge_session_load_page.cc

Issue 23678007: OAuth2LoginManager+MergeSessionThrottle hardening, multi-profle support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/chromeos/login/merge_session_load_page.h" 5 #include "chrome/browser/chromeos/login/merge_session_load_page.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_delegate.h" 8 #include "ash/shell_delegate.h"
9 #include "ash/system/tray/system_tray_delegate.h" 9 #include "ash/system/tray/system_tray_delegate.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/chrome_notification_types.h" 16 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/chromeos/login/oauth2_login_manager_factory.h"
17 #include "chrome/browser/extensions/extension_service.h" 18 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/extension_system.h" 19 #include "chrome/browser/extensions/extension_system.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/renderer_preferences_util.h" 21 #include "chrome/browser/renderer_preferences_util.h"
21 #include "chrome/browser/tab_contents/tab_util.h" 22 #include "chrome/browser/tab_contents/tab_util.h"
22 #include "chrome/common/extensions/extension.h" 23 #include "chrome/common/extensions/extension.h"
23 #include "chrome/common/extensions/extension_constants.h" 24 #include "chrome/common/extensions/extension_constants.h"
24 #include "chrome/common/extensions/extension_icon_set.h" 25 #include "chrome/common/extensions/extension_icon_set.h"
25 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
26 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
(...skipping 23 matching lines...) Expand all
50 51
51 namespace chromeos { 52 namespace chromeos {
52 53
53 MergeSessionLoadPage::MergeSessionLoadPage(WebContents* web_contents, 54 MergeSessionLoadPage::MergeSessionLoadPage(WebContents* web_contents,
54 const GURL& url, 55 const GURL& url,
55 const CompletionCallback& callback) 56 const CompletionCallback& callback)
56 : callback_(callback), 57 : callback_(callback),
57 proceeded_(false), 58 proceeded_(false),
58 web_contents_(web_contents), 59 web_contents_(web_contents),
59 url_(url) { 60 url_(url) {
60 UserManager::Get()->AddObserver(this); 61 OAuth2LoginManager* manager = GetOAuth2LoginManager();
62 manager->AddObserver(this);
61 interstitial_page_ = InterstitialPage::Create(web_contents, true, url, this); 63 interstitial_page_ = InterstitialPage::Create(web_contents, true, url, this);
62 } 64 }
63 65
64 MergeSessionLoadPage::~MergeSessionLoadPage() { 66 MergeSessionLoadPage::~MergeSessionLoadPage() {
65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
66 UserManager::Get()->RemoveObserver(this); 68 OAuth2LoginManager* manager = GetOAuth2LoginManager();
69 manager->RemoveObserver(this);
67 } 70 }
68 71
69 void MergeSessionLoadPage::Show() { 72 void MergeSessionLoadPage::Show() {
70 interstitial_page_->Show(); 73 interstitial_page_->Show();
71 } 74 }
72 75
73 std::string MergeSessionLoadPage::GetHTMLContents() { 76 std::string MergeSessionLoadPage::GetHTMLContents() {
74 DictionaryValue strings; 77 DictionaryValue strings;
75 strings.SetString("title", web_contents_->GetTitle()); 78 strings.SetString("title", web_contents_->GetTitle());
76 // Set the timeout to show the page. 79 // Set the timeout to show the page.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 127 }
125 } 128 }
126 129
127 void MergeSessionLoadPage::NotifyBlockingPageComplete() { 130 void MergeSessionLoadPage::NotifyBlockingPageComplete() {
128 if (!callback_.is_null()) { 131 if (!callback_.is_null()) {
129 BrowserThread::PostTask( 132 BrowserThread::PostTask(
130 BrowserThread::IO, FROM_HERE, callback_); 133 BrowserThread::IO, FROM_HERE, callback_);
131 } 134 }
132 } 135 }
133 136
134 void MergeSessionLoadPage::MergeSessionStateChanged( 137 OAuth2LoginManager* MergeSessionLoadPage::GetOAuth2LoginManager() {
135 UserManager::MergeSessionState state) { 138 content::BrowserContext* browser_context = web_contents_->GetBrowserContext();
139 if (!browser_context)
140 return NULL;
141
142 Profile* profile = Profile::FromBrowserContext(browser_context);
143 if (!profile)
144 return NULL;
145
146 return OAuth2LoginManagerFactory::GetInstance()->GetForProfile(profile);
147 }
148
149 void MergeSessionLoadPage::OnSessionRestoreStateChanged(
150 Profile* user_profile, OAuth2LoginManager::SessionRestoreState state) {
136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
137 DVLOG(1) << "Merge session is " 152
138 << (state != UserManager:: MERGE_STATUS_IN_PROCESS ? 153 OAuth2LoginManager* manager = GetOAuth2LoginManager();
154 DVLOG(1) << "Merge session should "
155 << (!manager->ShouldBlockTabLoading() ?
139 " NOT " : "") 156 " NOT " : "")
140 << " in progress, " 157 << " be blocking now, "
141 << state; 158 << state;
142 if (state != UserManager:: MERGE_STATUS_IN_PROCESS) { 159 if (!manager->ShouldBlockTabLoading()) {
143 UserManager::Get()->RemoveObserver(this); 160 manager->RemoveObserver(this);
144 interstitial_page_->Proceed(); 161 interstitial_page_->Proceed();
145 } 162 }
146 } 163 }
147 164
148 } // namespace chromeos 165 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698