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

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 comments Created 4 years, 5 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
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" 7 #include "chrome/browser/signin/signin_promo.h"
8 #include "chrome/common/url_constants.h"
8 #include "components/guest_view/browser/guest_view_manager.h" 9 #include "components/guest_view/browser/guest_view_manager.h"
9 #include "google_apis/gaia/gaia_urls.h" 10 #include "google_apis/gaia/gaia_urls.h"
10 11
11 namespace { 12 namespace {
12 13
13 bool AddToSet(std::set<content::WebContents*>* content_set, 14 bool AddToSet(std::set<content::WebContents*>* content_set,
14 content::WebContents* web_contents) { 15 content::WebContents* web_contents) {
15 content_set->insert(web_contents); 16 content_set->insert(web_contents);
16 return false; 17 return false;
17 } 18 }
18 19
19 } // namespace 20 } // namespace
20 21
21 UserManager::ReauthDialogObserver::ReauthDialogObserver( 22 UserManager::BaseReauthDialogDelegate::BaseReauthDialogDelegate(
22 content::WebContents* web_contents, const std::string& email_address) 23 content::WebContents* web_contents) : web_contents_(web_contents) {}
sky 2016/07/22 22:29:01 Why do you set the delegate on line 53 instead of
Moe 2016/07/22 23:56:56 The delegate is set similarly in the cocoa logic.
23 : email_address_(email_address) { 24
24 // Observe navigations of the web contents so that the dialog can close itself 25 bool UserManager::BaseReauthDialogDelegate::HandleContextMenu(
25 // when the sign in process is done. 26 const content::ContextMenuParams& params) {
26 Observe(web_contents); 27 // Ignores context menu.
28 return true;
27 } 29 }
28 30
29 void UserManager::ReauthDialogObserver::DidStopLoading() { 31
30 // If the sign in process reaches the termination URL, close the dialog. 32 void UserManager::BaseReauthDialogDelegate::LoadingStateChanged(
31 // Make sure to remove any parts of the URL that gaia might append during 33 content::WebContents* source, bool to_different_document) {
32 // signin. 34 if (source->IsLoading())
33 GURL url = web_contents()->GetURL();
34 url::Replacements<char> replacements;
35 replacements.ClearQuery();
36 replacements.ClearRef();
37 if (url.ReplaceComponents(replacements) ==
sky 2016/07/22 22:29:01 How come you're changing this code? The descriptio
Moe 2016/07/22 23:56:56 I mentioned in a comment in the initial patch that
38 GaiaUrls::GetInstance()->signin_completed_continue_url()) {
39 CloseReauthDialog();
40 return; 35 return;
41 }
42 36
43 // If still observing the top level web contents, try to find the embedded 37 // If still observing the top level web contents, try to find the embedded
44 // webview and observe it instead. The webview may not be found in the 38 // webview and observe it instead. The webview may not be found in the
45 // initial page load since it loads asynchronously. 39 // initial page load since it loads asynchronously.
46 if (url.GetOrigin() != 40 GURL url = web_contents_->GetURL();
47 signin::GetReauthURLWithEmail( 41 if (url.GetOrigin() != GURL(std::string(chrome::kChromeUIChromeSigninURL)))
sky 2016/07/22 22:29:01 Do you really need the std::string here?
Moe 2016/07/22 23:56:56 Not really. Removed.
48 signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER,
49 signin_metrics::Reason::REASON_UNLOCK, email_address_)
50 .GetOrigin()) {
51 return; 42 return;
52 }
53 43
54 std::set<content::WebContents*> content_set; 44 std::set<content::WebContents*> content_set;
55 guest_view::GuestViewManager* manager = 45 guest_view::GuestViewManager* manager =
56 guest_view::GuestViewManager::FromBrowserContext( 46 guest_view::GuestViewManager::FromBrowserContext(
57 web_contents()->GetBrowserContext()); 47 web_contents_->GetBrowserContext());
58 if (manager) 48 if (manager)
59 manager->ForEachGuest(web_contents(), base::Bind(&AddToSet, &content_set)); 49 manager->ForEachGuest(web_contents_, base::Bind(&AddToSet, &content_set));
60 DCHECK_LE(content_set.size(), 1U); 50 DCHECK_LE(content_set.size(), 1U);
61 if (!content_set.empty()) 51 if (!content_set.empty()) {
62 Observe(*content_set.begin()); 52 web_contents_ = *content_set.begin();
53 web_contents_->SetDelegate(this);
54 }
63 } 55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698