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

Side by Side Diff: chrome/browser/extensions/extension_bookmarks_module.cc

Issue 6879047: Make sure that extensions can launch web urls, create bookmark url with web safe schemes only. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/extensions/extension_bookmarks_module.h" 5 #include "chrome/browser/extensions/extension_bookmarks_module.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/i18n/file_util_icu.h" 8 #include "base/i18n/file_util_icu.h"
9 #include "base/i18n/time_formatting.h" 9 #include "base/i18n/time_formatting.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/extensions/extension_bookmarks_module_constants.h" 24 #include "chrome/browser/extensions/extension_bookmarks_module_constants.h"
25 #include "chrome/browser/extensions/extension_event_router.h" 25 #include "chrome/browser/extensions/extension_event_router.h"
26 #include "chrome/browser/extensions/extensions_quota_service.h" 26 #include "chrome/browser/extensions/extensions_quota_service.h"
27 #include "chrome/browser/importer/importer_data_types.h" 27 #include "chrome/browser/importer/importer_data_types.h"
28 #include "chrome/browser/importer/importer_host.h" 28 #include "chrome/browser/importer/importer_host.h"
29 #include "chrome/browser/prefs/pref_service.h" 29 #include "chrome/browser/prefs/pref_service.h"
30 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/browser/ui/browser_list.h" 31 #include "chrome/browser/ui/browser_list.h"
32 #include "chrome/common/chrome_paths.h" 32 #include "chrome/common/chrome_paths.h"
33 #include "chrome/common/pref_names.h" 33 #include "chrome/common/pref_names.h"
34 #include "content/browser/child_process_security_policy.h"
34 #include "content/common/notification_service.h" 35 #include "content/common/notification_service.h"
35 #include "grit/generated_resources.h" 36 #include "grit/generated_resources.h"
36 #include "ui/base/l10n/l10n_util.h" 37 #include "ui/base/l10n/l10n_util.h"
37 38
38 namespace keys = extension_bookmarks_module_constants; 39 namespace keys = extension_bookmarks_module_constants;
39 40
40 using base::TimeDelta; 41 using base::TimeDelta;
41 typedef QuotaLimitHeuristic::Bucket Bucket; 42 typedef QuotaLimitHeuristic::Bucket Bucket;
42 typedef QuotaLimitHeuristic::Config Config; 43 typedef QuotaLimitHeuristic::Config Config;
43 typedef QuotaLimitHeuristic::BucketList BucketList; 44 typedef QuotaLimitHeuristic::BucketList BucketList;
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 if (index > parent->child_count() || index < 0) { 462 if (index > parent->child_count() || index < 0) {
462 error_ = keys::kInvalidIndexError; 463 error_ = keys::kInvalidIndexError;
463 return false; 464 return false;
464 } 465 }
465 } 466 }
466 467
467 string16 title; 468 string16 title;
468 json->GetString(keys::kTitleKey, &title); // Optional. 469 json->GetString(keys::kTitleKey, &title); // Optional.
469 std::string url_string; 470 std::string url_string;
470 json->GetString(keys::kUrlKey, &url_string); // Optional. 471 json->GetString(keys::kUrlKey, &url_string); // Optional.
472
473 // Ensure the bookmark URL is a valid URL and has a web safe scheme.
471 GURL url(url_string); 474 GURL url(url_string);
472 if (!url.is_empty() && !url.is_valid()) { 475 ChildProcessSecurityPolicy *policy =
476 ChildProcessSecurityPolicy::GetInstance();
477 if (!url.is_empty() &&
478 (!url.is_valid() || !policy->IsWebSafeScheme(url.scheme()))) {
473 error_ = keys::kInvalidUrlError; 479 error_ = keys::kInvalidUrlError;
474 return false; 480 return false;
475 } 481 }
476 482
477 const BookmarkNode* node; 483 const BookmarkNode* node;
478 if (url_string.length()) 484 if (url_string.length())
479 node = model->AddURL(parent, index, title, url); 485 node = model->AddURL(parent, index, title, url);
480 else 486 else
481 node = model->AddFolder(parent, index, title); 487 node = model->AddFolder(parent, index, title);
482 DCHECK(node); 488 DCHECK(node);
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE); 914 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE);
909 return true; 915 return true;
910 } 916 }
911 917
912 void ExportBookmarksFunction::FileSelected(const FilePath& path, 918 void ExportBookmarksFunction::FileSelected(const FilePath& path,
913 int index, 919 int index,
914 void* params) { 920 void* params) {
915 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); 921 bookmark_html_writer::WriteBookmarks(profile(), path, NULL);
916 Release(); // Balanced in BookmarksIOFunction::SelectFile() 922 Release(); // Balanced in BookmarksIOFunction::SelectFile()
917 } 923 }
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