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

Side by Side Diff: chrome/browser/net/url_fixer_upper.h

Issue 7068007: Revise about: and chrome: url handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments and add extra crash URL checks. Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_NET_URL_FIXER_UPPER_H_ 5 #ifndef CHROME_BROWSER_NET_URL_FIXER_UPPER_H_
6 #define CHROME_BROWSER_NET_URL_FIXER_UPPER_H_ 6 #define CHROME_BROWSER_NET_URL_FIXER_UPPER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // possibly_invalid_spec(). 42 // possibly_invalid_spec().
43 // 43 //
44 // If |desired_tld| is non-empty, it represents the TLD the user wishes to 44 // If |desired_tld| is non-empty, it represents the TLD the user wishes to
45 // append in the case of an incomplete domain. We check that this is not a 45 // append in the case of an incomplete domain. We check that this is not a
46 // file path and there does not appear to be a valid TLD already, then append 46 // file path and there does not appear to be a valid TLD already, then append
47 // |desired_tld| to the domain and prepend "www." (unless it, or a scheme, 47 // |desired_tld| to the domain and prepend "www." (unless it, or a scheme,
48 // are already present.) This TLD should not have a leading '.' (use "com" 48 // are already present.) This TLD should not have a leading '.' (use "com"
49 // instead of ".com"). 49 // instead of ".com").
50 GURL FixupURL(const std::string& text, const std::string& desired_tld); 50 GURL FixupURL(const std::string& text, const std::string& desired_tld);
51 51
52 // Given |url| like about:foo, about://foo, chrome:foo, and chrome://foo, this
53 // returns the 'normalized' chrome://foo version of the URL. This chrome URL
54 // fixup probably shouldn't be performed in FixupURL, as that would break any
55 // extensions that perform URL overrides on the other chrome URL formats.
56 // Additionally, if the URL does not have a valid host, as in "about:", the
57 // returned URL will point to the host "version", as in "chrome://version".
58 GURL FixupChromeURL(const GURL& url);
59
52 // Converts |text| to a fixed-up URL, allowing it to be a relative path on 60 // Converts |text| to a fixed-up URL, allowing it to be a relative path on
53 // the local filesystem. Begin searching in |base_dir|; if empty, use the 61 // the local filesystem. Begin searching in |base_dir|; if empty, use the
54 // current working directory. If this resolves to a file on disk, convert it 62 // current working directory. If this resolves to a file on disk, convert it
55 // to a "file:" URL in |fixed_up_url|; otherwise, fall back to the behavior 63 // to a "file:" URL in |fixed_up_url|; otherwise, fall back to the behavior
56 // of FixupURL(). 64 // of FixupURL().
57 // 65 //
58 // For "regular" input, even if it is possibly a file with a full path, you 66 // For "regular" input, even if it is possibly a file with a full path, you
59 // should use FixupURL() directly. This function should only be used when 67 // should use FixupURL() directly. This function should only be used when
60 // relative path handling is desired, as for command line processing. 68 // relative path handling is desired, as for command line processing.
61 GURL FixupRelativeFile(const FilePath& base_dir, const FilePath& text); 69 GURL FixupRelativeFile(const FilePath& base_dir, const FilePath& text);
62 70
63 // Offsets the beginning index of |part| by |offset|, which is allowed to be 71 // Offsets the beginning index of |part| by |offset|, which is allowed to be
64 // negative. In some cases, the desired component does not exist at the given 72 // negative. In some cases, the desired component does not exist at the given
65 // offset. For example, when converting from "http://foo" to "foo", the 73 // offset. For example, when converting from "http://foo" to "foo", the
66 // scheme component no longer exists. In such a case, the beginning index is 74 // scheme component no longer exists. In such a case, the beginning index is
67 // set to 0. 75 // set to 0.
68 // Does nothing if |part| is invalid. 76 // Does nothing if |part| is invalid.
69 void OffsetComponent(int offset, url_parse::Component* part); 77 void OffsetComponent(int offset, url_parse::Component* part);
70 78
71 // For paths like ~, we use $HOME for the current user's home 79 // For paths like ~, we use $HOME for the current user's home
72 // directory. For tests, we allow our idea of $HOME to be overriden 80 // directory. For tests, we allow our idea of $HOME to be overriden
73 // by this variable. 81 // by this variable.
74 extern const char* home_directory_override; 82 extern const char* home_directory_override;
75 }; 83 };
76 84
77 #endif // CHROME_BROWSER_NET_URL_FIXER_UPPER_H_ 85 #endif // CHROME_BROWSER_NET_URL_FIXER_UPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698