Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/login/login_prompt.h" | 5 #include "chrome/browser/ui/login/login_prompt.h" |
| 6 | 6 |
| 7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/password_manager/password_manager.h" | 9 #include "chrome/browser/password_manager/password_manager.h" |
| 10 #include "chrome/browser/tab_contents/tab_util.h" | 10 #include "chrome/browser/tab_contents/tab_util.h" |
| 11 #include "chrome/browser/ui/views/constrained_window_views.h" | 11 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 12 #include "chrome/browser/ui/views/login_view.h" | 12 #include "chrome/browser/ui/views/login_view.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "components/web_modal/web_contents_modal_dialog_host.h" | 14 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 15 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 15 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 16 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | 16 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
| 19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/browser/web_contents_view.h" | |
| 21 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| 22 #include "net/url_request/url_request.h" | 21 #include "net/url_request/url_request.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 25 #include "ui/views/window/dialog_delegate.h" | 24 #include "ui/views/window/dialog_delegate.h" |
| 26 | 25 |
| 27 using autofill::PasswordForm; | 26 using autofill::PasswordForm; |
| 28 using content::BrowserThread; | 27 using content::BrowserThread; |
| 29 using content::WebContents; | 28 using content::WebContents; |
| 30 using web_modal::WebContentsModalDialogManager; | 29 using web_modal::WebContentsModalDialogManager; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 // Scary thread safety note: This can potentially be called *after* SetAuth | 149 // Scary thread safety note: This can potentially be called *after* SetAuth |
| 151 // or CancelAuth (say, if the request was cancelled before the UI thread got | 150 // or CancelAuth (say, if the request was cancelled before the UI thread got |
| 152 // control). However, that's OK since any UI interaction in those functions | 151 // control). However, that's OK since any UI interaction in those functions |
| 153 // will occur via an InvokeLater on the UI thread, which is guaranteed | 152 // will occur via an InvokeLater on the UI thread, which is guaranteed |
| 154 // to happen after this is called (since this was InvokeLater'd first). | 153 // to happen after this is called (since this was InvokeLater'd first). |
| 155 WebContents* requesting_contents = GetWebContentsForLogin(); | 154 WebContents* requesting_contents = GetWebContentsForLogin(); |
| 156 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 155 WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
| 157 WebContentsModalDialogManager::FromWebContents(requesting_contents); | 156 WebContentsModalDialogManager::FromWebContents(requesting_contents); |
| 158 WebContentsModalDialogManagerDelegate* modal_delegate = | 157 WebContentsModalDialogManagerDelegate* modal_delegate = |
| 159 web_contents_modal_dialog_manager->delegate(); | 158 web_contents_modal_dialog_manager->delegate(); |
| 160 CHECK(modal_delegate); | |
|
sky
2013/11/16 03:03:16
and here
msw
2013/11/16 04:15:44
Done.
| |
| 161 dialog_ = views::Widget::CreateWindowAsFramelessChild( | 159 dialog_ = views::Widget::CreateWindowAsFramelessChild( |
| 162 this, | 160 this, modal_delegate->GetWebContentsModalDialogHost()->GetHostView()); |
| 163 requesting_contents->GetView()->GetNativeView(), | |
| 164 modal_delegate->GetWebContentsModalDialogHost()->GetHostView()); | |
| 165 web_contents_modal_dialog_manager->ShowDialog(dialog_->GetNativeView()); | 161 web_contents_modal_dialog_manager->ShowDialog(dialog_->GetNativeView()); |
| 166 NotifyAuthNeeded(); | 162 NotifyAuthNeeded(); |
| 167 } | 163 } |
| 168 | 164 |
| 169 virtual void CloseDialog() OVERRIDE { | 165 virtual void CloseDialog() OVERRIDE { |
| 170 // The hosting widget may have been freed. | 166 // The hosting widget may have been freed. |
| 171 if (dialog_) | 167 if (dialog_) |
| 172 dialog_->Close(); | 168 dialog_->Close(); |
| 173 } | 169 } |
| 174 | 170 |
| 175 private: | 171 private: |
| 176 friend class base::RefCountedThreadSafe<LoginHandlerViews>; | 172 friend class base::RefCountedThreadSafe<LoginHandlerViews>; |
| 177 friend class LoginPrompt; | 173 friend class LoginPrompt; |
| 178 | 174 |
| 179 virtual ~LoginHandlerViews() {} | 175 virtual ~LoginHandlerViews() {} |
| 180 | 176 |
| 181 // The LoginView that contains the user's login information | 177 // The LoginView that contains the user's login information |
| 182 LoginView* login_view_; | 178 LoginView* login_view_; |
| 183 | 179 |
| 184 views::Widget* dialog_; | 180 views::Widget* dialog_; |
| 185 | 181 |
| 186 DISALLOW_COPY_AND_ASSIGN(LoginHandlerViews); | 182 DISALLOW_COPY_AND_ASSIGN(LoginHandlerViews); |
| 187 }; | 183 }; |
| 188 | 184 |
| 189 // static | 185 // static |
| 190 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, | 186 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, |
| 191 net::URLRequest* request) { | 187 net::URLRequest* request) { |
| 192 return new LoginHandlerViews(auth_info, request); | 188 return new LoginHandlerViews(auth_info, request); |
| 193 } | 189 } |
| OLD | NEW |