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

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

Issue 2168953002: Disables the context menu in User Manager's reauth dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment Created 4 years, 4 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 | « chrome/browser/ui/user_manager.h ('k') | chrome/browser/ui/views/profiles/user_manager_view.h » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/user_manager.h" 5 #include "chrome/browser/ui/user_manager.h"
6 6
7 #include "chrome/browser/signin/signin_promo.h"
8 #include "components/guest_view/browser/guest_view_manager.h" 7 #include "components/guest_view/browser/guest_view_manager.h"
9 #include "google_apis/gaia/gaia_urls.h"
10 8
11 namespace { 9 namespace {
12 10
13 bool AddToSet(std::set<content::WebContents*>* content_set, 11 bool AddToSet(std::set<content::WebContents*>* content_set,
14 content::WebContents* web_contents) { 12 content::WebContents* web_contents) {
15 content_set->insert(web_contents); 13 content_set->insert(web_contents);
16 return false; 14 return false;
17 } 15 }
18 16
19 } // namespace 17 } // namespace
20 18
21 UserManager::ReauthDialogObserver::ReauthDialogObserver( 19 UserManager::BaseReauthDialogDelegate::BaseReauthDialogDelegate()
22 content::WebContents* web_contents, const std::string& email_address) 20 : guest_web_contents_(nullptr) {}
23 : email_address_(email_address) { 21
24 // Observe navigations of the web contents so that the dialog can close itself 22 bool UserManager::BaseReauthDialogDelegate::HandleContextMenu(
25 // when the sign in process is done. 23 const content::ContextMenuParams& params) {
26 Observe(web_contents); 24 // Ignores context menu.
25 return true;
27 } 26 }
28 27
29 void UserManager::ReauthDialogObserver::DidStopLoading() { 28 void UserManager::BaseReauthDialogDelegate::LoadingStateChanged(
30 // If the sign in process reaches the termination URL, close the dialog. 29 content::WebContents* source, bool to_different_document) {
31 // Make sure to remove any parts of the URL that gaia might append during 30 if (source->IsLoading() || guest_web_contents_)
32 // signin.
33 GURL url = web_contents()->GetURL();
34 url::Replacements<char> replacements;
35 replacements.ClearQuery();
36 replacements.ClearRef();
37 if (url.ReplaceComponents(replacements) ==
38 GaiaUrls::GetInstance()->signin_completed_continue_url()) {
39 CloseReauthDialog();
40 return; 31 return;
41 }
42 32
43 // If still observing the top level web contents, try to find the embedded 33 // Try to find the embedded WebView and manage its WebContents. The WebView
44 // webview and observe it instead. The webview may not be found in the 34 // may not be found in the initial page load since it loads asynchronously.
45 // initial page load since it loads asynchronously.
46 if (url.GetOrigin() !=
47 signin::GetReauthURLWithEmail(
48 signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER,
49 signin_metrics::Reason::REASON_UNLOCK, email_address_)
50 .GetOrigin()) {
51 return;
52 }
53
54 std::set<content::WebContents*> content_set; 35 std::set<content::WebContents*> content_set;
55 guest_view::GuestViewManager* manager = 36 guest_view::GuestViewManager* manager =
56 guest_view::GuestViewManager::FromBrowserContext( 37 guest_view::GuestViewManager::FromBrowserContext(
57 web_contents()->GetBrowserContext()); 38 source->GetBrowserContext());
58 if (manager) 39 if (manager)
59 manager->ForEachGuest(web_contents(), base::Bind(&AddToSet, &content_set)); 40 manager->ForEachGuest(source, base::Bind(&AddToSet, &content_set));
60 DCHECK_LE(content_set.size(), 1U); 41 DCHECK_LE(content_set.size(), 1U);
61 if (!content_set.empty()) 42 if (!content_set.empty()) {
62 Observe(*content_set.begin()); 43 guest_web_contents_ = *content_set.begin();
44 guest_web_contents_->SetDelegate(this);
45 }
63 } 46 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/user_manager.h ('k') | chrome/browser/ui/views/profiles/user_manager_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698