| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/test/plugin/plugin_geturl_test.h" | 5 #include "content/test/plugin/plugin_geturl_test.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 205 |
| 206 #if defined(OS_WIN) | 206 #if defined(OS_WIN) |
| 207 filename = filename.substr(8); // remove "file:///" | 207 filename = filename.substr(8); // remove "file:///" |
| 208 // Assume an ASCII path on Windows. | 208 // Assume an ASCII path on Windows. |
| 209 base::FilePath path = base::FilePath(ASCIIToWide(filename)); | 209 base::FilePath path = base::FilePath(ASCIIToWide(filename)); |
| 210 #else | 210 #else |
| 211 filename = filename.substr(7); // remove "file://" | 211 filename = filename.substr(7); // remove "file://" |
| 212 base::FilePath path = base::FilePath(filename); | 212 base::FilePath path = base::FilePath(filename); |
| 213 #endif | 213 #endif |
| 214 | 214 |
| 215 test_file_ = file_util::OpenFile(path, "r"); | 215 test_file_ = base::OpenFile(path, "r"); |
| 216 if (!test_file_) { | 216 if (!test_file_) { |
| 217 SetError("Could not open source file"); | 217 SetError("Could not open source file"); |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 break; | 220 break; |
| 221 case BOGUS_URL_STREAM_ID: | 221 case BOGUS_URL_STREAM_ID: |
| 222 SetError("Unexpected NewStream for BOGUS_URL"); | 222 SetError("Unexpected NewStream for BOGUS_URL"); |
| 223 break; | 223 break; |
| 224 case REDIRECT_SRC_URL_NOTIFICATION_CANCEL_ID: | 224 case REDIRECT_SRC_URL_NOTIFICATION_CANCEL_ID: |
| 225 SetError("Should not redirect to URL when plugin denied it."); | 225 SetError("Should not redirect to URL when plugin denied it."); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 // don't care | 349 // don't care |
| 350 break; | 350 break; |
| 351 case REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID: | 351 case REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID: |
| 352 break; | 352 break; |
| 353 case FETCHED_URL_STREAM_ID: | 353 case FETCHED_URL_STREAM_ID: |
| 354 { | 354 { |
| 355 char read_buffer[STREAM_CHUNK]; | 355 char read_buffer[STREAM_CHUNK]; |
| 356 size_t bytes = fread(read_buffer, 1, sizeof(read_buffer), test_file_); | 356 size_t bytes = fread(read_buffer, 1, sizeof(read_buffer), test_file_); |
| 357 if (bytes != 0) | 357 if (bytes != 0) |
| 358 SetError("Data and source mismatch on length"); | 358 SetError("Data and source mismatch on length"); |
| 359 file_util::CloseFile(test_file_); | 359 base::CloseFile(test_file_); |
| 360 } | 360 } |
| 361 break; | 361 break; |
| 362 default: | 362 default: |
| 363 SetError("Unexpected NewStream callback"); | 363 SetError("Unexpected NewStream callback"); |
| 364 break; | 364 break; |
| 365 } | 365 } |
| 366 return NPERR_NO_ERROR; | 366 return NPERR_NO_ERROR; |
| 367 } | 367 } |
| 368 | 368 |
| 369 void PluginGetURLTest::StreamAsFile(NPStream* stream, const char* fname) { | 369 void PluginGetURLTest::StreamAsFile(NPStream* stream, const char* fname) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 id(), REDIRECT_SRC_URL, NULL, | 468 id(), REDIRECT_SRC_URL, NULL, |
| 469 reinterpret_cast<void*>(REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID)); | 469 reinterpret_cast<void*>(REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID)); |
| 470 } | 470 } |
| 471 } else if (stream_id == REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID) { | 471 } else if (stream_id == REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID) { |
| 472 received_url_redirect_allow_notification_ = true; | 472 received_url_redirect_allow_notification_ = true; |
| 473 HostFunctions()->urlredirectresponse(id(), notify_data, true); | 473 HostFunctions()->urlredirectresponse(id(), notify_data, true); |
| 474 } | 474 } |
| 475 } | 475 } |
| 476 | 476 |
| 477 } // namespace NPAPIClient | 477 } // namespace NPAPIClient |
| OLD | NEW |