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

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

Issue 140018: Make ExtensionPrefs paths relative, re-enable 2 ExtensionsService unit_tests (Closed)
Patch Set: final changes Created 11 years, 6 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 GURL file_url = extension_url.ReplaceComponents(replacements); 482 GURL file_url = extension_url.ReplaceComponents(replacements);
483 if (!file_url.is_valid()) 483 if (!file_url.is_valid())
484 return FilePath(); 484 return FilePath();
485 485
486 // Convert the result back to a FilePath. 486 // Convert the result back to a FilePath.
487 FilePath ret_val; 487 FilePath ret_val;
488 if (!net::FileURLToFilePath(file_url, &ret_val)) 488 if (!net::FileURLToFilePath(file_url, &ret_val))
489 return FilePath(); 489 return FilePath();
490 490
491 // Double-check that the path we ended up with is actually inside the 491 // Double-check that the path we ended up with is actually inside the
492 // extension root. We can do this with a simple prefix match because: 492 // extension root.
493 // a) We control the prefix on both sides, and they should match. 493 if (!extension_path.IsParent(ret_val))
494 // b) GURL normalizes things like "../" and "//" before it gets to us.
495 if (ret_val.value().find(extension_path.value() +
496 FilePath::kSeparators[0]) != 0)
497 return FilePath(); 494 return FilePath();
498 495
499 return ret_val; 496 return ret_val;
500 } 497 }
501 498
502 Extension::Extension(const FilePath& path) { 499 Extension::Extension(const FilePath& path) {
503 DCHECK(path.IsAbsolute()); 500 DCHECK(path.IsAbsolute());
504 location_ = INVALID; 501 location_ = INVALID;
505 502
506 #if defined(OS_WIN) 503 #if defined(OS_WIN)
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 } 929 }
933 } 930 }
934 931
935 for (PageActionMap::const_iterator it = page_actions().begin(); 932 for (PageActionMap::const_iterator it = page_actions().begin();
936 it != page_actions().end(); ++it) { 933 it != page_actions().end(); ++it) {
937 image_paths.insert(it->second->icon_path()); 934 image_paths.insert(it->second->icon_path());
938 } 935 }
939 936
940 return image_paths; 937 return image_paths;
941 } 938 }
OLDNEW
« no previous file with comments | « chrome/browser/profile.cc ('k') | chrome/test/data/extensions/bad/Extensions/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/1/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698