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

Side by Side Diff: content/browser/browser_url_handler_impl.cc

Issue 27603004: Ported GpuCrashTest to Telemetry, renaming the test to ContextLost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed dtu's review feedback. Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/gpu/gpu_data_manager_impl_private.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 "content/browser/browser_url_handler_impl.h" 5 #include "content/browser/browser_url_handler_impl.h"
6 6
7 #include "base/command_line.h"
7 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "content/browser/web_contents/debug_urls.h"
8 #include "content/browser/webui/web_ui_impl.h" 10 #include "content/browser/webui/web_ui_impl.h"
9 #include "content/public/browser/content_browser_client.h" 11 #include "content/public/browser/content_browser_client.h"
12 #include "content/public/common/content_switches.h"
10 #include "content/public/common/url_constants.h" 13 #include "content/public/common/url_constants.h"
11 #include "url/gurl.h" 14 #include "url/gurl.h"
12 15
13 namespace content { 16 namespace content {
14 17
15 // Handles rewriting view-source URLs for what we'll actually load. 18 // Handles rewriting view-source URLs for what we'll actually load.
16 static bool HandleViewSource(GURL* url, BrowserContext* browser_context) { 19 static bool HandleViewSource(GURL* url, BrowserContext* browser_context) {
17 if (url->SchemeIs(kViewSourceScheme)) { 20 if (url->SchemeIs(kViewSourceScheme)) {
18 // Load the inner URL instead. 21 // Load the inner URL instead.
19 *url = GURL(url->path()); 22 *url = GURL(url->path());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 55
53 url_canon::Replacements<char> repl; 56 url_canon::Replacements<char> repl;
54 repl.SetScheme(kViewSourceScheme, 57 repl.SetScheme(kViewSourceScheme,
55 url_parse::Component(0, strlen(kViewSourceScheme))); 58 url_parse::Component(0, strlen(kViewSourceScheme)));
56 repl.SetPath(url->spec().c_str(), 59 repl.SetPath(url->spec().c_str(),
57 url_parse::Component(0, url->spec().size())); 60 url_parse::Component(0, url->spec().size()));
58 *url = url->ReplaceComponents(repl); 61 *url = url->ReplaceComponents(repl);
59 return true; 62 return true;
60 } 63 }
61 64
62 static bool HandleDebugUrl(GURL* url, BrowserContext* browser_context) { 65 static bool DebugURLHandler(GURL* url, BrowserContext* browser_context) {
66 // If running inside the Telemetry test harness, allow automated
67 // navigations to access browser-side debug URLs. They must use the
68 // chrome:// scheme, since the about: scheme won't be rewritten in
69 // this code path.
70 if (CommandLine::ForCurrentProcess()->HasSwitch(
71 switches::kEnableGpuBenchmarking)) {
72 if (HandleDebugURL(*url, PAGE_TRANSITION_FROM_ADDRESS_BAR)) {
73 return true;
74 }
75 }
76
63 // Circumvent processing URLs that the renderer process will handle. 77 // Circumvent processing URLs that the renderer process will handle.
64 return *url == GURL(kChromeUICrashURL) || 78 return *url == GURL(kChromeUICrashURL) ||
65 *url == GURL(kChromeUIHangURL) || 79 *url == GURL(kChromeUIHangURL) ||
66 *url == GURL(kChromeUIKillURL) || 80 *url == GURL(kChromeUIKillURL) ||
67 *url == GURL(kChromeUIShorthangURL); 81 *url == GURL(kChromeUIShorthangURL);
68 } 82 }
69 83
70 // static 84 // static
71 BrowserURLHandler* BrowserURLHandler::GetInstance() { 85 BrowserURLHandler* BrowserURLHandler::GetInstance() {
72 return BrowserURLHandlerImpl::GetInstance(); 86 return BrowserURLHandlerImpl::GetInstance();
73 } 87 }
74 88
75 // static 89 // static
76 BrowserURLHandler::URLHandler BrowserURLHandler::null_handler() { 90 BrowserURLHandler::URLHandler BrowserURLHandler::null_handler() {
77 // Required for VS2010: http://connect.microsoft.com/VisualStudio/feedback/det ails/520043/error-converting-from-null-to-a-pointer-type-in-std-pair 91 // Required for VS2010: http://connect.microsoft.com/VisualStudio/feedback/det ails/520043/error-converting-from-null-to-a-pointer-type-in-std-pair
78 return NULL; 92 return NULL;
79 } 93 }
80 94
81 // static 95 // static
82 BrowserURLHandlerImpl* BrowserURLHandlerImpl::GetInstance() { 96 BrowserURLHandlerImpl* BrowserURLHandlerImpl::GetInstance() {
83 return Singleton<BrowserURLHandlerImpl>::get(); 97 return Singleton<BrowserURLHandlerImpl>::get();
84 } 98 }
85 99
86 BrowserURLHandlerImpl::BrowserURLHandlerImpl() { 100 BrowserURLHandlerImpl::BrowserURLHandlerImpl() {
87 AddHandlerPair(&HandleDebugUrl, BrowserURLHandlerImpl::null_handler()); 101 AddHandlerPair(&DebugURLHandler, BrowserURLHandlerImpl::null_handler());
88 102
89 GetContentClient()->browser()->BrowserURLHandlerCreated(this); 103 GetContentClient()->browser()->BrowserURLHandlerCreated(this);
90 104
91 // view-source: 105 // view-source:
92 AddHandlerPair(&HandleViewSource, &ReverseViewSource); 106 AddHandlerPair(&HandleViewSource, &ReverseViewSource);
93 } 107 }
94 108
95 BrowserURLHandlerImpl::~BrowserURLHandlerImpl() { 109 BrowserURLHandlerImpl::~BrowserURLHandlerImpl() {
96 } 110 }
97 111
(...skipping 27 matching lines...) Expand all
125 return true; 139 return true;
126 } else if (handler(&test_url, browser_context)) { 140 } else if (handler(&test_url, browser_context)) {
127 return reverse_rewriter(url, browser_context); 141 return reverse_rewriter(url, browser_context);
128 } 142 }
129 } 143 }
130 } 144 }
131 return false; 145 return false;
132 } 146 }
133 147
134 } // namespace content 148 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/gpu/gpu_data_manager_impl_private.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698