| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/signin_view_controller_delegate.h" | 5 #include "chrome/browser/ui/signin_view_controller_delegate.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/ui/signin_view_controller.h" | 9 #include "chrome/browser/ui/signin_view_controller.h" |
| 10 #include "chrome/browser/ui/webui/signin/get_auth_frame.h" | 10 #include "chrome/browser/ui/webui/signin/get_auth_frame.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 web_contents_->SetDelegate(this); | 27 web_contents_->SetDelegate(this); |
| 28 } | 28 } |
| 29 | 29 |
| 30 SigninViewControllerDelegate::~SigninViewControllerDelegate() {} | 30 SigninViewControllerDelegate::~SigninViewControllerDelegate() {} |
| 31 | 31 |
| 32 void SigninViewControllerDelegate::CloseModalSignin() { | 32 void SigninViewControllerDelegate::CloseModalSignin() { |
| 33 ResetSigninViewControllerDelegate(); | 33 ResetSigninViewControllerDelegate(); |
| 34 PerformClose(); | 34 PerformClose(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void SigninViewControllerDelegate::PerformNavigation() { |
| 38 if (CanGoBack(web_contents_)) { |
| 39 auto auth_web_contents = GetAuthFrameWebContents(web_contents_); |
| 40 auth_web_contents->GetController().GoBack(); |
| 41 } else { |
| 42 CloseModalSignin(); |
| 43 } |
| 44 } |
| 45 |
| 46 bool SigninViewControllerDelegate::HandleContextMenu( |
| 47 const content::ContextMenuParams& params) { |
| 48 // Discard the context menu |
| 49 return true; |
| 50 } |
| 51 |
| 37 void SigninViewControllerDelegate::ResetSigninViewControllerDelegate() { | 52 void SigninViewControllerDelegate::ResetSigninViewControllerDelegate() { |
| 38 if (signin_view_controller_) { | 53 if (signin_view_controller_) { |
| 39 signin_view_controller_->ResetModalSigninDelegate(); | 54 signin_view_controller_->ResetModalSigninDelegate(); |
| 40 signin_view_controller_ = nullptr; | 55 signin_view_controller_ = nullptr; |
| 41 } | 56 } |
| 42 } | 57 } |
| 43 | 58 |
| 44 bool SigninViewControllerDelegate::CanGoBack( | |
| 45 content::WebContents* web_ui_web_contents) const { | |
| 46 auto auth_web_contents = GetAuthFrameWebContents(web_ui_web_contents); | |
| 47 return auth_web_contents && auth_web_contents->GetController().CanGoBack(); | |
| 48 } | |
| 49 | |
| 50 // content::WebContentsDelegate | 59 // content::WebContentsDelegate |
| 51 void SigninViewControllerDelegate::LoadingStateChanged( | 60 void SigninViewControllerDelegate::LoadingStateChanged( |
| 52 content::WebContents* source, | 61 content::WebContents* source, |
| 53 bool to_different_document) { | 62 bool to_different_document) { |
| 54 if (CanGoBack(source)) | 63 if (CanGoBack(source)) |
| 55 source->GetWebUI()->CallJavascriptFunctionUnsafe( | 64 source->GetWebUI()->CallJavascriptFunctionUnsafe( |
| 56 "inline.login.showBackButton"); | 65 "inline.login.showBackButton"); |
| 57 else | 66 else |
| 58 source->GetWebUI()->CallJavascriptFunctionUnsafe( | 67 source->GetWebUI()->CallJavascriptFunctionUnsafe( |
| 59 "inline.login.showCloseButton"); | 68 "inline.login.showCloseButton"); |
| 60 } | 69 } |
| 61 | 70 |
| 62 void SigninViewControllerDelegate::PerformNavigation() { | 71 bool SigninViewControllerDelegate::CanGoBack( |
| 63 if (CanGoBack(web_contents_)) { | 72 content::WebContents* web_ui_web_contents) const { |
| 64 auto auth_web_contents = GetAuthFrameWebContents(web_contents_); | 73 auto auth_web_contents = GetAuthFrameWebContents(web_ui_web_contents); |
| 65 auth_web_contents->GetController().GoBack(); | 74 return auth_web_contents && auth_web_contents->GetController().CanGoBack(); |
| 66 } else { | |
| 67 CloseModalSignin(); | |
| 68 } | |
| 69 } | 75 } |
| OLD | NEW |