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

Side by Side Diff: chrome/browser/resource_coordinator/tab_navigation_throttle.cc

Issue 2931023002: [TooManyTabs] Add TabNavigationThrottle (Closed)
Patch Set: Created 3 years, 6 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/resource_coordinator/tab_navigation_throttle.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/resource_coordinator/tab_manager.h"
11 #include "chrome/browser/search/search.h"
12 #include "content/public/browser/navigation_handle.h"
13 #include "content/public/browser/web_contents.h"
14
15 namespace resource_coordinator {
16
17 // static
18 std::unique_ptr<TabNavigationThrottle>
19 TabNavigationThrottle::MaybeCreateThrottleFor(
20 content::NavigationHandle* navigation_handle) {
21 // Only consider throttling common URLs, i.e., HTTP/HTTPS and common
22 // chrome:// UI URLs, for main frames.
Charlie Reis 2017/06/10 00:53:36 I'm curious, what's the motivation for this? We'v
Zhen Wang 2017/06/13 23:33:21 My actual intention is to exclude all non-tab navi
Zhen Wang 2017/06/19 23:00:12 Ping.
Charlie Reis 2017/07/06 23:50:30 I'm not sure I understand what you mean. chrome-e
23 if (!navigation_handle->IsInMainFrame() ||
24 (!navigation_handle->GetURL().SchemeIsHTTPOrHTTPS() &&
25 !TabManager::IsInternalPage(navigation_handle->GetURL()))) {
26 return nullptr;
27 }
28
29 // Do not delay the NTP, which in some cases has an HTTPS URL.
30 if (search::IsNTPURL(
31 navigation_handle->GetURL(),
32 Profile::FromBrowserContext(
33 navigation_handle->GetWebContents()->GetBrowserContext()))) {
34 return nullptr;
35 }
36
37 return base::MakeUnique<TabNavigationThrottle>(navigation_handle);
Charlie Reis 2017/06/10 00:53:36 It seems like we're creating this throttle in a lo
Zhen Wang 2017/06/13 23:33:21 Thanks for the pointers! Added restriction on firs
Charlie Reis 2017/07/06 23:50:30 SiteInstanceImpl::active_frame_count() says how ma
Zhen Wang 2017/07/07 18:06:39 active_frame_count is not exposed as a public cont
Charlie Reis 2017/07/07 22:07:55 Ah, I'd forgotten we're not in content here. Neve
38 }
39
40 const char* TabNavigationThrottle::GetNameForLogging() {
41 return "TabNavigationThrottle";
42 }
43
44 TabNavigationThrottle::TabNavigationThrottle(
45 content::NavigationHandle* navigation_handle)
46 : content::NavigationThrottle(navigation_handle) {}
47
48 TabNavigationThrottle::~TabNavigationThrottle() {}
49
50 content::NavigationThrottle::ThrottleCheckResult
51 TabNavigationThrottle::WillStartRequest() {
52 return g_browser_process->GetTabManager()->MaybeThrottleNavigation(
53 navigation_handle());
54 }
55
56 } // namespace resource_coordinator
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698