OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/public/common/url_utils.h" | 5 #include "content/public/common/url_utils.h" |
6 | 6 |
7 #include "base/base_switches.h" | |
8 #include "base/command_line.h" | |
9 #include "base/logging.h" | |
10 #include "build/build_config.h" | 7 #include "build/build_config.h" |
11 #include "content/common/savable_url_schemes.h" | 8 #include "content/common/savable_url_schemes.h" |
12 #include "content/public/common/content_switches.h" | |
13 #include "content/public/common/url_constants.h" | 9 #include "content/public/common/url_constants.h" |
14 #include "url/gurl.h" | 10 #include "url/gurl.h" |
15 | 11 |
16 namespace content { | 12 namespace content { |
17 | 13 |
18 static size_t g_max_url_size = 2 * 1024 * 1024; | |
19 | |
20 const char* const* GetSavableSchemes() { | 14 const char* const* GetSavableSchemes() { |
21 return GetSavableSchemesInternal(); | 15 return GetSavableSchemesInternal(); |
22 } | 16 } |
23 | 17 |
24 bool HasWebUIScheme(const GURL& url) { | 18 bool HasWebUIScheme(const GURL& url) { |
25 return | 19 return |
26 #if !defined(OS_IOS) | 20 #if !defined(OS_IOS) |
27 url.SchemeIs(kChromeDevToolsScheme) || | 21 url.SchemeIs(kChromeDevToolsScheme) || |
28 #endif | 22 #endif |
29 url.SchemeIs(kChromeUIScheme); | 23 url.SchemeIs(kChromeUIScheme); |
30 } | 24 } |
31 | 25 |
32 bool IsSavableURL(const GURL& url) { | 26 bool IsSavableURL(const GURL& url) { |
33 for (int i = 0; GetSavableSchemes()[i] != NULL; ++i) { | 27 for (int i = 0; GetSavableSchemes()[i] != NULL; ++i) { |
34 if (url.SchemeIs(GetSavableSchemes()[i])) | 28 if (url.SchemeIs(GetSavableSchemes()[i])) |
35 return true; | 29 return true; |
36 } | 30 } |
37 return false; | 31 return false; |
38 } | 32 } |
39 | 33 |
40 #if defined(OS_ANDROID) | |
41 void SetMaxURLChars(size_t max_chars) { | |
42 // Check that it is not used by a multiprocesses embedder | |
43 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | |
44 CHECK(cmd->HasSwitch(switches::kSingleProcess)); | |
45 g_max_url_size = max_chars; | |
46 } | |
47 #endif | |
48 | |
49 size_t GetMaxURLChars() { | |
50 return g_max_url_size; | |
51 } | |
52 | |
53 } // namespace content | 34 } // namespace content |
OLD | NEW |