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

Side by Side Diff: Source/core/frame/DOMWindowBase64.cpp

Issue 171333003: Pass implementation object to supplemental classes by reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 10 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 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2013 Samsung Electronics. All rights reserved. 4 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 24 matching lines...) Expand all
35 35
36 #include "bindings/v8/ExceptionState.h" 36 #include "bindings/v8/ExceptionState.h"
37 #include "core/dom/ExceptionCode.h" 37 #include "core/dom/ExceptionCode.h"
38 #include "core/html/parser/HTMLParserIdioms.h" 38 #include "core/html/parser/HTMLParserIdioms.h"
39 #include "wtf/text/Base64.h" 39 #include "wtf/text/Base64.h"
40 40
41 namespace WebCore { 41 namespace WebCore {
42 42
43 namespace DOMWindowBase64 { 43 namespace DOMWindowBase64 {
44 44
45 String btoa(void*, const String& stringToEncode, ExceptionState& exceptionState) 45 String btoa(ScriptWrappable&, const String& stringToEncode, ExceptionState& exce ptionState)
46 { 46 {
47 if (stringToEncode.isNull()) 47 if (stringToEncode.isNull())
48 return String(); 48 return String();
49 49
50 if (!stringToEncode.containsOnlyLatin1()) { 50 if (!stringToEncode.containsOnlyLatin1()) {
51 exceptionState.throwDOMException(InvalidCharacterError, "The string to b e encoded contains characters outside of the Latin1 range."); 51 exceptionState.throwDOMException(InvalidCharacterError, "The string to b e encoded contains characters outside of the Latin1 range.");
52 return String(); 52 return String();
53 } 53 }
54 54
55 return base64Encode(stringToEncode.latin1()); 55 return base64Encode(stringToEncode.latin1());
56 } 56 }
57 57
58 String atob(void*, const String& encodedString, ExceptionState& exceptionState) 58 String atob(ScriptWrappable&, const String& encodedString, ExceptionState& excep tionState)
59 { 59 {
60 if (encodedString.isNull()) 60 if (encodedString.isNull())
61 return String(); 61 return String();
62 62
63 if (!encodedString.containsOnlyLatin1()) { 63 if (!encodedString.containsOnlyLatin1()) {
64 exceptionState.throwDOMException(InvalidCharacterError, "The string to b e decoded contains characters outside of the Latin1 range."); 64 exceptionState.throwDOMException(InvalidCharacterError, "The string to b e decoded contains characters outside of the Latin1 range.");
65 return String(); 65 return String();
66 } 66 }
67 Vector<char> out; 67 Vector<char> out;
68 if (!base64Decode(encodedString, out, isHTMLSpace<UChar>, Base64ValidatePadd ing)) { 68 if (!base64Decode(encodedString, out, isHTMLSpace<UChar>, Base64ValidatePadd ing)) {
69 exceptionState.throwDOMException(InvalidCharacterError, "The string to b e decoded is not correctly encoded."); 69 exceptionState.throwDOMException(InvalidCharacterError, "The string to b e decoded is not correctly encoded.");
70 return String(); 70 return String();
71 } 71 }
72 72
73 return String(out.data(), out.size()); 73 return String(out.data(), out.size());
74 } 74 }
75 75
76 } // namespace DOMWindowBase64 76 } // namespace DOMWindowBase64
77 77
78 } // namespace WebCore 78 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698