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

Side by Side Diff: chrome/common/extensions/extension_file_util.cc

Issue 6378009: Only allow extension pages to be displayed in the sidebar to be consistent... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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/common/extensions/extension_file_util.h" 5 #include "chrome/common/extensions/extension_file_util.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/scoped_temp_dir.h" 15 #include "base/scoped_temp_dir.h"
16 #include "base/threading/thread_restrictions.h" 16 #include "base/threading/thread_restrictions.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "chrome/common/chrome_paths.h" 18 #include "chrome/common/chrome_paths.h"
19 #include "chrome/common/extensions/extension.h" 19 #include "chrome/common/extensions/extension.h"
20 #include "chrome/common/extensions/extension_action.h" 20 #include "chrome/common/extensions/extension_action.h"
21 #include "chrome/common/extensions/extension_l10n_util.h" 21 #include "chrome/common/extensions/extension_l10n_util.h"
22 #include "chrome/common/extensions/extension_constants.h" 22 #include "chrome/common/extensions/extension_constants.h"
23 #include "chrome/common/extensions/extension_resource.h" 23 #include "chrome/common/extensions/extension_resource.h"
24 #include "chrome/common/extensions/extension_sidebar_defaults.h"
24 #include "chrome/common/json_value_serializer.h" 25 #include "chrome/common/json_value_serializer.h"
25 #include "grit/generated_resources.h" 26 #include "grit/generated_resources.h"
26 #include "net/base/escape.h" 27 #include "net/base/escape.h"
27 #include "net/base/file_stream.h" 28 #include "net/base/file_stream.h"
28 29
29 namespace errors = extension_manifest_errors; 30 namespace errors = extension_manifest_errors;
30 31
31 namespace extension_file_util { 32 namespace extension_file_util {
32 33
33 // Validates locale info. Doesn't check if messages.json files are valid. 34 // Validates locale info. Doesn't check if messages.json files are valid.
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 const FilePath path = extension->GetResource(options_path).GetFilePath(); 263 const FilePath path = extension->GetResource(options_path).GetFilePath();
263 if (path.empty() || !file_util::PathExists(path)) { 264 if (path.empty() || !file_util::PathExists(path)) {
264 *error = 265 *error =
265 l10n_util::GetStringFUTF8( 266 l10n_util::GetStringFUTF8(
266 IDS_EXTENSION_LOAD_OPTIONS_PAGE_FAILED, 267 IDS_EXTENSION_LOAD_OPTIONS_PAGE_FAILED,
267 WideToUTF16(options_path.ToWStringHack())); 268 WideToUTF16(options_path.ToWStringHack()));
268 return false; 269 return false;
269 } 270 }
270 } 271 }
271 272
273 // Validate sidebar default page location.
274 ExtensionSidebarDefaults* sidebar_defaults = extension->sidebar_defaults();
275 if (sidebar_defaults && sidebar_defaults->default_page().is_valid()) {
276 FilePath page_path = ExtensionURLToRelativeFilePath(
277 sidebar_defaults->default_page());
278 const FilePath path = extension->GetResource(page_path).GetFilePath();
279 if (path.empty() || !file_util::PathExists(path)) {
280 *error =
281 l10n_util::GetStringFUTF8(
282 IDS_EXTENSION_LOAD_SIDEBAR_PAGE_FAILED,
283 WideToUTF16(page_path.ToWStringHack()));
284 return false;
285 }
286 }
287
272 // Validate locale info. 288 // Validate locale info.
273 if (!ValidateLocaleInfo(*extension, error)) 289 if (!ValidateLocaleInfo(*extension, error))
274 return false; 290 return false;
275 291
276 // Check children of extension root to see if any of them start with _ and is 292 // Check children of extension root to see if any of them start with _ and is
277 // not on the reserved list. 293 // not on the reserved list.
278 if (!CheckForIllegalFilenames(extension->path(), error)) { 294 if (!CheckForIllegalFilenames(extension->path(), error)) {
279 return false; 295 return false;
280 } 296 }
281 297
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 result, 597 result,
582 NUM_DIRECTORY_CREATION_RESULTS); 598 NUM_DIRECTORY_CREATION_RESULTS);
583 599
584 if (result == SUCCESS) 600 if (result == SUCCESS)
585 return temp_path; 601 return temp_path;
586 602
587 return FilePath(); 603 return FilePath();
588 } 604 }
589 605
590 } // namespace extension_file_util 606 } // namespace extension_file_util
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | chrome/common/extensions/extension_manifests_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698