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

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

Issue 8983012: Get rid of content::NavigationController in cc file and use "using" instead. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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
« no previous file with comments | « chrome/browser/translate/translate_manager_browsertest.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 23 matching lines...) Expand all
34 #include "content/public/browser/notification_types.h" 34 #include "content/public/browser/notification_types.h"
35 #include "googleurl/src/url_canon.h" 35 #include "googleurl/src/url_canon.h"
36 #include "googleurl/src/url_util.h" 36 #include "googleurl/src/url_util.h"
37 #include "grit/generated_resources.h" 37 #include "grit/generated_resources.h"
38 #include "grit/theme_resources_standard.h" 38 #include "grit/theme_resources_standard.h"
39 #include "net/url_request/url_request.h" 39 #include "net/url_request/url_request.h"
40 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
41 #include "ui/base/resource/resource_bundle.h" 41 #include "ui/base/resource/resource_bundle.h"
42 42
43 using content::BrowserThread; 43 using content::BrowserThread;
44 using content::NavigationController;
44 using content::WebContents; 45 using content::WebContents;
45 46
46 // AutoLoginRedirector -------------------------------------------------------- 47 // AutoLoginRedirector --------------------------------------------------------
47 48
48 // This class is created by the AutoLoginInfoBarDelegate when the user wishes to 49 // This class is created by the AutoLoginInfoBarDelegate when the user wishes to
49 // auto-login. It holds context information needed while re-issuing service 50 // auto-login. It holds context information needed while re-issuing service
50 // tokens using the TokenService, gets the browser cookies with the TokenAuth 51 // tokens using the TokenService, gets the browser cookies with the TokenAuth
51 // API, and finally redirects the user to the correct page. 52 // API, and finally redirects the user to the correct page.
52 class AutoLoginRedirector : public content::NotificationObserver { 53 class AutoLoginRedirector : public content::NotificationObserver {
53 public: 54 public:
54 AutoLoginRedirector(TokenService* token_service, 55 AutoLoginRedirector(TokenService* token_service,
55 content::NavigationController* navigation_controller, 56 NavigationController* navigation_controller,
56 const std::string& args); 57 const std::string& args);
57 virtual ~AutoLoginRedirector(); 58 virtual ~AutoLoginRedirector();
58 59
59 private: 60 private:
60 // content::NotificationObserver override. 61 // content::NotificationObserver override.
61 virtual void Observe(int type, 62 virtual void Observe(int type,
62 const content::NotificationSource& source, 63 const content::NotificationSource& source,
63 const content::NotificationDetails& details) OVERRIDE; 64 const content::NotificationDetails& details) OVERRIDE;
64 65
65 // Redirect tab to MergeSession URL, logging the user in and navigating 66 // Redirect tab to MergeSession URL, logging the user in and navigating
66 // to the desired page. 67 // to the desired page.
67 void RedirectToMergeSession(const std::string& token); 68 void RedirectToMergeSession(const std::string& token);
68 69
69 content::NavigationController* navigation_controller_; 70 NavigationController* navigation_controller_;
70 const std::string args_; 71 const std::string args_;
71 content::NotificationRegistrar registrar_; 72 content::NotificationRegistrar registrar_;
72 73
73 DISALLOW_COPY_AND_ASSIGN(AutoLoginRedirector); 74 DISALLOW_COPY_AND_ASSIGN(AutoLoginRedirector);
74 }; 75 };
75 76
76 AutoLoginRedirector::AutoLoginRedirector( 77 AutoLoginRedirector::AutoLoginRedirector(
77 TokenService* token_service, 78 TokenService* token_service,
78 content::NavigationController* navigation_controller, 79 NavigationController* navigation_controller,
79 const std::string& args) 80 const std::string& args)
80 : navigation_controller_(navigation_controller), 81 : navigation_controller_(navigation_controller),
81 args_(args) { 82 args_(args) {
82 // Register to receive notification for new tokens and then force the tokens 83 // Register to receive notification for new tokens and then force the tokens
83 // to be re-issued. The token service guarantees to fire either 84 // 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 85 // TOKEN_AVAILABLE or TOKEN_REQUEST_FAILED, so we will get at least one or
85 // the other, allow AutoLoginRedirector to delete itself correctly. 86 // the other, allow AutoLoginRedirector to delete itself correctly.
86 registrar_.Add(this, 87 registrar_.Add(this,
87 chrome::NOTIFICATION_TOKEN_AVAILABLE, 88 chrome::NOTIFICATION_TOKEN_AVAILABLE,
88 content::Source<TokenService>(token_service)); 89 content::Source<TokenService>(token_service));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 std::string()); 135 std::string());
135 } 136 }
136 137
137 138
138 // AutoLoginInfoBarDelegate --------------------------------------------------- 139 // AutoLoginInfoBarDelegate ---------------------------------------------------
139 140
140 // This is the actual infobar displayed to prompt the user to auto-login. 141 // This is the actual infobar displayed to prompt the user to auto-login.
141 class AutoLoginInfoBarDelegate : public ConfirmInfoBarDelegate { 142 class AutoLoginInfoBarDelegate : public ConfirmInfoBarDelegate {
142 public: 143 public:
143 AutoLoginInfoBarDelegate(InfoBarTabHelper* owner, 144 AutoLoginInfoBarDelegate(InfoBarTabHelper* owner,
144 content::NavigationController* navigation_controller, 145 NavigationController* navigation_controller,
145 TokenService* token_service, 146 TokenService* token_service,
146 PrefService* pref_service, 147 PrefService* pref_service,
147 const std::string& username, 148 const std::string& username,
148 const std::string& args); 149 const std::string& args);
149 virtual ~AutoLoginInfoBarDelegate(); 150 virtual ~AutoLoginInfoBarDelegate();
150 151
151 private: 152 private:
152 // ConfirmInfoBarDelegate overrides. 153 // ConfirmInfoBarDelegate overrides.
153 virtual gfx::Image* GetIcon() const OVERRIDE; 154 virtual gfx::Image* GetIcon() const OVERRIDE;
154 virtual Type GetInfoBarType() const OVERRIDE; 155 virtual Type GetInfoBarType() const OVERRIDE;
155 virtual string16 GetMessageText() const OVERRIDE; 156 virtual string16 GetMessageText() const OVERRIDE;
156 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 157 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
157 virtual bool Accept() OVERRIDE; 158 virtual bool Accept() OVERRIDE;
158 virtual bool Cancel() OVERRIDE; 159 virtual bool Cancel() OVERRIDE;
159 160
160 content::NavigationController* navigation_controller_; 161 NavigationController* navigation_controller_;
161 TokenService* token_service_; 162 TokenService* token_service_;
162 PrefService* pref_service_; 163 PrefService* pref_service_;
163 std::string username_; 164 std::string username_;
164 std::string args_; 165 std::string args_;
165 166
166 DISALLOW_COPY_AND_ASSIGN(AutoLoginInfoBarDelegate); 167 DISALLOW_COPY_AND_ASSIGN(AutoLoginInfoBarDelegate);
167 }; 168 };
168 169
169 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate( 170 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate(
170 InfoBarTabHelper* owner, 171 InfoBarTabHelper* owner,
171 content::NavigationController* navigation_controller, 172 NavigationController* navigation_controller,
172 TokenService* token_service, 173 TokenService* token_service,
173 PrefService* pref_service, 174 PrefService* pref_service,
174 const std::string& username, 175 const std::string& username,
175 const std::string& args) 176 const std::string& args)
176 : ConfirmInfoBarDelegate(owner), 177 : ConfirmInfoBarDelegate(owner),
177 navigation_controller_(navigation_controller), 178 navigation_controller_(navigation_controller),
178 token_service_(token_service), 179 token_service_(token_service),
179 pref_service_(pref_service), 180 pref_service_(pref_service),
180 username_(username), 181 username_(username),
181 args_(args) { 182 args_(args) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // AutoLoginPrompter ---------------------------------------------------------- 220 // AutoLoginPrompter ----------------------------------------------------------
220 221
221 AutoLoginPrompter::AutoLoginPrompter( 222 AutoLoginPrompter::AutoLoginPrompter(
222 WebContents* web_contents, 223 WebContents* web_contents,
223 const std::string& username, 224 const std::string& username,
224 const std::string& args) 225 const std::string& args)
225 : web_contents_(web_contents), 226 : web_contents_(web_contents),
226 username_(username), 227 username_(username),
227 args_(args) { 228 args_(args) {
228 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, 229 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP,
229 content::Source<content::NavigationController>( 230 content::Source<NavigationController>(
230 &web_contents_->GetController())); 231 &web_contents_->GetController()));
231 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 232 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
232 content::Source<WebContents>(web_contents_)); 233 content::Source<WebContents>(web_contents_));
233 } 234 }
234 235
235 AutoLoginPrompter::~AutoLoginPrompter() { 236 AutoLoginPrompter::~AutoLoginPrompter() {
236 } 237 }
237 238
238 // static 239 // static
239 void AutoLoginPrompter::ShowInfoBarIfPossible(net::URLRequest* request, 240 void AutoLoginPrompter::ShowInfoBarIfPossible(net::URLRequest* request,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 infobar_helper, &web_contents_->GetController(), 337 infobar_helper, &web_contents_->GetController(),
337 profile->GetTokenService(), profile->GetPrefs(), 338 profile->GetTokenService(), profile->GetPrefs(),
338 username_, args_)); 339 username_, args_));
339 } 340 }
340 } 341 }
341 // Either we couldn't add the infobar, we added the infobar, or the tab 342 // 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 343 // contents was destroyed before the navigation completed. In any case
343 // there's no reason to live further. 344 // there's no reason to live further.
344 delete this; 345 delete this;
345 } 346 }
OLDNEW
« no previous file with comments | « chrome/browser/translate/translate_manager_browsertest.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698