OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/download/download_extension_api.h" | 5 #include "chrome/browser/download/download_extension_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cctype> | 8 #include <cctype> |
9 #include <iterator> | 9 #include <iterator> |
10 #include <set> | 10 #include <set> |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 std::string url; | 373 std::string url; |
374 iodata_.reset(new IOData()); | 374 iodata_.reset(new IOData()); |
375 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &options)); | 375 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &options)); |
376 EXTENSION_FUNCTION_VALIDATE(options->GetString(kUrlKey, &url)); | 376 EXTENSION_FUNCTION_VALIDATE(options->GetString(kUrlKey, &url)); |
377 iodata_->url = GURL(url); | 377 iodata_->url = GURL(url); |
378 if (!iodata_->url.is_valid()) { | 378 if (!iodata_->url.is_valid()) { |
379 error_ = download_extension_errors::kInvalidURLError; | 379 error_ = download_extension_errors::kInvalidURLError; |
380 return false; | 380 return false; |
381 } | 381 } |
382 | 382 |
| 383 if (!GetExtension()->HasHostPermission(iodata_->url)) { |
| 384 error_ = download_extension_errors::kInvalidURLError; |
| 385 return false; |
| 386 } |
| 387 |
383 if (options->HasKey(kFilenameKey)) { | 388 if (options->HasKey(kFilenameKey)) { |
384 EXTENSION_FUNCTION_VALIDATE(options->GetString( | 389 EXTENSION_FUNCTION_VALIDATE(options->GetString( |
385 kFilenameKey, &iodata_->filename)); | 390 kFilenameKey, &iodata_->filename)); |
386 if (!ValidateFilename(iodata_->filename)) { | 391 if (!ValidateFilename(iodata_->filename)) { |
387 error_ = download_extension_errors::kGenericError; | 392 error_ = download_extension_errors::kGenericError; |
388 return false; | 393 return false; |
389 } | 394 } |
390 } | 395 } |
391 | 396 |
392 if (options->HasKey(kSaveAsKey)) { | 397 if (options->HasKey(kSaveAsKey)) { |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 ListValue args; | 1079 ListValue args; |
1075 args.Append(arg); | 1080 args.Append(arg); |
1076 std::string json_args; | 1081 std::string json_args; |
1077 base::JSONWriter::Write(&args, &json_args); | 1082 base::JSONWriter::Write(&args, &json_args); |
1078 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 1083 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
1079 event_name, | 1084 event_name, |
1080 json_args, | 1085 json_args, |
1081 profile_, | 1086 profile_, |
1082 GURL()); | 1087 GURL()); |
1083 } | 1088 } |
OLD | NEW |