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

Side by Side Diff: chrome/browser/ui/android/infobars/auto_login_prompter.cc

Issue 309773003: Do not do infobar auto login in Incognito. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Do not show autologin infobar in Incognito mode. Created 6 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/ui/android/infobars/auto_login_prompter.h" 5 #include "chrome/browser/ui/android/infobars/auto_login_prompter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "chrome/browser/google/google_url_tracker.h" 11 #include "chrome/browser/google/google_url_tracker.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
14 #include "chrome/browser/signin/signin_manager_factory.h" 14 #include "chrome/browser/signin/signin_manager_factory.h"
15 #include "chrome/browser/tab_contents/tab_util.h" 15 #include "chrome/browser/tab_contents/tab_util.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 #include "components/auto_login_parser/auto_login_parser.h" 18 #include "components/auto_login_parser/auto_login_parser.h"
19 #include "components/signin/core/browser/profile_oauth2_token_service.h" 19 #include "components/signin/core/browser/profile_oauth2_token_service.h"
20 #include "components/signin/core/browser/signin_manager.h" 20 #include "components/signin/core/browser/signin_manager.h"
21 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
23 #include "net/url_request/url_request.h" 23 #include "net/url_request/url_request.h"
24 #include "url/gurl.h" 24 #include "url/gurl.h"
25 25
26 using content::BrowserThread; 26 using content::BrowserThread;
27 using content::BrowserContext;
27 using content::WebContents; 28 using content::WebContents;
28 29
29 AutoLoginPrompter::AutoLoginPrompter(WebContents* web_contents, 30 AutoLoginPrompter::AutoLoginPrompter(WebContents* web_contents,
30 const Params& params, 31 const Params& params,
31 const GURL& url) 32 const GURL& url)
32 : WebContentsObserver(web_contents), 33 : WebContentsObserver(web_contents),
33 params_(params), 34 params_(params),
34 url_(url), 35 url_(url),
35 infobar_shown_(false) { 36 infobar_shown_(false) {
36 if (!web_contents->IsLoading()) { 37 if (!web_contents->IsLoading()) {
(...skipping 29 matching lines...) Expand all
66 // static 67 // static
67 void AutoLoginPrompter::ShowInfoBarUIThread(Params params, 68 void AutoLoginPrompter::ShowInfoBarUIThread(Params params,
68 const GURL& url, 69 const GURL& url,
69 int child_id, 70 int child_id,
70 int route_id) { 71 int route_id) {
71 DCHECK_CURRENTLY_ON(BrowserThread::UI); 72 DCHECK_CURRENTLY_ON(BrowserThread::UI);
72 WebContents* web_contents = tab_util::GetWebContentsByID(child_id, route_id); 73 WebContents* web_contents = tab_util::GetWebContentsByID(child_id, route_id);
73 if (!web_contents) 74 if (!web_contents)
74 return; 75 return;
75 76
76 Profile* profile = 77 BrowserContext* context = web_contents->GetBrowserContext();
77 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 78
gone 2014/06/02 23:27:05 nit: remove empty line
acleung1 2014/06/03 17:15:32 Done.
79 if (context->IsOffTheRecord())
80 return;
81
82 Profile* profile = Profile::FromBrowserContext(context);
78 83
gone 2014/06/02 23:27:05 this one too?
acleung1 2014/06/03 17:15:32 Done.
79 if (!profile->GetPrefs()->GetBoolean(prefs::kAutologinEnabled)) 84 if (!profile->GetPrefs()->GetBoolean(prefs::kAutologinEnabled))
80 return; 85 return;
81 86
82 // Make sure that |account|, if specified, matches the logged in user. 87 // Make sure that |account|, if specified, matches the logged in user.
83 // However, |account| is usually empty. 88 // However, |account| is usually empty.
84 if (!params.username.empty() && !params.header.account.empty() && 89 if (!params.username.empty() && !params.header.account.empty() &&
85 params.username != params.header.account) 90 params.username != params.header.account)
86 return; 91 return;
87 // We can't add the infobar just yet, since we need to wait for the tab to 92 // We can't add the infobar just yet, since we need to wait for the tab to
88 // finish loading. If we don't, the info bar appears and then disappears 93 // finish loading. If we don't, the info bar appears and then disappears
(...skipping 10 matching lines...) Expand all
99 104
100 void AutoLoginPrompter::WebContentsDestroyed() { 105 void AutoLoginPrompter::WebContentsDestroyed() {
101 // The WebContents was destroyed before the navigation completed. 106 // The WebContents was destroyed before the navigation completed.
102 delete this; 107 delete this;
103 } 108 }
104 109
105 void AutoLoginPrompter::AddInfoBarToWebContents() { 110 void AutoLoginPrompter::AddInfoBarToWebContents() {
106 if (!infobar_shown_) 111 if (!infobar_shown_)
107 infobar_shown_ = AutoLoginInfoBarDelegate::Create(web_contents(), params_); 112 infobar_shown_ = AutoLoginInfoBarDelegate::Create(web_contents(), params_);
108 } 113 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698