OLD | NEW |
---|---|
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/command_line.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "cc/base/switches.h" | 9 #include "cc/base/switches.h" |
10 #include "content/browser/frame_host/debug_urls.h" | 10 #include "content/browser/frame_host/debug_urls.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 return false; | 66 return false; |
67 | 67 |
68 url::Replacements<char> repl; | 68 url::Replacements<char> repl; |
69 repl.SetScheme(kViewSourceScheme, | 69 repl.SetScheme(kViewSourceScheme, |
70 url::Component(0, strlen(kViewSourceScheme))); | 70 url::Component(0, strlen(kViewSourceScheme))); |
71 repl.SetPath(url->spec().c_str(), url::Component(0, url->spec().size())); | 71 repl.SetPath(url->spec().c_str(), url::Component(0, url->spec().size())); |
72 *url = url->ReplaceComponents(repl); | 72 *url = url->ReplaceComponents(repl); |
73 return true; | 73 return true; |
74 } | 74 } |
75 | 75 |
76 static bool DebugURLHandler(GURL* url, BrowserContext* browser_context) { | |
77 // If running inside the Telemetry test harness, allow automated | |
78 // navigations to access browser-side debug URLs. They must use the | |
79 // chrome:// scheme, since the about: scheme won't be rewritten in | |
80 // this code path. | |
81 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
82 cc::switches::kEnableGpuBenchmarking)) { | |
83 if (HandleDebugURL(*url, PAGE_TRANSITION_FROM_ADDRESS_BAR)) { | |
84 return true; | |
85 } | |
86 } | |
87 | |
88 // Circumvent processing URLs that the renderer process will handle. | |
89 return IsRendererDebugURL(*url); | |
Charlie Reis
2014/07/23 23:04:17
Why is this ok to delete?
Ken Russell (switch to Gerrit)
2014/07/23 23:08:43
Yes, that's a good point. This should instead be r
vmiura
2014/07/23 23:39:59
Done. I'm not sure what that's there for, but I d
| |
90 } | |
91 | |
92 // static | 76 // static |
93 BrowserURLHandler* BrowserURLHandler::GetInstance() { | 77 BrowserURLHandler* BrowserURLHandler::GetInstance() { |
94 return BrowserURLHandlerImpl::GetInstance(); | 78 return BrowserURLHandlerImpl::GetInstance(); |
95 } | 79 } |
96 | 80 |
97 // static | 81 // static |
98 BrowserURLHandler::URLHandler BrowserURLHandler::null_handler() { | 82 BrowserURLHandler::URLHandler BrowserURLHandler::null_handler() { |
99 // Required for VS2010: http://connect.microsoft.com/VisualStudio/feedback/det ails/520043/error-converting-from-null-to-a-pointer-type-in-std-pair | 83 // Required for VS2010: http://connect.microsoft.com/VisualStudio/feedback/det ails/520043/error-converting-from-null-to-a-pointer-type-in-std-pair |
100 return NULL; | 84 return NULL; |
101 } | 85 } |
102 | 86 |
103 // static | 87 // static |
104 BrowserURLHandlerImpl* BrowserURLHandlerImpl::GetInstance() { | 88 BrowserURLHandlerImpl* BrowserURLHandlerImpl::GetInstance() { |
105 return Singleton<BrowserURLHandlerImpl>::get(); | 89 return Singleton<BrowserURLHandlerImpl>::get(); |
106 } | 90 } |
107 | 91 |
108 BrowserURLHandlerImpl::BrowserURLHandlerImpl() { | 92 BrowserURLHandlerImpl::BrowserURLHandlerImpl() { |
109 AddHandlerPair(&DebugURLHandler, BrowserURLHandlerImpl::null_handler()); | |
110 | |
111 GetContentClient()->browser()->BrowserURLHandlerCreated(this); | 93 GetContentClient()->browser()->BrowserURLHandlerCreated(this); |
112 | 94 |
113 // view-source: | 95 // view-source: |
114 AddHandlerPair(&HandleViewSource, &ReverseViewSource); | 96 AddHandlerPair(&HandleViewSource, &ReverseViewSource); |
115 } | 97 } |
116 | 98 |
117 BrowserURLHandlerImpl::~BrowserURLHandlerImpl() { | 99 BrowserURLHandlerImpl::~BrowserURLHandlerImpl() { |
118 } | 100 } |
119 | 101 |
120 void BrowserURLHandlerImpl::AddHandlerPair(URLHandler handler, | 102 void BrowserURLHandlerImpl::AddHandlerPair(URLHandler handler, |
(...skipping 26 matching lines...) Expand all Loading... | |
147 return true; | 129 return true; |
148 } else if (handler(&test_url, browser_context)) { | 130 } else if (handler(&test_url, browser_context)) { |
149 return reverse_rewriter(url, browser_context); | 131 return reverse_rewriter(url, browser_context); |
150 } | 132 } |
151 } | 133 } |
152 } | 134 } |
153 return false; | 135 return false; |
154 } | 136 } |
155 | 137 |
156 } // namespace content | 138 } // namespace content |
OLD | NEW |