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

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

Issue 8983010: Convert WebContents to return a content::NavigationController instead of the implementation. Upda... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/auto_login_prompter.h" 5 #include "chrome/browser/ui/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/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // AutoLoginRedirector -------------------------------------------------------- 46 // AutoLoginRedirector --------------------------------------------------------
47 47
48 // This class is created by the AutoLoginInfoBarDelegate when the user wishes to 48 // This class is created by the AutoLoginInfoBarDelegate when the user wishes to
49 // auto-login. It holds context information needed while re-issuing service 49 // auto-login. It holds context information needed while re-issuing service
50 // tokens using the TokenService, gets the browser cookies with the TokenAuth 50 // tokens using the TokenService, gets the browser cookies with the TokenAuth
51 // API, and finally redirects the user to the correct page. 51 // API, and finally redirects the user to the correct page.
52 class AutoLoginRedirector : public content::NotificationObserver { 52 class AutoLoginRedirector : public content::NotificationObserver {
53 public: 53 public:
54 AutoLoginRedirector(TokenService* token_service, 54 AutoLoginRedirector(TokenService* token_service,
55 NavigationController* navigation_controller, 55 content::NavigationController* navigation_controller,
56 const std::string& args); 56 const std::string& args);
57 virtual ~AutoLoginRedirector(); 57 virtual ~AutoLoginRedirector();
58 58
59 private: 59 private:
60 // content::NotificationObserver override. 60 // content::NotificationObserver override.
61 virtual void Observe(int type, 61 virtual void Observe(int type,
62 const content::NotificationSource& source, 62 const content::NotificationSource& source,
63 const content::NotificationDetails& details) OVERRIDE; 63 const content::NotificationDetails& details) OVERRIDE;
64 64
65 // Redirect tab to MergeSession URL, logging the user in and navigating 65 // Redirect tab to MergeSession URL, logging the user in and navigating
66 // to the desired page. 66 // to the desired page.
67 void RedirectToMergeSession(const std::string& token); 67 void RedirectToMergeSession(const std::string& token);
68 68
69 NavigationController* navigation_controller_; 69 content::NavigationController* navigation_controller_;
70 const std::string args_; 70 const std::string args_;
71 content::NotificationRegistrar registrar_; 71 content::NotificationRegistrar registrar_;
72 72
73 DISALLOW_COPY_AND_ASSIGN(AutoLoginRedirector); 73 DISALLOW_COPY_AND_ASSIGN(AutoLoginRedirector);
74 }; 74 };
75 75
76 AutoLoginRedirector::AutoLoginRedirector( 76 AutoLoginRedirector::AutoLoginRedirector(
77 TokenService* token_service, 77 TokenService* token_service,
78 NavigationController* navigation_controller, 78 content::NavigationController* navigation_controller,
79 const std::string& args) 79 const std::string& args)
80 : navigation_controller_(navigation_controller), 80 : navigation_controller_(navigation_controller),
81 args_(args) { 81 args_(args) {
82 // Register to receive notification for new tokens and then force the tokens 82 // Register to receive notification for new tokens and then force the tokens
83 // to be re-issued. The token service guarantees to fire either 83 // to be re-issued. The token service guarantees to fire either
84 // TOKEN_AVAILABLE or TOKEN_REQUEST_FAILED, so we will get at least one or 84 // TOKEN_AVAILABLE or TOKEN_REQUEST_FAILED, so we will get at least one or
85 // the other, allow AutoLoginRedirector to delete itself correctly. 85 // the other, allow AutoLoginRedirector to delete itself correctly.
86 registrar_.Add(this, 86 registrar_.Add(this,
87 chrome::NOTIFICATION_TOKEN_AVAILABLE, 87 chrome::NOTIFICATION_TOKEN_AVAILABLE,
88 content::Source<TokenService>(token_service)); 88 content::Source<TokenService>(token_service));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 std::string()); 134 std::string());
135 } 135 }
136 136
137 137
138 // AutoLoginInfoBarDelegate --------------------------------------------------- 138 // AutoLoginInfoBarDelegate ---------------------------------------------------
139 139
140 // This is the actual infobar displayed to prompt the user to auto-login. 140 // This is the actual infobar displayed to prompt the user to auto-login.
141 class AutoLoginInfoBarDelegate : public ConfirmInfoBarDelegate { 141 class AutoLoginInfoBarDelegate : public ConfirmInfoBarDelegate {
142 public: 142 public:
143 AutoLoginInfoBarDelegate(InfoBarTabHelper* owner, 143 AutoLoginInfoBarDelegate(InfoBarTabHelper* owner,
144 NavigationController* navigation_controller, 144 content::NavigationController* navigation_controller,
145 TokenService* token_service, 145 TokenService* token_service,
146 PrefService* pref_service, 146 PrefService* pref_service,
147 const std::string& username, 147 const std::string& username,
148 const std::string& args); 148 const std::string& args);
149 virtual ~AutoLoginInfoBarDelegate(); 149 virtual ~AutoLoginInfoBarDelegate();
150 150
151 private: 151 private:
152 // ConfirmInfoBarDelegate overrides. 152 // ConfirmInfoBarDelegate overrides.
153 virtual gfx::Image* GetIcon() const OVERRIDE; 153 virtual gfx::Image* GetIcon() const OVERRIDE;
154 virtual Type GetInfoBarType() const OVERRIDE; 154 virtual Type GetInfoBarType() const OVERRIDE;
155 virtual string16 GetMessageText() const OVERRIDE; 155 virtual string16 GetMessageText() const OVERRIDE;
156 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 156 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
157 virtual bool Accept() OVERRIDE; 157 virtual bool Accept() OVERRIDE;
158 virtual bool Cancel() OVERRIDE; 158 virtual bool Cancel() OVERRIDE;
159 159
160 NavigationController* navigation_controller_; 160 content::NavigationController* navigation_controller_;
161 TokenService* token_service_; 161 TokenService* token_service_;
162 PrefService* pref_service_; 162 PrefService* pref_service_;
163 std::string username_; 163 std::string username_;
164 std::string args_; 164 std::string args_;
165 165
166 DISALLOW_COPY_AND_ASSIGN(AutoLoginInfoBarDelegate); 166 DISALLOW_COPY_AND_ASSIGN(AutoLoginInfoBarDelegate);
167 }; 167 };
168 168
169 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate( 169 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate(
170 InfoBarTabHelper* owner, 170 InfoBarTabHelper* owner,
171 NavigationController* navigation_controller, 171 content::NavigationController* navigation_controller,
172 TokenService* token_service, 172 TokenService* token_service,
173 PrefService* pref_service, 173 PrefService* pref_service,
174 const std::string& username, 174 const std::string& username,
175 const std::string& args) 175 const std::string& args)
176 : ConfirmInfoBarDelegate(owner), 176 : ConfirmInfoBarDelegate(owner),
177 navigation_controller_(navigation_controller), 177 navigation_controller_(navigation_controller),
178 token_service_(token_service), 178 token_service_(token_service),
179 pref_service_(pref_service), 179 pref_service_(pref_service),
180 username_(username), 180 username_(username),
181 args_(args) { 181 args_(args) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 infobar_helper, &web_contents_->GetController(), 336 infobar_helper, &web_contents_->GetController(),
337 profile->GetTokenService(), profile->GetPrefs(), 337 profile->GetTokenService(), profile->GetPrefs(),
338 username_, args_)); 338 username_, args_));
339 } 339 }
340 } 340 }
341 // Either we couldn't add the infobar, we added the infobar, or the tab 341 // Either we couldn't add the infobar, we added the infobar, or the tab
342 // contents was destroyed before the navigation completed. In any case 342 // contents was destroyed before the navigation completed. In any case
343 // there's no reason to live further. 343 // there's no reason to live further.
344 delete this; 344 delete this;
345 } 345 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698