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

Side by Side Diff: net/base/net_util.cc

Issue 260003: Move the clipboard stuff out of base and into app/clipboard. I renamed... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | « net/base/net_util.h ('k') | views/controls/message_box_view.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "net/base/net_util.h"
6
5 #include <algorithm> 7 #include <algorithm>
6 #include <map> 8 #include <map>
7 #include <unicode/ucnv.h> 9 #include <unicode/ucnv.h>
8 #include <unicode/uidna.h> 10 #include <unicode/uidna.h>
9 #include <unicode/ulocdata.h> 11 #include <unicode/ulocdata.h>
10 #include <unicode/uniset.h> 12 #include <unicode/uniset.h>
11 #include <unicode/uscript.h> 13 #include <unicode/uscript.h>
12 #include <unicode/uset.h> 14 #include <unicode/uset.h>
13 15
14 #include "build/build_config.h" 16 #include "build/build_config.h"
15 17
16 #if defined(OS_WIN) 18 #if defined(OS_WIN)
17 #include <windows.h> 19 #include <windows.h>
18 #include <winsock2.h> 20 #include <winsock2.h>
19 #include <ws2tcpip.h> 21 #include <ws2tcpip.h>
20 #include <wspiapi.h> // Needed for Win2k compat. 22 #include <wspiapi.h> // Needed for Win2k compat.
21 #elif defined(OS_POSIX) 23 #elif defined(OS_POSIX)
22 #include <netdb.h> 24 #include <netdb.h>
23 #include <sys/socket.h> 25 #include <sys/socket.h>
24 #include <fcntl.h> 26 #include <fcntl.h>
25 #endif 27 #endif
26 28
27 #include "net/base/net_util.h"
28
29 #include "base/basictypes.h" 29 #include "base/basictypes.h"
30 #include "base/file_path.h" 30 #include "base/file_path.h"
31 #include "base/file_util.h" 31 #include "base/file_util.h"
32 #include "base/lock.h" 32 #include "base/lock.h"
33 #include "base/logging.h" 33 #include "base/logging.h"
34 #include "base/message_loop.h" 34 #include "base/message_loop.h"
35 #include "base/path_service.h" 35 #include "base/path_service.h"
36 #include "base/scoped_clipboard_writer.h"
37 #include "base/singleton.h" 36 #include "base/singleton.h"
38 #include "base/stl_util-inl.h" 37 #include "base/stl_util-inl.h"
39 #include "base/string_escape.h" 38 #include "base/string_escape.h"
40 #include "base/string_piece.h" 39 #include "base/string_piece.h"
41 #include "base/string_tokenizer.h" 40 #include "base/string_tokenizer.h"
42 #include "base/string_util.h" 41 #include "base/string_util.h"
43 #include "base/sys_string_conversions.h" 42 #include "base/sys_string_conversions.h"
44 #include "base/time.h" 43 #include "base/time.h"
45 #include "base/time_format.h" 44 #include "base/time_format.h"
46 #include "grit/net_resources.h" 45 #include "grit/net_resources.h"
(...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 if (parsed.ref.len > 0) 1323 if (parsed.ref.len > 0)
1325 url_string.append(UTF8ToWide(std::string(&spec[parsed.ref.begin], 1324 url_string.append(UTF8ToWide(std::string(&spec[parsed.ref.begin],
1326 parsed.ref.len))); 1325 parsed.ref.len)));
1327 new_parsed->ref.begin = begin; 1326 new_parsed->ref.begin = begin;
1328 new_parsed->ref.len = url_string.length() - begin; 1327 new_parsed->ref.len = url_string.length() - begin;
1329 } 1328 }
1330 1329
1331 return url_string; 1330 return url_string;
1332 } 1331 }
1333 1332
1334 void WriteURLToClipboard(const GURL& url,
1335 const std::wstring& languages,
1336 Clipboard *clipboard) {
1337 if (url.is_empty() || !url.is_valid() || !clipboard)
1338 return;
1339
1340 string16 text =
1341 // Unescaping path and query is not a good idea because other
1342 // applications may not encode non-ASCII characters in UTF-8.
1343 // See crbug.com/2820.
1344 WideToUTF16(FormatUrl(url, languages, false, UnescapeRule::NONE, NULL,
1345 NULL));
1346
1347 ScopedClipboardWriter scw(clipboard);
1348 scw.WriteURL(text);
1349 }
1350
1351 GURL SimplifyUrlForRequest(const GURL& url) { 1333 GURL SimplifyUrlForRequest(const GURL& url) {
1352 DCHECK(url.is_valid()); 1334 DCHECK(url.is_valid());
1353 GURL::Replacements replacements; 1335 GURL::Replacements replacements;
1354 replacements.ClearUsername(); 1336 replacements.ClearUsername();
1355 replacements.ClearPassword(); 1337 replacements.ClearPassword();
1356 replacements.ClearRef(); 1338 replacements.ClearRef();
1357 return url.ReplaceComponents(replacements); 1339 return url.ReplaceComponents(replacements);
1358 } 1340 }
1359 1341
1360 // Specifies a comma separated list of port numbers that should be accepted 1342 // Specifies a comma separated list of port numbers that should be accepted
(...skipping 19 matching lines...) Expand all
1380 if (length > 0) 1362 if (length > 0)
1381 ports.insert(StringToInt(WideToASCII( 1363 ports.insert(StringToInt(WideToASCII(
1382 allowed_ports.substr(last, length)))); 1364 allowed_ports.substr(last, length))));
1383 last = i + 1; 1365 last = i + 1;
1384 } 1366 }
1385 } 1367 }
1386 explicitly_allowed_ports = ports; 1368 explicitly_allowed_ports = ports;
1387 } 1369 }
1388 1370
1389 } // namespace net 1371 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_util.h ('k') | views/controls/message_box_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698