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

Unified Diff: pkg/webdriver/lib/src/base64decoder.dart

Issue 12321078: Make base64 decoding available in dart:crypto Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove duplicate base64 decoding functionality from webdriver and use dart:crypto Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/webdriver/lib/webdriver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/webdriver/lib/src/base64decoder.dart
diff --git a/pkg/webdriver/lib/src/base64decoder.dart b/pkg/webdriver/lib/src/base64decoder.dart
deleted file mode 100644
index 7e9175bc03c147ca27a28f31fd0a78c2b5518201..0000000000000000000000000000000000000000
--- a/pkg/webdriver/lib/src/base64decoder.dart
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-part of webdriver;
-
-/**
- * A simple base64 decoder class, used to decode web browser screenshots
- * returned by WebDriver.
- */
-class Base64Decoder {
-
- static int getVal(String s, pos) {
- int code = s.codeUnitAt(pos);
- if (code >= 65 && code < (65+26)) { // 'A'..'Z'
- return code - 65;
- } else if (code >= 97 && code < (97+26)) { // 'a'..'z'
- return code - 97 + 26;
- } else if (code >= 48 && code < (48+10)) { // '0'..'9'
- return code - 48 + 52;
- } else if (code == 43) { // '+'
- return 62;
- } else if (code == 47) { // '/'
- return 63;
- } else {
- throw 'Invalid character $s';
- }
- }
-
- static List<int> decode(String s) {
- var rtn = new List<int>();
- var pos = 0;
- while (pos < s.length) {
- if (s[pos+2] =='=') { // Single byte as two chars.
- int v = (getVal(s, pos) << 18 ) | (getVal(s, pos+1) << 12 );
- rtn.add((v >> 16) & 0xff);
- break;
- } else if (s[pos+3] == '=') { // Two bytes as 3 chars.
- int v = (getVal(s, pos) << 18 ) | (getVal(s, pos+1) << 12 ) |
- (getVal(s, pos + 2) << 6);
- rtn.add((v >> 16) & 0xff);
- rtn.add((v >> 8) & 0xff);
- break;
- } else { // Three bytes as 4 chars.
- int v = (getVal(s, pos) << 18 ) | (getVal(s, pos+1) << 12 ) |
- (getVal(s, pos + 2) << 6) | getVal(s, pos+3);
- pos += 4;
- rtn.add((v >> 16 ) & 0xff);
- rtn.add((v >> 8) & 0xff);
- rtn.add(v & 0xff);
- }
- }
- return rtn;
- }
-}
« no previous file with comments | « no previous file | pkg/webdriver/lib/webdriver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698