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

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

Issue 11726002: Move the parsing of 'update_url' & 'options_page' URLs out of Extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@url_parse
Patch Set: fixed HomepageURLManifestTest.GetHomepageURL Created 7 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
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/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 "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
13 #include "base/json/json_file_value_serializer.h" 13 #include "base/json/json_file_value_serializer.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/stringprintf.h" 17 #include "base/stringprintf.h"
18 #include "base/threading/thread_restrictions.h" 18 #include "base/threading/thread_restrictions.h"
19 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
20 #include "chrome/common/chrome_constants.h" 20 #include "chrome/common/chrome_constants.h"
21 #include "chrome/common/chrome_paths.h" 21 #include "chrome/common/chrome_paths.h"
22 #include "chrome/common/extensions/extension.h" 22 #include "chrome/common/extensions/extension.h"
23 #include "chrome/common/extensions/extension_l10n_util.h" 23 #include "chrome/common/extensions/extension_l10n_util.h"
24 #include "chrome/common/extensions/extension_manifest_constants.h" 24 #include "chrome/common/extensions/extension_manifest_constants.h"
25 #include "chrome/common/extensions/extension_messages.h" 25 #include "chrome/common/extensions/extension_messages.h"
26 #include "chrome/common/extensions/extension_resource.h" 26 #include "chrome/common/extensions/extension_resource.h"
27 #include "chrome/common/extensions/manifest_url_handler.h"
27 #include "chrome/common/extensions/message_bundle.h" 28 #include "chrome/common/extensions/message_bundle.h"
28 #include "grit/generated_resources.h" 29 #include "grit/generated_resources.h"
29 #include "net/base/escape.h" 30 #include "net/base/escape.h"
30 #include "net/base/file_stream.h" 31 #include "net/base/file_stream.h"
31 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
32 33
33 using extensions::Extension; 34 using extensions::Extension;
34 35
35 namespace errors = extension_manifest_errors; 36 namespace errors = extension_manifest_errors;
36 37
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 *error = 367 *error =
367 l10n_util::GetStringFUTF8( 368 l10n_util::GetStringFUTF8(
368 IDS_EXTENSION_LOAD_BACKGROUND_PAGE_FAILED, 369 IDS_EXTENSION_LOAD_BACKGROUND_PAGE_FAILED,
369 page_path.LossyDisplayName()); 370 page_path.LossyDisplayName());
370 return false; 371 return false;
371 } 372 }
372 } 373 }
373 374
374 // Validate path to the options page. Don't check the URL for hosted apps, 375 // Validate path to the options page. Don't check the URL for hosted apps,
375 // because they are expected to refer to an external URL. 376 // because they are expected to refer to an external URL.
376 if (!extension->options_url().is_empty() && !extension->is_hosted_app()) { 377 if (!extensions::ManifestURL::GetOptionsPage(extension).is_empty() &&
378 !extension->is_hosted_app()) {
377 const FilePath options_path = ExtensionURLToRelativeFilePath( 379 const FilePath options_path = ExtensionURLToRelativeFilePath(
378 extension->options_url()); 380 extensions::ManifestURL::GetOptionsPage(extension));
379 const FilePath path = extension->GetResource(options_path).GetFilePath(); 381 const FilePath path = extension->GetResource(options_path).GetFilePath();
380 if (path.empty() || !file_util::PathExists(path)) { 382 if (path.empty() || !file_util::PathExists(path)) {
381 *error = 383 *error =
382 l10n_util::GetStringFUTF8( 384 l10n_util::GetStringFUTF8(
383 IDS_EXTENSION_LOAD_OPTIONS_PAGE_FAILED, 385 IDS_EXTENSION_LOAD_OPTIONS_PAGE_FAILED,
384 options_path.LossyDisplayName()); 386 options_path.LossyDisplayName());
385 return false; 387 return false;
386 } 388 }
387 } 389 }
388 390
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 return FilePath(); 755 return FilePath();
754 } 756 }
755 return temp_path; 757 return temp_path;
756 } 758 }
757 759
758 void DeleteFile(const FilePath& path, bool recursive) { 760 void DeleteFile(const FilePath& path, bool recursive) {
759 file_util::Delete(path, recursive); 761 file_util::Delete(path, recursive);
760 } 762 }
761 763
762 } // namespace extension_file_util 764 } // namespace extension_file_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698