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

Side by Side Diff: chrome/browser/extensions/navigation_observer.cc

Issue 2889003002: Change NavigationEntry to use virtual URL in error pages for blocked navigations (Closed)
Patch Set: Add back reload test (PlzNavigate only) and address review comments. Created 3 years, 7 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 | « no previous file | content/browser/browser_side_navigation_browsertest.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) 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/extensions/navigation_observer.h" 5 #include "chrome/browser/extensions/navigation_observer.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "content/public/browser/navigation_controller.h" 10 #include "content/public/browser/navigation_controller.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 void NavigationObserver::PromptToEnableExtensionIfNecessary( 62 void NavigationObserver::PromptToEnableExtensionIfNecessary(
63 NavigationController* nav_controller) { 63 NavigationController* nav_controller) {
64 // Bail out if we're already running a prompt. 64 // Bail out if we're already running a prompt.
65 if (!in_progress_prompt_extension_id_.empty()) 65 if (!in_progress_prompt_extension_id_.empty())
66 return; 66 return;
67 67
68 NavigationEntry* nav_entry = nav_controller->GetVisibleEntry(); 68 NavigationEntry* nav_entry = nav_controller->GetVisibleEntry();
69 if (!nav_entry) 69 if (!nav_entry)
70 return; 70 return;
71 71
72 const GURL& url = nav_entry->GetURL(); 72 // With a disabled extension, the navigation is blocked, which results in
73 // a NavigationEntry with "about:blank" URL. In this case, the virtual
74 // URL is the real URL the user navigated to, so if it is non-empty, use
75 // it instead.
76 const GURL& url = nav_entry->GetVirtualURL().is_empty()
Charlie Reis 2017/05/24 21:50:52 This condition makes me nervous. If GetURL is an
nasko 2017/05/24 22:16:41 Fixed by combining all 3 checks.
77 ? nav_entry->GetURL()
78 : nav_entry->GetVirtualURL();
79
73 // NOTE: We only consider chrome-extension:// urls, and deliberately don't 80 // NOTE: We only consider chrome-extension:// urls, and deliberately don't
74 // consider hosted app urls. This is because it's really annoying to visit the 81 // consider hosted app urls. This is because it's really annoying to visit the
75 // site associated with a hosted app (like calendar.google.com or 82 // site associated with a hosted app (like calendar.google.com or
76 // drive.google.com) and have it repeatedly prompt you to re-enable an item. 83 // drive.google.com) and have it repeatedly prompt you to re-enable an item.
77 // Visiting a chrome-extension:// url is a much stronger signal, and, without 84 // Visiting a chrome-extension:// url is a much stronger signal, and, without
78 // the item enabled, we won't show anything. 85 // the item enabled, we won't show anything.
79 // TODO(devlin): While true, I still wonder how useful this is. We should get 86 // TODO(devlin): While true, I still wonder how useful this is. We should get
80 // metrics. 87 // metrics.
81 if (!url.SchemeIs(kExtensionScheme)) 88 if (!url.SchemeIs(kExtensionScheme))
82 return; 89 return;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 in_progress_prompt_extension_id_ != extension->id()) { 169 in_progress_prompt_extension_id_ != extension->id()) {
163 return; 170 return;
164 } 171 }
165 172
166 in_progress_prompt_extension_id_ = std::string(); 173 in_progress_prompt_extension_id_ = std::string();
167 in_progress_prompt_navigation_controller_ = nullptr; 174 in_progress_prompt_navigation_controller_ = nullptr;
168 extension_install_prompt_.reset(); 175 extension_install_prompt_.reset();
169 } 176 }
170 177
171 } // namespace extensions 178 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | content/browser/browser_side_navigation_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698