| OLD | NEW |
| 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/api/extension_action/action_info.h" | 22 #include "chrome/common/extensions/api/extension_action/action_info.h" |
| 23 #include "chrome/common/extensions/api/extension_action/browser_action_handler.h
" | 23 #include "chrome/common/extensions/api/extension_action/browser_action_handler.h
" |
| 24 #include "chrome/common/extensions/api/extension_urls/extension_urls_handler.h" |
| 24 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
| 25 #include "chrome/common/extensions/extension_l10n_util.h" | 26 #include "chrome/common/extensions/extension_l10n_util.h" |
| 26 #include "chrome/common/extensions/extension_manifest_constants.h" | 27 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 27 #include "chrome/common/extensions/extension_messages.h" | 28 #include "chrome/common/extensions/extension_messages.h" |
| 28 #include "chrome/common/extensions/extension_resource.h" | 29 #include "chrome/common/extensions/extension_resource.h" |
| 29 #include "chrome/common/extensions/message_bundle.h" | 30 #include "chrome/common/extensions/message_bundle.h" |
| 30 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
| 31 #include "net/base/escape.h" | 32 #include "net/base/escape.h" |
| 32 #include "net/base/file_stream.h" | 33 #include "net/base/file_stream.h" |
| 33 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 *error = | 369 *error = |
| 369 l10n_util::GetStringFUTF8( | 370 l10n_util::GetStringFUTF8( |
| 370 IDS_EXTENSION_LOAD_BACKGROUND_PAGE_FAILED, | 371 IDS_EXTENSION_LOAD_BACKGROUND_PAGE_FAILED, |
| 371 page_path.LossyDisplayName()); | 372 page_path.LossyDisplayName()); |
| 372 return false; | 373 return false; |
| 373 } | 374 } |
| 374 } | 375 } |
| 375 | 376 |
| 376 // Validate path to the options page. Don't check the URL for hosted apps, | 377 // Validate path to the options page. Don't check the URL for hosted apps, |
| 377 // because they are expected to refer to an external URL. | 378 // because they are expected to refer to an external URL. |
| 378 if (!extension->options_url().is_empty() && !extension->is_hosted_app()) { | 379 if (!extensions::ExtensionURL::GetOptionsURL(extension).is_empty() && |
| 380 !extension->is_hosted_app()) { |
| 379 const FilePath options_path = ExtensionURLToRelativeFilePath( | 381 const FilePath options_path = ExtensionURLToRelativeFilePath( |
| 380 extension->options_url()); | 382 extensions::ExtensionURL::GetOptionsURL(extension)); |
| 381 const FilePath path = extension->GetResource(options_path).GetFilePath(); | 383 const FilePath path = extension->GetResource(options_path).GetFilePath(); |
| 382 if (path.empty() || !file_util::PathExists(path)) { | 384 if (path.empty() || !file_util::PathExists(path)) { |
| 383 *error = | 385 *error = |
| 384 l10n_util::GetStringFUTF8( | 386 l10n_util::GetStringFUTF8( |
| 385 IDS_EXTENSION_LOAD_OPTIONS_PAGE_FAILED, | 387 IDS_EXTENSION_LOAD_OPTIONS_PAGE_FAILED, |
| 386 options_path.LossyDisplayName()); | 388 options_path.LossyDisplayName()); |
| 387 return false; | 389 return false; |
| 388 } | 390 } |
| 389 } | 391 } |
| 390 | 392 |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 return FilePath(); | 757 return FilePath(); |
| 756 } | 758 } |
| 757 return temp_path; | 759 return temp_path; |
| 758 } | 760 } |
| 759 | 761 |
| 760 void DeleteFile(const FilePath& path, bool recursive) { | 762 void DeleteFile(const FilePath& path, bool recursive) { |
| 761 file_util::Delete(path, recursive); | 763 file_util::Delete(path, recursive); |
| 762 } | 764 } |
| 763 | 765 |
| 764 } // namespace extension_file_util | 766 } // namespace extension_file_util |
| OLD | NEW |