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

Side by Side Diff: chrome/browser/download/download_extension_api.cc

Issue 10213002: Make downloads.download() respect host permissions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 8 years, 7 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 // 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
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 (!iodata_->url.SchemeIs("data") &&
384 !GetExtension()->HasHostPermission(iodata_->url)) {
385 error_ = download_extension_errors::kInvalidURLError;
386 return false;
387 }
388
383 if (options->HasKey(kFilenameKey)) { 389 if (options->HasKey(kFilenameKey)) {
384 EXTENSION_FUNCTION_VALIDATE(options->GetString( 390 EXTENSION_FUNCTION_VALIDATE(options->GetString(
385 kFilenameKey, &iodata_->filename)); 391 kFilenameKey, &iodata_->filename));
386 if (!ValidateFilename(iodata_->filename)) { 392 if (!ValidateFilename(iodata_->filename)) {
387 error_ = download_extension_errors::kGenericError; 393 error_ = download_extension_errors::kGenericError;
388 return false; 394 return false;
389 } 395 }
390 } 396 }
391 397
392 if (options->HasKey(kSaveAsKey)) { 398 if (options->HasKey(kSaveAsKey)) {
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 ListValue args; 1080 ListValue args;
1075 args.Append(arg); 1081 args.Append(arg);
1076 std::string json_args; 1082 std::string json_args;
1077 base::JSONWriter::Write(&args, &json_args); 1083 base::JSONWriter::Write(&args, &json_args);
1078 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( 1084 profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
1079 event_name, 1085 event_name,
1080 json_args, 1086 json_args,
1081 profile_, 1087 profile_,
1082 GURL()); 1088 GURL());
1083 } 1089 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/extension.cc » ('j') | chrome/common/extensions/extension.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698