Move extension_error_utils.* and url_pattern_set.* into
top-level extensions dir. BUG=159265 TBR=ben@chromium.org NOTRY=true Review URL: https://codereview.chromium.org/11312228 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168613 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
chrome
browser
accessibility
automation
chromeos
extensions
download
extensions
active_tab_permission_granter.hconvert_user_script_unittest.ccextension_prefs.hextension_service.ccextension_service_unittest.ccextensions_quota_service.ccmenu_manager.h
api
alarms
app_current_window_internal
browsing_data
content_settings
context_menu
cookies
debugger
declarative_webrequest
discovery
extension_action
font_settings
management
offscreen_tabs
permissions
permissions_api.ccpermissions_api_helpers.ccpermissions_api_helpers_unittest.ccpermissions_apitest.cc
preference
processes
proxy
tabs
web_request
webstore_private
settings
user_script_master_unittest.ccinfobars
tab_contents
ui
webui
options
common
extensions
api
command.ccextension.ccextension.hextension_error_utils.ccextension_messages.ccextension_messages.hextension_set.ccextension_set.hextension_unittest.ccfile_browser_handler.hmanifest.ccmanifest_tests
extension_manifest_test.ccextension_manifest_test.hextension_manifests_background_unittest.ccextension_manifests_browseraction_unittest.ccextension_manifests_contentscript_unittest.ccextension_manifests_filebrowser_unittest.ccextension_manifests_launch_unittest.ccextension_manifests_requirements_unittest.ccextension_manifests_validapp_unittest.ccextension_manifests_web_unittest.cc
manifest_unittest.ccmatcher
message_bundle.ccmessage_bundle_unittest.ccpermissions
user_script.hrenderer
extensions
extensions
@ -17,8 +17,8 @@
|
||||
#include "chrome/browser/infobars/infobar_tab_helper.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/common/chrome_notification_types.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "content/public/browser/notification_service.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
namespace keys = extension_accessibility_api_constants;
|
||||
|
||||
@ -203,7 +203,7 @@ bool GetAlertsForTabFunction::RunImpl() {
|
||||
int tab_index = -1;
|
||||
if (!ExtensionTabUtil::GetTabById(tab_id, profile(), include_incognito(),
|
||||
NULL, &tab_strip, &contents, &tab_index)) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = extensions::ErrorUtils::FormatErrorMessage(
|
||||
extensions::tabs_constants::kTabNotFoundError,
|
||||
base::IntToString(tab_id));
|
||||
return false;
|
||||
|
@ -127,7 +127,6 @@
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/permissions/permission_set.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "chrome/common/render_messages.h"
|
||||
#include "content/public/browser/browser_child_process_host_iterator.h"
|
||||
@ -148,6 +147,7 @@
|
||||
#include "content/public/common/geoposition.h"
|
||||
#include "content/public/common/ssl_status.h"
|
||||
#include "extensions/common/url_pattern.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
#include "net/cookies/cookie_store.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
|
||||
#include "ui/base/events/event_constants.h"
|
||||
@ -3734,14 +3734,14 @@ void TestingAutomationProvider::InstallExtension(
|
||||
namespace {
|
||||
|
||||
ListValue* GetHostPermissions(const Extension* ext, bool effective_perm) {
|
||||
URLPatternSet pattern_set;
|
||||
extensions::URLPatternSet pattern_set;
|
||||
if (effective_perm)
|
||||
pattern_set = ext->GetEffectiveHostPermissions();
|
||||
else
|
||||
pattern_set = ext->GetActivePermissions()->explicit_hosts();
|
||||
|
||||
ListValue* permissions = new ListValue;
|
||||
for (URLPatternSet::const_iterator perm = pattern_set.begin();
|
||||
for (extensions::URLPatternSet::const_iterator perm = pattern_set.begin();
|
||||
perm != pattern_set.end(); ++perm) {
|
||||
permissions->Append(new StringValue(perm->GetAsString()));
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "base/platform_file.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/file_browser_handler.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
|
||||
class Browser;
|
||||
class GURL;
|
||||
|
@ -58,7 +58,7 @@ bool OffStoreInstallAllowedByPrefs(Profile* profile, const DownloadItem& item) {
|
||||
profile)->extension_service()->extension_prefs();
|
||||
CHECK(prefs);
|
||||
|
||||
URLPatternSet url_patterns = prefs->GetAllowedInstallSites();
|
||||
extensions::URLPatternSet url_patterns = prefs->GetAllowedInstallSites();
|
||||
|
||||
// TODO(aa): RefererURL is cleared in some cases, for example when going
|
||||
// between secure and non-secure URLs. It would be better if DownloadItem
|
||||
|
@ -9,10 +9,10 @@
|
||||
#include <string>
|
||||
|
||||
#include "chrome/common/extensions/extension_set.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "content/public/browser/notification_observer.h"
|
||||
#include "content/public/browser/notification_registrar.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
|
||||
class Profile;
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "chrome/browser/extensions/api/alarms/alarm_manager.h"
|
||||
#include "chrome/browser/extensions/extension_system.h"
|
||||
#include "chrome/common/extensions/api/alarms.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
namespace alarms = extensions::api::alarms;
|
||||
|
||||
@ -37,7 +37,7 @@ bool ValidateDelay(double delay_in_minutes,
|
||||
// In release mode we check for integer delay values and a stricter delay
|
||||
// minimum.
|
||||
if (delay_in_minutes != static_cast<int>(delay_in_minutes)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(
|
||||
*error = ErrorUtils::FormatErrorMessage(
|
||||
kDelayIsNonInteger,
|
||||
delay_or_period);
|
||||
return false;
|
||||
@ -47,7 +47,7 @@ bool ValidateDelay(double delay_in_minutes,
|
||||
|
||||
// Validate against our found delay minimum.
|
||||
if (delay_in_minutes < delay_minimum) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(
|
||||
*error = ErrorUtils::FormatErrorMessage(
|
||||
kDelayLessThanMinimum,
|
||||
delay_or_period,
|
||||
base::DoubleToString(delay_minimum));
|
||||
@ -128,7 +128,7 @@ bool AlarmsGetFunction::RunImpl() {
|
||||
extension_id(), name);
|
||||
|
||||
if (!alarm) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(kAlarmNotFound, name);
|
||||
error_ = ErrorUtils::FormatErrorMessage(kAlarmNotFound, name);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ bool AlarmsClearFunction::RunImpl() {
|
||||
extension_id(), name);
|
||||
|
||||
if (!success) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(kAlarmNotFound, name);
|
||||
error_ = ErrorUtils::FormatErrorMessage(kAlarmNotFound, name);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.h"
|
||||
#include "chrome/browser/extensions/shell_window_registry.h"
|
||||
#include "chrome/browser/ui/extensions/shell_window.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
|
@ -18,8 +18,8 @@
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
|
@ -25,8 +25,8 @@
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/extensions/api/content_settings.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "content/public/browser/plugin_service.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
using content::PluginService;
|
||||
@ -104,7 +104,7 @@ bool GetContentSettingFunction::RunImpl() {
|
||||
|
||||
GURL primary_url(params->details.primary_url);
|
||||
if (!primary_url.is_valid()) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kInvalidUrlError,
|
||||
error_ = ErrorUtils::FormatErrorMessage(keys::kInvalidUrlError,
|
||||
params->details.primary_url);
|
||||
return false;
|
||||
}
|
||||
@ -113,7 +113,7 @@ bool GetContentSettingFunction::RunImpl() {
|
||||
if (params->details.secondary_url.get()) {
|
||||
secondary_url = GURL(*params->details.secondary_url);
|
||||
if (!secondary_url.is_valid()) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kInvalidUrlError,
|
||||
error_ = ErrorUtils::FormatErrorMessage(keys::kInvalidUrlError,
|
||||
*params->details.secondary_url);
|
||||
return false;
|
||||
}
|
||||
|
@ -6,15 +6,17 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/values.h"
|
||||
#include "base/string_number_conversions.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/browser/extensions/extension_service.h"
|
||||
#include "chrome/browser/extensions/menu_manager.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/common/extensions/api/context_menus.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
|
||||
using extensions::ErrorUtils;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -128,7 +130,7 @@ extensions::MenuItem* GetParent(extensions::MenuItem::Id parent_id,
|
||||
std::string* error) {
|
||||
extensions::MenuItem* parent = menu_manager->GetItemById(parent_id);
|
||||
if (!parent) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(
|
||||
*error = ErrorUtils::FormatErrorMessage(
|
||||
kCannotFindItemError, GetIDString(parent_id));
|
||||
return NULL;
|
||||
}
|
||||
@ -175,7 +177,7 @@ bool CreateContextMenuFunction::RunImpl() {
|
||||
MenuManager* menu_manager = profile()->GetExtensionService()->menu_manager();
|
||||
|
||||
if (menu_manager->GetItemById(id)) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(kDuplicateIDError,
|
||||
error_ = ErrorUtils::FormatErrorMessage(kDuplicateIDError,
|
||||
GetIDString(id));
|
||||
return false;
|
||||
}
|
||||
@ -264,7 +266,7 @@ bool UpdateContextMenuFunction::RunImpl() {
|
||||
MenuManager* manager = service->menu_manager();
|
||||
MenuItem* item = manager->GetItemById(item_id);
|
||||
if (!item || item->extension_id() != extension_id()) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
kCannotFindItemError, GetIDString(item_id));
|
||||
return false;
|
||||
}
|
||||
@ -374,7 +376,7 @@ bool RemoveContextMenuFunction::RunImpl() {
|
||||
MenuItem* item = manager->GetItemById(id);
|
||||
// Ensure one extension can't remove another's menu items.
|
||||
if (!item || item->extension_id() != extension_id()) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
kCannotFindItemError, GetIDString(id));
|
||||
return false;
|
||||
}
|
||||
|
@ -24,9 +24,9 @@
|
||||
#include "chrome/common/chrome_notification_types.h"
|
||||
#include "chrome/common/extensions/api/cookies.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/notification_service.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "net/cookies/canonical_cookie.h"
|
||||
#include "net/cookies/cookie_monster.h"
|
||||
#include "net/url_request/url_request_context.h"
|
||||
@ -140,13 +140,13 @@ bool CookiesFunction::ParseUrl(const std::string& url_string, GURL* url,
|
||||
bool check_host_permissions) {
|
||||
*url = GURL(url_string);
|
||||
if (!url->is_valid()) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kInvalidUrlError, url_string);
|
||||
return false;
|
||||
}
|
||||
// Check against host permissions if needed.
|
||||
if (check_host_permissions && !GetExtension()->HasHostPermission(*url)) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kNoHostPermissionsError, url->spec());
|
||||
return false;
|
||||
}
|
||||
@ -162,7 +162,7 @@ bool CookiesFunction::ParseStoreContext(
|
||||
store_profile = cookies_helpers::ChooseProfileFromStoreId(
|
||||
*store_id, profile(), include_incognito());
|
||||
if (!store_profile) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kInvalidStoreIdError, *store_id);
|
||||
return false;
|
||||
}
|
||||
@ -423,7 +423,7 @@ void SetCookieFunction::RespondOnUIThread() {
|
||||
if (!success_) {
|
||||
std::string name = parsed_args_->details.name.get() ?
|
||||
*parsed_args_->details.name : "";
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kCookieSetFailedError, name);
|
||||
}
|
||||
SendResponse(success_);
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "chrome/common/chrome_notification_types.h"
|
||||
#include "chrome/common/extensions/api/debugger.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "content/public/browser/devtools_agent_host_registry.h"
|
||||
#include "content/public/browser/devtools_client_host.h"
|
||||
#include "content/public/browser/devtools_manager.h"
|
||||
@ -37,6 +36,7 @@
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/content_client.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "grit/generated_resources.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "webkit/glue/webkit_glue.h"
|
||||
@ -47,6 +47,7 @@ using content::DevToolsClientHost;
|
||||
using content::DevToolsManager;
|
||||
using content::WebContents;
|
||||
using extensions::api::debugger::Debuggee;
|
||||
using extensions::ErrorUtils;
|
||||
|
||||
namespace keys = debugger_api_constants;
|
||||
namespace Attach = extensions::api::debugger::Attach;
|
||||
@ -408,7 +409,7 @@ bool DebuggerFunction::InitWebContents() {
|
||||
bool result = ExtensionTabUtil::GetTabById(
|
||||
tab_id_, profile(), include_incognito(), NULL, NULL, &web_contents, NULL);
|
||||
if (!result || !web_contents) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kNoTabError,
|
||||
base::IntToString(tab_id_));
|
||||
return false;
|
||||
@ -417,7 +418,7 @@ bool DebuggerFunction::InitWebContents() {
|
||||
|
||||
if (content::GetContentClient()->HasWebUIScheme(
|
||||
contents_->GetURL())) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kAttachToWebUIError,
|
||||
contents_->GetURL().scheme());
|
||||
return false;
|
||||
@ -436,7 +437,7 @@ bool DebuggerFunction::InitClientHost() {
|
||||
if (!client_host_ ||
|
||||
!client_host_->MatchesContentsAndExtensionId(contents_,
|
||||
GetExtension()->id())) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kNotAttachedError,
|
||||
base::IntToString(tab_id_));
|
||||
return false;
|
||||
@ -458,7 +459,7 @@ bool AttachDebuggerFunction::RunImpl() {
|
||||
|
||||
if (!webkit_glue::IsInspectorProtocolVersionSupported(
|
||||
params->required_version)) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kProtocolVersionNotSupportedError,
|
||||
params->required_version);
|
||||
return false;
|
||||
@ -470,7 +471,7 @@ bool AttachDebuggerFunction::RunImpl() {
|
||||
GetDevToolsClientHostFor(agent);
|
||||
|
||||
if (client_host != NULL) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kAlreadyAttachedError,
|
||||
base::IntToString(tab_id_));
|
||||
return false;
|
||||
|
@ -13,13 +13,13 @@
|
||||
#include "chrome/browser/extensions/api/declarative_webrequest/request_stage.h"
|
||||
#include "chrome/browser/extensions/api/declarative_webrequest/webrequest_constants.h"
|
||||
#include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "content/public/browser/resource_request_info.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
|
||||
#include "net/base/static_cookie_policy.h"
|
||||
#include "net/http/http_util.h"
|
||||
#include "net/http/http_request_headers.h"
|
||||
#include "net/http/http_util.h"
|
||||
#include "net/url_request/url_request.h"
|
||||
|
||||
using base::CaseInsensitiveCompareASCII;
|
||||
@ -87,7 +87,7 @@ WebRequestConditionAttribute::Create(
|
||||
return WebRequestConditionAttributeStages::Create(name, value, error);
|
||||
}
|
||||
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(kUnknownConditionAttribute,
|
||||
*error = ErrorUtils::FormatErrorMessage(kUnknownConditionAttribute,
|
||||
name);
|
||||
return scoped_ptr<WebRequestConditionAttribute>(NULL);
|
||||
}
|
||||
@ -120,7 +120,7 @@ WebRequestConditionAttributeResourceType::Create(
|
||||
|
||||
const ListValue* value_as_list = NULL;
|
||||
if (!value->GetAsList(&value_as_list)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(kInvalidValue,
|
||||
*error = ErrorUtils::FormatErrorMessage(kInvalidValue,
|
||||
keys::kResourceTypeKey);
|
||||
return scoped_ptr<WebRequestConditionAttribute>(NULL);
|
||||
}
|
||||
@ -133,7 +133,7 @@ WebRequestConditionAttributeResourceType::Create(
|
||||
ResourceType::Type type = ResourceType::LAST_TYPE;
|
||||
if (!value_as_list->GetString(i, &resource_type_string) ||
|
||||
!helpers::ParseResourceType(resource_type_string, &type)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(kInvalidValue,
|
||||
*error = ErrorUtils::FormatErrorMessage(kInvalidValue,
|
||||
keys::kResourceTypeKey);
|
||||
return scoped_ptr<WebRequestConditionAttribute>(NULL);
|
||||
}
|
||||
@ -198,7 +198,7 @@ WebRequestConditionAttributeContentType::Create(
|
||||
|
||||
const ListValue* value_as_list = NULL;
|
||||
if (!value->GetAsList(&value_as_list)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(kInvalidValue, name);
|
||||
*error = ErrorUtils::FormatErrorMessage(kInvalidValue, name);
|
||||
return scoped_ptr<WebRequestConditionAttribute>(NULL);
|
||||
}
|
||||
std::vector<std::string> content_types;
|
||||
@ -206,7 +206,7 @@ WebRequestConditionAttributeContentType::Create(
|
||||
it != value_as_list->end(); ++it) {
|
||||
std::string content_type;
|
||||
if (!(*it)->GetAsString(&content_type)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(kInvalidValue, name);
|
||||
*error = ErrorUtils::FormatErrorMessage(kInvalidValue, name);
|
||||
return scoped_ptr<WebRequestConditionAttribute>(NULL);
|
||||
}
|
||||
content_types.push_back(content_type);
|
||||
@ -527,14 +527,14 @@ scoped_ptr<const HeaderMatcher> PrepareHeaderMatcher(
|
||||
std::string* error) {
|
||||
const ListValue* value_as_list = NULL;
|
||||
if (!value->GetAsList(&value_as_list)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(kInvalidValue, name);
|
||||
*error = ErrorUtils::FormatErrorMessage(kInvalidValue, name);
|
||||
return scoped_ptr<const HeaderMatcher>(NULL);
|
||||
}
|
||||
|
||||
scoped_ptr<const HeaderMatcher> header_matcher(
|
||||
HeaderMatcher::Create(value_as_list));
|
||||
if (header_matcher.get() == NULL)
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(kInvalidValue, name);
|
||||
*error = ErrorUtils::FormatErrorMessage(kInvalidValue, name);
|
||||
return header_matcher.Pass();
|
||||
}
|
||||
|
||||
@ -686,7 +686,7 @@ WebRequestConditionAttributeThirdParty::Create(
|
||||
|
||||
bool third_party = false; // Dummy value, gets overwritten.
|
||||
if (!value->GetAsBoolean(&third_party)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(kInvalidValue,
|
||||
*error = ErrorUtils::FormatErrorMessage(kInvalidValue,
|
||||
keys::kThirdPartyKey);
|
||||
return scoped_ptr<WebRequestConditionAttribute>(NULL);
|
||||
}
|
||||
@ -783,7 +783,7 @@ WebRequestConditionAttributeStages::Create(const std::string& name,
|
||||
|
||||
int allowed_stages = 0;
|
||||
if (!ParseListOfStages(*value, &allowed_stages)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(kInvalidValue,
|
||||
*error = ErrorUtils::FormatErrorMessage(kInvalidValue,
|
||||
keys::kStagesKey);
|
||||
return scoped_ptr<WebRequestConditionAttribute>(NULL);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "chrome/browser/extensions/api/discovery/suggested_links_registry_factory.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/common/extensions/api/experimental_discovery.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
namespace discovery = extensions::api::experimental_discovery;
|
||||
|
||||
|
@ -22,10 +22,10 @@
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/common/chrome_notification_types.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/render_messages.h"
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
#include "content/public/browser/notification_service.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -351,7 +351,7 @@ bool ExtensionActionFunction::RunImpl() {
|
||||
ExtensionTabUtil::GetTabById(
|
||||
tab_id_, profile(), include_incognito(), NULL, NULL, &contents_, NULL);
|
||||
if (!contents_) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = extensions::ErrorUtils::FormatErrorMessage(
|
||||
kNoTabError, base::IntToString(tab_id_));
|
||||
return false;
|
||||
}
|
||||
|
@ -17,11 +17,12 @@
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/ui/browser_list.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
using content::NavigationEntry;
|
||||
using extensions::ErrorUtils;
|
||||
|
||||
namespace keys = extension_page_actions_api_constants;
|
||||
|
||||
@ -69,7 +70,7 @@ bool PageActionsFunction::SetPageActionEnabled(bool enable) {
|
||||
bool result = ExtensionTabUtil::GetTabById(
|
||||
tab_id, profile(), include_incognito(), NULL, NULL, &contents, NULL);
|
||||
if (!result || !contents) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
kNoTabError, base::IntToString(tab_id));
|
||||
return false;
|
||||
}
|
||||
@ -77,7 +78,7 @@ bool PageActionsFunction::SetPageActionEnabled(bool enable) {
|
||||
// Make sure the URL hasn't changed.
|
||||
NavigationEntry* entry = contents->GetController().GetActiveEntry();
|
||||
if (!entry || url != entry->GetURL().spec()) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(kUrlNotActiveError, url);
|
||||
error_ = ErrorUtils::FormatErrorMessage(kUrlNotActiveError, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/json/json_writer.h"
|
||||
#include "base/stringprintf.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/stringprintf.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/browser/extensions/api/preference/preference_helpers.h"
|
||||
#include "chrome/browser/extensions/extension_service.h"
|
||||
@ -18,12 +18,12 @@
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/common/chrome_notification_types.h"
|
||||
#include "chrome/common/extensions/api/font_settings.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "chrome/common/pref_names_util.h"
|
||||
#include "content/public/browser/font_list_async.h"
|
||||
#include "content/public/browser/notification_details.h"
|
||||
#include "content/public/browser/notification_source.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "ui/gfx/font.h"
|
||||
|
@ -32,13 +32,13 @@
|
||||
#include "chrome/common/extensions/api/management.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_constants.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_icon_set.h"
|
||||
#include "chrome/common/extensions/permissions/permission_set.h"
|
||||
#include "content/public/browser/notification_details.h"
|
||||
#include "content/public/browser/notification_source.h"
|
||||
#include "content/public/browser/utility_process_host.h"
|
||||
#include "content/public/browser/utility_process_host_client.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "extensions/common/url_pattern.h"
|
||||
|
||||
#if !defined(OS_ANDROID)
|
||||
@ -51,6 +51,7 @@ using content::UtilityProcessHost;
|
||||
using content::UtilityProcessHostClient;
|
||||
using extensions::api::management::ExtensionInfo;
|
||||
using extensions::api::management::IconInfo;
|
||||
using extensions::ErrorUtils;
|
||||
using extensions::Extension;
|
||||
using extensions::ExtensionSystem;
|
||||
using extensions::PermissionMessages;
|
||||
@ -162,10 +163,10 @@ scoped_ptr<management::ExtensionInfo> CreateExtensionInfo(
|
||||
|
||||
if (!extension.is_hosted_app()) {
|
||||
// Skip host permissions for hosted apps.
|
||||
const URLPatternSet host_perms =
|
||||
const extensions::URLPatternSet host_perms =
|
||||
extension.GetActivePermissions()->explicit_hosts();
|
||||
if (!host_perms.is_empty()) {
|
||||
for (URLPatternSet::const_iterator iter = host_perms.begin();
|
||||
for (extensions::URLPatternSet::const_iterator iter = host_perms.begin();
|
||||
iter != host_perms.end(); ++iter) {
|
||||
info->host_permissions.push_back(iter->GetAsString());
|
||||
}
|
||||
@ -239,7 +240,7 @@ bool GetExtensionByIdFunction::RunImpl() {
|
||||
|
||||
const Extension* extension = service()->GetExtensionById(params->id, true);
|
||||
if (!extension) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoExtensionError,
|
||||
error_ = ErrorUtils::FormatErrorMessage(keys::kNoExtensionError,
|
||||
params->id);
|
||||
return false;
|
||||
}
|
||||
@ -258,7 +259,7 @@ bool GetPermissionWarningsByIdFunction::RunImpl() {
|
||||
|
||||
const Extension* extension = service()->GetExtensionById(params->id, true);
|
||||
if (!extension) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoExtensionError,
|
||||
error_ = ErrorUtils::FormatErrorMessage(keys::kNoExtensionError,
|
||||
params->id);
|
||||
return false;
|
||||
}
|
||||
@ -411,12 +412,12 @@ bool LaunchAppFunction::RunImpl() {
|
||||
EXTENSION_FUNCTION_VALIDATE(params.get());
|
||||
const Extension* extension = service()->GetExtensionById(params->id, true);
|
||||
if (!extension) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoExtensionError,
|
||||
error_ = ErrorUtils::FormatErrorMessage(keys::kNoExtensionError,
|
||||
params->id);
|
||||
return false;
|
||||
}
|
||||
if (!extension->is_app()) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNotAnAppError,
|
||||
error_ = ErrorUtils::FormatErrorMessage(keys::kNotAnAppError,
|
||||
params->id);
|
||||
return false;
|
||||
}
|
||||
@ -452,7 +453,7 @@ bool SetEnabledFunction::RunImpl() {
|
||||
|
||||
const Extension* extension = service()->GetInstalledExtension(extension_id_);
|
||||
if (!extension) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kNoExtensionError, extension_id_);
|
||||
return false;
|
||||
}
|
||||
@ -460,7 +461,7 @@ bool SetEnabledFunction::RunImpl() {
|
||||
const extensions::ManagementPolicy* policy = extensions::ExtensionSystem::Get(
|
||||
profile())->management_policy();
|
||||
if (!policy->UserMayModifySettings(extension, NULL)) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kUserCantModifyError, extension_id_);
|
||||
return false;
|
||||
}
|
||||
@ -524,14 +525,14 @@ bool UninstallFunction::RunImpl() {
|
||||
|
||||
const Extension* extension = service()->GetExtensionById(extension_id_, true);
|
||||
if (!extension) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kNoExtensionError, extension_id_);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!extensions::ExtensionSystem::Get(
|
||||
profile())->management_policy()->UserMayModifySettings(extension, NULL)) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kUserCantModifyError, extension_id_);
|
||||
return false;
|
||||
}
|
||||
@ -567,7 +568,7 @@ void UninstallFunction::Finish(bool should_uninstall) {
|
||||
// TODO set error_ if !success
|
||||
SendResponse(success);
|
||||
} else {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kUninstallCanceledError, extension_id_);
|
||||
SendResponse(false);
|
||||
}
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
#include "base/hash_tables.h"
|
||||
#include "base/json/json_writer.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/memory/linked_ptr.h"
|
||||
#include "base/memory/scoped_vector.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/string_number_conversions.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/values.h"
|
||||
@ -31,7 +31,6 @@
|
||||
#include "chrome/browser/ui/window_sizer/window_sizer.h"
|
||||
#include "chrome/common/chrome_notification_types.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_messages.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "chrome/common/url_constants.h"
|
||||
@ -41,12 +40,14 @@
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/web_contents_view.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
using content::NativeWebKeyboardEvent;
|
||||
using content::NavigationController;
|
||||
using content::NotificationDetails;
|
||||
using content::NotificationSource;
|
||||
using content::WebContents;
|
||||
using extensions::ErrorUtils;
|
||||
using WebKit::WebInputEvent;
|
||||
|
||||
namespace keys = extensions::offscreen_tabs_constants;
|
||||
@ -359,7 +360,7 @@ bool OffscreenTabMap::GetOffscreenTab(const int offscreen_tab_id,
|
||||
}
|
||||
}
|
||||
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(
|
||||
*error = ErrorUtils::FormatErrorMessage(
|
||||
keys::kOffscreenTabNotFoundError, base::IntToString(offscreen_tab_id));
|
||||
return false;
|
||||
}
|
||||
@ -473,7 +474,7 @@ bool CreateOffscreenTabFunction::RunImpl() {
|
||||
GURL url = ExtensionTabUtil::ResolvePossiblyRelativeURL(
|
||||
url_string, GetExtension());
|
||||
if (!url.is_valid()) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
tabs_keys::kInvalidUrlError, url_string);
|
||||
return false;
|
||||
}
|
||||
@ -540,7 +541,7 @@ bool GetOffscreenTabFunction::RunImpl() {
|
||||
OffscreenTab* offscreen_tab = NULL;
|
||||
if (!GetMap()->GetOffscreenTab(
|
||||
offscreen_tab_id, this, &offscreen_tab, &error_)) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kOffscreenTabNotFoundError, base::IntToString(offscreen_tab_id));
|
||||
return false;
|
||||
}
|
||||
|
@ -12,14 +12,15 @@
|
||||
#include "chrome/common/chrome_notification_types.h"
|
||||
#include "chrome/common/extensions/api/permissions.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/permissions/permissions_info.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
|
||||
using extensions::api::permissions::Permissions;
|
||||
using extensions::APIPermission;
|
||||
using extensions::APIPermissionSet;
|
||||
using extensions::ErrorUtils;
|
||||
using extensions::PermissionSet;
|
||||
using extensions::PermissionsInfo;
|
||||
using extensions::PermissionsUpdater;
|
||||
@ -87,7 +88,7 @@ bool RemovePermissionsFunction::RunImpl() {
|
||||
for (APIPermissionSet::const_iterator i = apis.begin();
|
||||
i != apis.end(); ++i) {
|
||||
if (!i->info()->supports_optional()) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
kNotWhitelistedError, i->name());
|
||||
return false;
|
||||
}
|
||||
@ -162,7 +163,7 @@ bool RequestPermissionsFunction::RunImpl() {
|
||||
for (APIPermissionSet::const_iterator i = apis.begin();
|
||||
i != apis.end(); ++i) {
|
||||
if (!i->info()->supports_optional()) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
kNotWhitelistedError, i->name());
|
||||
return false;
|
||||
}
|
||||
|
@ -7,10 +7,10 @@
|
||||
#include "base/values.h"
|
||||
#include "chrome/common/extensions/api/permissions.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/permissions/permission_set.h"
|
||||
#include "chrome/common/extensions/permissions/permissions_info.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
|
||||
using extensions::APIPermission;
|
||||
using extensions::PermissionSet;
|
||||
@ -58,7 +58,7 @@ scoped_refptr<PermissionSet> UnpackPermissionSet(
|
||||
it != permissions_list->end(); ++it) {
|
||||
const APIPermissionInfo* permission_info = info->GetByName(*it);
|
||||
if (!permission_info) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(
|
||||
*error = ErrorUtils::FormatErrorMessage(
|
||||
kUnknownPermissionError, *it);
|
||||
return NULL;
|
||||
}
|
||||
@ -73,7 +73,7 @@ scoped_refptr<PermissionSet> UnpackPermissionSet(
|
||||
URLPattern origin(Extension::kValidHostPermissionSchemes);
|
||||
URLPattern::ParseResult parse_result = origin.Parse(*it);
|
||||
if (URLPattern::PARSE_SUCCESS != parse_result) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(
|
||||
*error = ErrorUtils::FormatErrorMessage(
|
||||
kInvalidOrigin,
|
||||
*it,
|
||||
URLPattern::GetParseResultString(parse_result));
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h"
|
||||
#include "chrome/common/extensions/api/permissions.h"
|
||||
#include "chrome/common/extensions/permissions/permission_set.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
@ -17,6 +17,7 @@ using extensions::api::permissions::Permissions;
|
||||
using extensions::APIPermission;
|
||||
using extensions::APIPermissionSet;
|
||||
using extensions::PermissionSet;
|
||||
using extensions::URLPatternSet;
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
using extensions::APIPermission;
|
||||
using extensions::APIPermissionSet;
|
||||
using extensions::PermissionSet;
|
||||
using extensions::URLPatternSet;
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -20,11 +20,11 @@
|
||||
#include "chrome/browser/prefs/pref_service.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/common/chrome_notification_types.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/permissions/api_permission.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "content/public/browser/notification_details.h"
|
||||
#include "content/public/browser/notification_source.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
namespace keys = extensions::preference_api_constants;
|
||||
namespace helpers = extensions::preference_helpers;
|
||||
@ -282,7 +282,7 @@ void PreferenceEventRouter::OnPrefChanged(PrefServiceBase* pref_service,
|
||||
transformer->BrowserToExtensionPref(pref->GetValue());
|
||||
if (!transformed_value) {
|
||||
LOG(ERROR) <<
|
||||
ExtensionErrorUtils::FormatErrorMessage(kConversionErrorMessage,
|
||||
ErrorUtils::FormatErrorMessage(kConversionErrorMessage,
|
||||
pref->name());
|
||||
return;
|
||||
}
|
||||
@ -312,7 +312,7 @@ bool PreferenceFunction::ValidateBrowserPref(
|
||||
PrefMapping::GetInstance()->FindBrowserPrefForExtensionPref(
|
||||
extension_pref_key, browser_pref_key, &permission));
|
||||
if (!GetExtension()->HasAPIPermission(permission)) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kPermissionErrorMessage, extension_pref_key);
|
||||
return false;
|
||||
}
|
||||
@ -363,7 +363,7 @@ bool GetPreferenceFunction::RunImpl() {
|
||||
transformer->BrowserToExtensionPref(pref->GetValue());
|
||||
if (!transformed_value) {
|
||||
LOG(ERROR) <<
|
||||
ExtensionErrorUtils::FormatErrorMessage(kConversionErrorMessage,
|
||||
ErrorUtils::FormatErrorMessage(kConversionErrorMessage,
|
||||
pref->name());
|
||||
return false;
|
||||
}
|
||||
@ -456,7 +456,7 @@ bool SetPreferenceFunction::RunImpl() {
|
||||
scoped_ptr<Value> extensionPrefValue(
|
||||
transformer->BrowserToExtensionPref(browser_pref_value.get()));
|
||||
if (!extensionPrefValue) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(kConversionErrorMessage,
|
||||
error_ = ErrorUtils::FormatErrorMessage(kConversionErrorMessage,
|
||||
pref->name());
|
||||
bad_message_ = true;
|
||||
return false;
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/task_manager/task_manager.h"
|
||||
#include "chrome/common/chrome_notification_types.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/notification_details.h"
|
||||
#include "content/public/browser/notification_service.h"
|
||||
@ -34,6 +33,7 @@
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/result_codes.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
@ -569,7 +569,7 @@ void GetProcessIdForTabFunction::GetProcessIdForTab() {
|
||||
int tab_index = -1;
|
||||
if (!ExtensionTabUtil::GetTabById(tab_id_, profile(), include_incognito(),
|
||||
NULL, NULL, &contents, &tab_index)) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
extensions::tabs_constants::kTabNotFoundError,
|
||||
base::IntToString(tab_id_));
|
||||
SetResult(Value::CreateIntegerValue(-1));
|
||||
@ -647,7 +647,7 @@ void TerminateFunction::TerminateProcess() {
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(errors::kProcessNotFound,
|
||||
error_ = ErrorUtils::FormatErrorMessage(errors::kProcessNotFound,
|
||||
base::IntToString(process_id_));
|
||||
SendResponse(false);
|
||||
} else {
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "base/values.h"
|
||||
#include "chrome/browser/extensions/api/proxy/proxy_api_constants.h"
|
||||
#include "chrome/browser/prefs/proxy_config_dictionary.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "net/base/data_url.h"
|
||||
#include "net/proxy/proxy_config.h"
|
||||
|
||||
@ -171,7 +171,7 @@ bool GetProxyServer(const DictionaryValue* proxy_server,
|
||||
return false;
|
||||
}
|
||||
if (!IsStringASCII(host16)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(
|
||||
*error = ErrorUtils::FormatErrorMessage(
|
||||
"Invalid 'rules.???.host' entry '*'. 'host' field supports only ASCII "
|
||||
"URLs (encode URLs in Punycode format).",
|
||||
UTF16ToUTF8(host16));
|
||||
@ -226,7 +226,7 @@ bool GetProxyRulesStringFromExtensionPref(const DictionaryValue* proxy_config,
|
||||
if (has_proxy[keys::SCHEME_ALL]) {
|
||||
for (size_t i = 1; i <= keys::SCHEME_MAX; ++i) {
|
||||
if (has_proxy[i]) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(
|
||||
*error = ErrorUtils::FormatErrorMessage(
|
||||
"Proxy rule for * and * cannot be set at the same time.",
|
||||
keys::field_name[keys::SCHEME_ALL], keys::field_name[i]);
|
||||
return false;
|
||||
|
@ -11,15 +11,14 @@
|
||||
#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
|
||||
#include "chrome/browser/extensions/extension_service.h"
|
||||
#include "chrome/browser/extensions/extension_tab_util.h"
|
||||
#include "chrome/browser/extensions/tab_helper.h"
|
||||
#include "chrome/browser/extensions/file_reader.h"
|
||||
#include "chrome/browser/extensions/script_executor.h"
|
||||
#include "chrome/browser/extensions/tab_helper.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/common/extensions/api/tabs.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_constants.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_file_util.h"
|
||||
#include "chrome/common/extensions/extension_l10n_util.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
@ -27,9 +26,11 @@
|
||||
#include "chrome/common/extensions/message_bundle.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
using extensions::api::tabs::InjectDetails;
|
||||
using extensions::ErrorUtils;
|
||||
using extensions::ScriptExecutor;
|
||||
using extensions::UserScript;
|
||||
|
||||
@ -210,10 +211,10 @@ void ExecuteCodeInTabFunction::DidLoadAndLocalizeFile(bool success,
|
||||
#if defined(OS_POSIX)
|
||||
// TODO(viettrungluu): bug: there's no particular reason the path should be
|
||||
// UTF-8, in which case this may fail.
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kLoadFileError,
|
||||
error_ = ErrorUtils::FormatErrorMessage(keys::kLoadFileError,
|
||||
resource_.relative_path().value());
|
||||
#elif defined(OS_WIN)
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kLoadFileError,
|
||||
error_ = ErrorUtils::FormatErrorMessage(keys::kLoadFileError,
|
||||
WideToUTF8(resource_.relative_path().value()));
|
||||
#endif // OS_WIN
|
||||
SendResponse(false);
|
||||
|
@ -52,7 +52,6 @@
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/extensions/api/windows.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "chrome/common/extensions/extension_messages.h"
|
||||
#include "chrome/common/extensions/user_script.h"
|
||||
@ -68,6 +67,7 @@
|
||||
#include "content/public/browser/web_contents_view.h"
|
||||
#include "content/public/common/url_constants.h"
|
||||
#include "extensions/common/constants.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "skia/ext/image_operations.h"
|
||||
#include "skia/ext/platform_canvas.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
@ -92,6 +92,7 @@ using content::OpenURLParams;
|
||||
using content::Referrer;
|
||||
using content::RenderViewHost;
|
||||
using content::WebContents;
|
||||
using extensions::ErrorUtils;
|
||||
using extensions::ScriptExecutor;
|
||||
using extensions::WindowController;
|
||||
using extensions::WindowControllerList;
|
||||
@ -119,7 +120,7 @@ Browser* GetBrowserInProfileWithId(Profile* profile,
|
||||
}
|
||||
|
||||
if (error_message)
|
||||
*error_message = ExtensionErrorUtils::FormatErrorMessage(
|
||||
*error_message = ErrorUtils::FormatErrorMessage(
|
||||
keys::kWindowNotFoundError, base::IntToString(window_id));
|
||||
|
||||
return NULL;
|
||||
@ -167,7 +168,7 @@ bool GetWindowFromWindowID(UIThreadExtensionFunction* function,
|
||||
*controller = WindowControllerList::GetInstance()->
|
||||
FindWindowForFunctionById(function, window_id);
|
||||
if (!(*controller)) {
|
||||
function->SetError(ExtensionErrorUtils::FormatErrorMessage(
|
||||
function->SetError(ErrorUtils::FormatErrorMessage(
|
||||
keys::kWindowNotFoundError, base::IntToString(window_id)));
|
||||
return false;
|
||||
}
|
||||
@ -190,7 +191,7 @@ bool GetTabById(int tab_id,
|
||||
return true;
|
||||
|
||||
if (error_message)
|
||||
*error_message = ExtensionErrorUtils::FormatErrorMessage(
|
||||
*error_message = ErrorUtils::FormatErrorMessage(
|
||||
keys::kTabNotFoundError, base::IntToString(tab_id));
|
||||
|
||||
return false;
|
||||
@ -380,7 +381,7 @@ bool CreateWindowFunction::ShouldOpenIncognitoWindow(
|
||||
}
|
||||
}
|
||||
if (urls->empty() && !first_url_erased.empty()) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kURLsNotAllowedInIncognitoError, first_url_erased);
|
||||
*is_error = true;
|
||||
return false;
|
||||
@ -424,7 +425,7 @@ bool CreateWindowFunction::RunImpl() {
|
||||
GURL url = ExtensionTabUtil::ResolvePossiblyRelativeURL(
|
||||
*i, GetExtension());
|
||||
if (!url.is_valid()) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kInvalidUrlError, *i);
|
||||
return false;
|
||||
}
|
||||
@ -453,7 +454,7 @@ bool CreateWindowFunction::RunImpl() {
|
||||
return false;
|
||||
contents = source_tab_strip->DetachTabContentsAt(tab_index);
|
||||
if (!contents) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kTabNotFoundError, base::IntToString(tab_id));
|
||||
return false;
|
||||
}
|
||||
@ -1027,7 +1028,7 @@ bool CreateTabFunction::RunImpl() {
|
||||
url = ExtensionTabUtil::ResolvePossiblyRelativeURL(url_string,
|
||||
GetExtension());
|
||||
if (!url.is_valid()) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kInvalidUrlError,
|
||||
error_ = ErrorUtils::FormatErrorMessage(keys::kInvalidUrlError,
|
||||
url_string);
|
||||
return false;
|
||||
}
|
||||
@ -1195,7 +1196,7 @@ bool HighlightTabsFunction::RunImpl() {
|
||||
|
||||
// Make sure the index is in range.
|
||||
if (!tabstrip->ContainsIndex(index)) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kTabIndexNotFoundError, base::IntToString(index));
|
||||
return false;
|
||||
}
|
||||
@ -1341,7 +1342,7 @@ bool UpdateTabFunction::UpdateURLIfPresent(DictionaryValue* update_props,
|
||||
url_string, GetExtension());
|
||||
|
||||
if (!url.is_valid()) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kInvalidUrlError, url_string);
|
||||
return false;
|
||||
}
|
||||
@ -1472,7 +1473,7 @@ bool MoveTabsFunction::RunImpl() {
|
||||
TabContents* tab_contents =
|
||||
source_tab_strip->DetachTabContentsAt(tab_index);
|
||||
if (!tab_contents) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kTabNotFoundError, base::IntToString(tab_ids[i]));
|
||||
return false;
|
||||
}
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "chrome/common/extensions/event_filtering_info.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_constants.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_messages.h"
|
||||
#include "chrome/common/extensions/features/feature.h"
|
||||
#include "chrome/common/url_constants.h"
|
||||
@ -47,6 +46,7 @@
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/resource_request_info.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "extensions/common/url_pattern.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "grit/generated_resources.h"
|
||||
@ -65,6 +65,7 @@ using chrome::VersionInfo;
|
||||
using content::BrowserMessageFilter;
|
||||
using content::BrowserThread;
|
||||
using content::ResourceRequestInfo;
|
||||
using extensions::ErrorUtils;
|
||||
using extensions::Extension;
|
||||
using extensions::ExtensionWarning;
|
||||
using extensions::ExtensionWarningService;
|
||||
@ -417,7 +418,7 @@ bool ExtensionWebRequestEventRouter::RequestFilter::InitFromValue(
|
||||
URLPattern::SCHEME_EXTENSION);
|
||||
if (!urls_value->GetString(i, &url) ||
|
||||
pattern.Parse(url) != URLPattern::PARSE_SUCCESS) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(
|
||||
*error = ErrorUtils::FormatErrorMessage(
|
||||
keys::kInvalidRequestFilterUrl, url);
|
||||
return false;
|
||||
}
|
||||
@ -1793,7 +1794,7 @@ bool WebRequestEventHandled::RunImpl() {
|
||||
&new_url_str));
|
||||
response->new_url = GURL(new_url_str);
|
||||
if (!response->new_url.is_valid()) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
keys::kInvalidRedirectUrl, new_url_str);
|
||||
return false;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "chrome/browser/extensions/extension_function.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/common/chrome_version_info.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
#include "ipc/ipc_sender.h"
|
||||
#include "net/base/completion_callback.h"
|
||||
#include "net/base/network_delegate.h"
|
||||
@ -85,7 +85,7 @@ class ExtensionWebRequestEventRouter
|
||||
// unexpected).
|
||||
bool InitFromValue(const base::DictionaryValue& value, std::string* error);
|
||||
|
||||
URLPatternSet urls;
|
||||
extensions::URLPatternSet urls;
|
||||
std::vector<ResourceType::Type> types;
|
||||
int tab_id;
|
||||
int window_id;
|
||||
|
@ -26,13 +26,13 @@
|
||||
#include "chrome/common/chrome_notification_types.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/extensions/extension_constants.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_l10n_util.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "content/public/browser/gpu_data_manager.h"
|
||||
#include "content/public/browser/notification_details.h"
|
||||
#include "content/public/browser/notification_source.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "google_apis/gaia/gaia_constants.h"
|
||||
#include "grit/chromium_strings.h"
|
||||
#include "grit/generated_resources.h"
|
||||
@ -420,7 +420,7 @@ bool CompleteInstallFunction::RunImpl() {
|
||||
scoped_ptr<WebstoreInstaller::Approval> approval(
|
||||
g_pending_approvals.Get().PopApproval(profile(), id));
|
||||
if (!approval.get()) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = ErrorUtils::FormatErrorMessage(
|
||||
kNoPreviousBeginInstallWithManifestError, id);
|
||||
return false;
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
namespace {
|
||||
|
||||
static void AddPattern(URLPatternSet* extent, const std::string& pattern) {
|
||||
@ -25,8 +27,6 @@ static void AddPattern(URLPatternSet* extent, const std::string& pattern) {
|
||||
|
||||
}
|
||||
|
||||
namespace extensions {
|
||||
|
||||
TEST(ExtensionFromUserScript, Basic) {
|
||||
base::ScopedTempDir extensions_dir;
|
||||
ASSERT_TRUE(extensions_dir.CreateUniqueTempDir());
|
||||
|
@ -18,16 +18,16 @@
|
||||
#include "chrome/browser/extensions/extension_scoped_prefs.h"
|
||||
#include "chrome/browser/media_gallery/media_galleries_preferences.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
#include "sync/api/string_ordinal.h"
|
||||
|
||||
class ExtensionPrefValueMap;
|
||||
class ExtensionSorting;
|
||||
class PrefService;
|
||||
class URLPatternSet;
|
||||
|
||||
namespace extensions {
|
||||
class ExtensionPrefsUninstallExtension;
|
||||
class URLPatternSet;
|
||||
struct ExtensionOmniboxSuggestion;
|
||||
|
||||
// Class for managing global and per-extension preferences.
|
||||
|
@ -40,8 +40,8 @@
|
||||
#include "chrome/browser/extensions/api/management/management_api.h"
|
||||
#include "chrome/browser/extensions/api/media_galleries_private/media_galleries_private_event_router.h"
|
||||
#include "chrome/browser/extensions/api/preference/preference_api.h"
|
||||
#include "chrome/browser/extensions/api/runtime/runtime_api.h"
|
||||
#include "chrome/browser/extensions/api/push_messaging/push_messaging_api.h"
|
||||
#include "chrome/browser/extensions/api/runtime/runtime_api.h"
|
||||
#include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
|
||||
#include "chrome/browser/extensions/app_notification_manager.h"
|
||||
#include "chrome/browser/extensions/app_sync_data.h"
|
||||
@ -93,13 +93,12 @@
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/chrome_version_info.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_file_util.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "chrome/common/extensions/extension_messages.h"
|
||||
#include "chrome/common/extensions/extension_resource.h"
|
||||
#include "chrome/common/extensions/features/feature.h"
|
||||
#include "chrome/common/extensions/feature_switch.h"
|
||||
#include "chrome/common/extensions/features/feature.h"
|
||||
#include "chrome/common/extensions/manifest.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "chrome/common/url_constants.h"
|
||||
@ -111,6 +110,7 @@
|
||||
#include "content/public/browser/plugin_service.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/common/pepper_plugin_info.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "grit/generated_resources.h"
|
||||
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
|
||||
|
@ -114,6 +114,7 @@ using extensions::ExtensionPrefs;
|
||||
using extensions::ExtensionSystem;
|
||||
using extensions::FeatureSwitch;
|
||||
using extensions::PermissionSet;
|
||||
using extensions::URLPatternSet;
|
||||
|
||||
namespace keys = extension_manifest_keys;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "base/message_loop.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "chrome/browser/extensions/extension_function.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -133,7 +133,7 @@ bool QuotaLimitHeuristic::ApplyToArgs(const ListValue* args,
|
||||
}
|
||||
|
||||
std::string QuotaLimitHeuristic::GetError() const {
|
||||
return ExtensionErrorUtils::FormatErrorMessage(kOverQuotaError, name_);
|
||||
return extensions::ErrorUtils::FormatErrorMessage(kOverQuotaError, name_);
|
||||
}
|
||||
|
||||
ExtensionsQuotaService::SustainedLimit::SustainedLimit(
|
||||
|
@ -18,9 +18,9 @@
|
||||
#include "base/string16.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/browser/extensions/extension_icon_manager.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "content/public/browser/notification_observer.h"
|
||||
#include "content/public/browser/notification_registrar.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
|
||||
|
||||
class Profile;
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "base/message_loop.h"
|
||||
#include "base/metrics/histogram.h"
|
||||
#include "chrome/common/extensions/api/extension_api.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
@ -76,7 +76,7 @@ ValueStore::WriteResult QuotaExceededFor(Resource resource) {
|
||||
NOTREACHED();
|
||||
}
|
||||
return ValueStore::MakeWriteResult(
|
||||
ExtensionErrorUtils::FormatErrorMessage(kQuotaExceededError, name));
|
||||
ErrorUtils::FormatErrorMessage(kQuotaExceededError, name));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
using extensions::URLPatternSet;
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -16,9 +16,9 @@
|
||||
#include "chrome/browser/infobars/infobar_tab_helper.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/url_constants.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "grit/generated_resources.h"
|
||||
|
||||
using extensions::Extension;
|
||||
@ -61,7 +61,7 @@ bool ShowInfoBarFunction::RunImpl() {
|
||||
NULL,
|
||||
&web_contents,
|
||||
NULL)) {
|
||||
error_ = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error_ = extensions::ErrorUtils::FormatErrorMessage(
|
||||
extensions::tabs_constants::kTabNotFoundError,
|
||||
base::IntToString(tab_id));
|
||||
return false;
|
||||
|
@ -277,7 +277,7 @@ void RenderViewContextMenu::Cancel() {
|
||||
PlatformCancel();
|
||||
}
|
||||
|
||||
static bool ExtensionPatternMatch(const URLPatternSet& patterns,
|
||||
static bool ExtensionPatternMatch(const extensions::URLPatternSet& patterns,
|
||||
const GURL& url) {
|
||||
// No patterns means no restriction, so that implicitly matches.
|
||||
if (patterns.is_empty())
|
||||
@ -289,7 +289,7 @@ static bool ExtensionPatternMatch(const URLPatternSet& patterns,
|
||||
bool RenderViewContextMenu::ExtensionContextAndPatternMatch(
|
||||
const content::ContextMenuParams& params,
|
||||
MenuItem::ContextList contexts,
|
||||
const URLPatternSet& target_url_patterns) {
|
||||
const extensions::URLPatternSet& target_url_patterns) {
|
||||
bool has_link = !params.link_url.is_empty();
|
||||
bool has_selection = !params.selection_text.empty();
|
||||
bool in_frame = !params.frame_url.is_empty();
|
||||
|
@ -196,7 +196,7 @@ class RenderViewContextMenu : public ui::SimpleMenuModel::Delegate,
|
||||
static bool ExtensionContextAndPatternMatch(
|
||||
const content::ContextMenuParams& params,
|
||||
extensions::MenuItem::ContextList contexts,
|
||||
const URLPatternSet& target_url_patterns);
|
||||
const extensions::URLPatternSet& target_url_patterns);
|
||||
static bool MenuItemMatchesParams(
|
||||
const content::ContextMenuParams& params,
|
||||
const extensions::MenuItem* item);
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
|
||||
|
||||
using extensions::MenuItem;
|
||||
using extensions::URLPatternSet;
|
||||
|
||||
class RenderViewContextMenuTest : public testing::Test {
|
||||
public:
|
||||
|
@ -193,9 +193,9 @@ void AddExceptionsGrantedByHostedApps(
|
||||
extension != extensions->end(); ++extension) {
|
||||
if (!app_filter(**extension, profile)) continue;
|
||||
|
||||
URLPatternSet web_extent = (*extension)->web_extent();
|
||||
extensions::URLPatternSet web_extent = (*extension)->web_extent();
|
||||
// Add patterns from web extent.
|
||||
for (URLPatternSet::const_iterator pattern = web_extent.begin();
|
||||
for (extensions::URLPatternSet::const_iterator pattern = web_extent.begin();
|
||||
pattern != web_extent.end(); ++pattern) {
|
||||
std::string url_pattern = pattern->GetAsString();
|
||||
AddExceptionForHostedApp(url_pattern, **extension, exceptions);
|
||||
|
@ -53,8 +53,12 @@
|
||||
'sources': [
|
||||
'../extensions/common/constants.cc',
|
||||
'../extensions/common/constants.h',
|
||||
'../extensions/common/error_utils.cc',
|
||||
'../extensions/common/error_utils.h',
|
||||
'../extensions/common/url_pattern.cc',
|
||||
'../extensions/common/url_pattern.h',
|
||||
'../extensions/common/url_pattern_set.cc',
|
||||
'../extensions/common/url_pattern_set.h',
|
||||
'common/all_messages.h',
|
||||
'common/attrition_experiments.h',
|
||||
'common/auto_start_linux.cc',
|
||||
@ -131,8 +135,6 @@
|
||||
'common/extensions/extension.h',
|
||||
'common/extensions/extension_constants.cc',
|
||||
'common/extensions/extension_constants.h',
|
||||
'common/extensions/extension_error_utils.cc',
|
||||
'common/extensions/extension_error_utils.h',
|
||||
'common/extensions/extension_file_util.cc',
|
||||
'common/extensions/extension_file_util.h',
|
||||
'common/extensions/extension_icon_set.cc',
|
||||
@ -202,8 +204,6 @@
|
||||
'common/extensions/unpacker.h',
|
||||
'common/extensions/update_manifest.cc',
|
||||
'common/extensions/update_manifest.h',
|
||||
'common/extensions/url_pattern_set.cc',
|
||||
'common/extensions/url_pattern_set.h',
|
||||
'common/extensions/user_script.cc',
|
||||
'common/extensions/user_script.h',
|
||||
'common/extensions/value_counter.cc',
|
||||
|
@ -37,6 +37,7 @@
|
||||
],
|
||||
'sources': [
|
||||
'../extensions/common/url_pattern_unittest.cc',
|
||||
'../extensions/common/url_pattern_set_unittest.cc',
|
||||
'app/breakpad_mac_stubs.mm',
|
||||
'app/chrome_main_delegate.cc',
|
||||
'app/chrome_main_delegate.h',
|
||||
@ -1511,7 +1512,6 @@
|
||||
'common/extensions/permissions/socket_permission_unittest.cc',
|
||||
'common/extensions/unpacker_unittest.cc',
|
||||
'common/extensions/update_manifest_unittest.cc',
|
||||
'common/extensions/url_pattern_set_unittest.cc',
|
||||
'common/extensions/user_script_unittest.cc',
|
||||
'common/extensions/value_counter_unittest.cc',
|
||||
'common/extensions/api/extension_api_unittest.cc',
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "base/values.h"
|
||||
#include "chrome/common/extensions/features/feature.h"
|
||||
#include "chrome/common/extensions/features/feature_provider.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
|
||||
namespace base {
|
||||
class DictionaryValue;
|
||||
|
@ -10,8 +10,8 @@
|
||||
#include "base/string_util.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "grit/generated_resources.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
|
||||
@ -19,6 +19,8 @@ namespace errors = extension_manifest_errors;
|
||||
namespace keys = extension_manifest_keys;
|
||||
namespace values = extension_manifest_values;
|
||||
|
||||
using extensions::ErrorUtils;
|
||||
|
||||
namespace {
|
||||
|
||||
static const char kMissing[] = "Missing";
|
||||
@ -36,7 +38,7 @@ ui::Accelerator ParseImpl(const std::string& accelerator,
|
||||
platform_key != values::kKeybindingPlatformChromeOs &&
|
||||
platform_key != values::kKeybindingPlatformLinux &&
|
||||
platform_key != values::kKeybindingPlatformDefault) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidKeyBindingUnknownPlatform,
|
||||
base::IntToString(index),
|
||||
platform_key);
|
||||
@ -46,7 +48,7 @@ ui::Accelerator ParseImpl(const std::string& accelerator,
|
||||
std::vector<std::string> tokens;
|
||||
base::SplitString(accelerator, '+', &tokens);
|
||||
if (tokens.size() < 2 || tokens.size() > 3) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidKeyBinding,
|
||||
base::IntToString(index),
|
||||
platform_key,
|
||||
@ -99,7 +101,7 @@ ui::Accelerator ParseImpl(const std::string& accelerator,
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidKeyBinding,
|
||||
base::IntToString(index),
|
||||
platform_key,
|
||||
@ -120,7 +122,7 @@ ui::Accelerator ParseImpl(const std::string& accelerator,
|
||||
// as a modifier.
|
||||
if (key == ui::VKEY_UNKNOWN || (ctrl && alt) || (command && alt) ||
|
||||
(shift && !ctrl && !alt && !command)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidKeyBinding,
|
||||
base::IntToString(index),
|
||||
platform_key,
|
||||
@ -222,7 +224,7 @@ bool Command::Parse(DictionaryValue* command,
|
||||
// Found a platform, add it to the suggestions list.
|
||||
suggestions[*iter] = suggested_key_string;
|
||||
} else {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidKeyBinding,
|
||||
base::IntToString(index),
|
||||
keys::kSuggestedKey,
|
||||
@ -240,7 +242,7 @@ bool Command::Parse(DictionaryValue* command,
|
||||
// If only a single string is provided, it must be default for all.
|
||||
suggestions["default"] = suggested_key_string;
|
||||
} else {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidKeyBinding,
|
||||
base::IntToString(index),
|
||||
keys::kSuggestedKey,
|
||||
@ -258,7 +260,7 @@ bool Command::Parse(DictionaryValue* command,
|
||||
// other platforms, which is not what we want.
|
||||
if (iter->first == "default" &&
|
||||
iter->second.find("Command+") != std::string::npos) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidKeyBinding,
|
||||
base::IntToString(index),
|
||||
keys::kSuggestedKey,
|
||||
@ -275,7 +277,7 @@ bool Command::Parse(DictionaryValue* command,
|
||||
if (suggestions.find(key) == suggestions.end())
|
||||
key = values::kKeybindingPlatformDefault;
|
||||
if (suggestions.find(key) == suggestions.end()) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidKeyBindingMissingPlatform,
|
||||
base::IntToString(index),
|
||||
keys::kSuggestedKey,
|
||||
@ -293,7 +295,7 @@ bool Command::Parse(DictionaryValue* command,
|
||||
ui::Accelerator accelerator =
|
||||
ParseImpl(iter->second, iter->first, index, error);
|
||||
if (accelerator.key_code() == ui::VKEY_UNKNOWN) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidKeyBinding,
|
||||
base::IntToString(index),
|
||||
iter->first,
|
||||
@ -314,7 +316,7 @@ bool Command::Parse(DictionaryValue* command,
|
||||
extension_manifest_values::kScriptBadgeCommandEvent) {
|
||||
if (!command->GetString(keys::kDescription, &description_) ||
|
||||
description_.empty()) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidKeyBindingDescription,
|
||||
base::IntToString(index));
|
||||
return false;
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/chrome_version_info.h"
|
||||
#include "chrome/common/extensions/csp_validator.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "chrome/common/extensions/extension_resource.h"
|
||||
#include "chrome/common/extensions/feature_switch.h"
|
||||
@ -37,11 +36,12 @@
|
||||
#include "chrome/common/extensions/manifest.h"
|
||||
#include "chrome/common/extensions/permissions/permission_set.h"
|
||||
#include "chrome/common/extensions/permissions/permissions_info.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "chrome/common/extensions/user_script.h"
|
||||
#include "chrome/common/url_constants.h"
|
||||
#include "crypto/sha2.h"
|
||||
#include "extensions/common/constants.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
#include "googleurl/src/url_util.h"
|
||||
#include "grit/chromium_strings.h"
|
||||
#include "grit/theme_resources.h"
|
||||
@ -157,13 +157,13 @@ bool LoadIconsFromDictionary(const DictionaryValue* icons_value,
|
||||
if (icons_value->HasKey(key)) {
|
||||
std::string icon_path;
|
||||
if (!icons_value->GetString(key, &icon_path)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidIconPath, key);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!NormalizeAndValidatePath(&icon_path)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidIconPath, key);
|
||||
return false;
|
||||
}
|
||||
@ -265,14 +265,14 @@ bool ReadLaunchDimension(const extensions::Manifest* manifest,
|
||||
Value* temp = NULL;
|
||||
if (manifest->Get(key, &temp)) {
|
||||
if (!is_valid_container) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidLaunchValueContainer,
|
||||
key);
|
||||
return false;
|
||||
}
|
||||
if (!temp->GetAsInteger(target) || *target < 0) {
|
||||
*target = 0;
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidLaunchValue,
|
||||
key);
|
||||
return false;
|
||||
@ -610,7 +610,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
|
||||
if (content_script->HasKey(keys::kRunAt)) {
|
||||
std::string run_location;
|
||||
if (!content_script->GetString(keys::kRunAt, &run_location)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidRunAt,
|
||||
base::IntToString(definition_index));
|
||||
return false;
|
||||
@ -623,7 +623,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
|
||||
} else if (run_location == values::kRunAtDocumentIdle) {
|
||||
result->set_run_location(UserScript::DOCUMENT_IDLE);
|
||||
} else {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidRunAt,
|
||||
base::IntToString(definition_index));
|
||||
return false;
|
||||
@ -634,7 +634,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
|
||||
if (content_script->HasKey(keys::kAllFrames)) {
|
||||
bool all_frames = false;
|
||||
if (!content_script->GetBoolean(keys::kAllFrames, &all_frames)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidAllFrames, base::IntToString(definition_index));
|
||||
return false;
|
||||
}
|
||||
@ -644,14 +644,14 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
|
||||
// matches (required)
|
||||
const ListValue* matches = NULL;
|
||||
if (!content_script->GetList(keys::kMatches, &matches)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidMatches,
|
||||
base::IntToString(definition_index));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (matches->GetSize() == 0) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidMatchCount,
|
||||
base::IntToString(definition_index));
|
||||
return false;
|
||||
@ -659,7 +659,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
|
||||
for (size_t j = 0; j < matches->GetSize(); ++j) {
|
||||
std::string match_str;
|
||||
if (!matches->GetString(j, &match_str)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidMatch,
|
||||
base::IntToString(definition_index),
|
||||
base::IntToString(j),
|
||||
@ -673,7 +673,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
|
||||
|
||||
URLPattern::ParseResult parse_result = pattern.Parse(match_str);
|
||||
if (parse_result != URLPattern::PARSE_SUCCESS) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidMatch,
|
||||
base::IntToString(definition_index),
|
||||
base::IntToString(j),
|
||||
@ -697,7 +697,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
|
||||
if (content_script->HasKey(keys::kExcludeMatches)) { // optional
|
||||
const ListValue* exclude_matches = NULL;
|
||||
if (!content_script->GetList(keys::kExcludeMatches, &exclude_matches)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidExcludeMatches,
|
||||
base::IntToString(definition_index));
|
||||
return false;
|
||||
@ -706,7 +706,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
|
||||
for (size_t j = 0; j < exclude_matches->GetSize(); ++j) {
|
||||
std::string match_str;
|
||||
if (!exclude_matches->GetString(j, &match_str)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidExcludeMatch,
|
||||
base::IntToString(definition_index),
|
||||
base::IntToString(j),
|
||||
@ -719,7 +719,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
|
||||
pattern.SetValidSchemes(URLPattern::SCHEME_ALL);
|
||||
URLPattern::ParseResult parse_result = pattern.Parse(match_str);
|
||||
if (parse_result != URLPattern::PARSE_SUCCESS) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidExcludeMatch,
|
||||
base::IntToString(definition_index), base::IntToString(j),
|
||||
URLPattern::GetParseResultString(parse_result));
|
||||
@ -745,7 +745,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
|
||||
const ListValue* js = NULL;
|
||||
if (content_script->HasKey(keys::kJs) &&
|
||||
!content_script->GetList(keys::kJs, &js)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidJsList,
|
||||
base::IntToString(definition_index));
|
||||
return false;
|
||||
@ -754,7 +754,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
|
||||
const ListValue* css = NULL;
|
||||
if (content_script->HasKey(keys::kCss) &&
|
||||
!content_script->GetList(keys::kCss, &css)) {
|
||||
*error = ExtensionErrorUtils::
|
||||
*error = ErrorUtils::
|
||||
FormatErrorMessageUTF16(errors::kInvalidCssList,
|
||||
base::IntToString(definition_index));
|
||||
return false;
|
||||
@ -762,7 +762,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
|
||||
|
||||
// The manifest needs to have at least one js or css user script definition.
|
||||
if (((js ? js->GetSize() : 0) + (css ? css->GetSize() : 0)) == 0) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kMissingFile,
|
||||
base::IntToString(definition_index));
|
||||
return false;
|
||||
@ -774,7 +774,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
|
||||
const Value* value;
|
||||
std::string relative;
|
||||
if (!js->Get(script_index, &value) || !value->GetAsString(&relative)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidJs,
|
||||
base::IntToString(definition_index),
|
||||
base::IntToString(script_index));
|
||||
@ -793,7 +793,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
|
||||
const Value* value;
|
||||
std::string relative;
|
||||
if (!css->Get(script_index, &value) || !value->GetAsString(&relative)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidCss,
|
||||
base::IntToString(definition_index),
|
||||
base::IntToString(script_index));
|
||||
@ -821,7 +821,7 @@ bool Extension::LoadGlobsHelper(
|
||||
|
||||
const ListValue* list = NULL;
|
||||
if (!content_script->GetList(globs_property_name, &list)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidGlobList,
|
||||
base::IntToString(content_script_index),
|
||||
globs_property_name);
|
||||
@ -831,7 +831,7 @@ bool Extension::LoadGlobsHelper(
|
||||
for (size_t i = 0; i < list->GetSize(); ++i) {
|
||||
std::string glob;
|
||||
if (!list->GetString(i, &glob)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidGlob,
|
||||
base::IntToString(content_script_index),
|
||||
globs_property_name,
|
||||
@ -929,7 +929,7 @@ scoped_ptr<Extension::ActionInfo> Extension::LoadExtensionActionInfoHelper(
|
||||
if (manifest_version_ == 1 &&
|
||||
extension_action->HasKey(keys::kPageActionPopup)) {
|
||||
if (popup_key) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidPageActionOldAndNewKeys,
|
||||
keys::kPageActionDefaultPopup,
|
||||
keys::kPageActionPopup);
|
||||
@ -947,7 +947,7 @@ scoped_ptr<Extension::ActionInfo> Extension::LoadExtensionActionInfoHelper(
|
||||
} else if (manifest_version_ == 1 &&
|
||||
extension_action->GetDictionary(popup_key, &popup)) {
|
||||
if (!popup->GetString(keys::kPageActionPopupPath, &url_str)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidPageActionPopupPath, "<missing>");
|
||||
return scoped_ptr<ActionInfo>();
|
||||
}
|
||||
@ -960,7 +960,7 @@ scoped_ptr<Extension::ActionInfo> Extension::LoadExtensionActionInfoHelper(
|
||||
// An empty string is treated as having no popup.
|
||||
result->default_popup_url = GetResourceURL(url_str);
|
||||
if (!result->default_popup_url.is_valid()) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidPageActionPopupPath, url_str);
|
||||
return scoped_ptr<ActionInfo>();
|
||||
}
|
||||
@ -1114,7 +1114,7 @@ bool Extension::LoadExtent(const char* key,
|
||||
for (size_t i = 0; i < pattern_list->GetSize(); ++i) {
|
||||
std::string pattern_string;
|
||||
if (!pattern_list->GetString(i, &pattern_string)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(value_error,
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(value_error,
|
||||
base::UintToString(i),
|
||||
errors::kExpectString);
|
||||
return false;
|
||||
@ -1128,7 +1128,7 @@ bool Extension::LoadExtent(const char* key,
|
||||
}
|
||||
|
||||
if (parse_result != URLPattern::PARSE_SUCCESS) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
value_error,
|
||||
base::UintToString(i),
|
||||
URLPattern::GetParseResultString(parse_result));
|
||||
@ -1137,7 +1137,7 @@ bool Extension::LoadExtent(const char* key,
|
||||
|
||||
// Do not allow authors to claim "<all_urls>".
|
||||
if (pattern.match_all_urls()) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
value_error,
|
||||
base::UintToString(i),
|
||||
errors::kCannotClaimAllURLsInExtent);
|
||||
@ -1146,7 +1146,7 @@ bool Extension::LoadExtent(const char* key,
|
||||
|
||||
// Do not allow authors to claim "*" for host.
|
||||
if (pattern.host().empty()) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
value_error,
|
||||
base::UintToString(i),
|
||||
errors::kCannotClaimAllHostsInExtent);
|
||||
@ -1156,7 +1156,7 @@ bool Extension::LoadExtent(const char* key,
|
||||
// We do not allow authors to put wildcards in their paths. Instead, we
|
||||
// imply one at the end.
|
||||
if (pattern.path().find('*') != std::string::npos) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
value_error,
|
||||
base::UintToString(i),
|
||||
errors::kNoWildCardsInPaths);
|
||||
@ -1188,7 +1188,7 @@ bool Extension::LoadLaunchURL(string16* error) {
|
||||
|
||||
std::string launch_path;
|
||||
if (!temp->GetAsString(&launch_path)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidLaunchValue,
|
||||
keys::kLaunchLocalPath);
|
||||
return false;
|
||||
@ -1197,7 +1197,7 @@ bool Extension::LoadLaunchURL(string16* error) {
|
||||
// Ensure the launch path is a valid relative URL.
|
||||
GURL resolved = url().Resolve(launch_path);
|
||||
if (!resolved.is_valid() || resolved.GetOrigin() != url()) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidLaunchValue,
|
||||
keys::kLaunchLocalPath);
|
||||
return false;
|
||||
@ -1207,7 +1207,7 @@ bool Extension::LoadLaunchURL(string16* error) {
|
||||
} else if (manifest_->Get(keys::kLaunchWebURL, &temp)) {
|
||||
std::string launch_url;
|
||||
if (!temp->GetAsString(&launch_url)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidLaunchValue,
|
||||
keys::kLaunchWebURL);
|
||||
return false;
|
||||
@ -1217,7 +1217,7 @@ bool Extension::LoadLaunchURL(string16* error) {
|
||||
GURL url(launch_url);
|
||||
URLPattern pattern(kValidWebExtentSchemes);
|
||||
if (!url.is_valid() || !pattern.SetScheme(url.scheme())) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidLaunchValue,
|
||||
keys::kLaunchWebURL);
|
||||
return false;
|
||||
@ -1234,7 +1234,7 @@ bool Extension::LoadLaunchURL(string16* error) {
|
||||
GURL launch_url(launch_web_url());
|
||||
URLPattern pattern(kValidWebExtentSchemes);
|
||||
if (!pattern.SetScheme("*")) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidLaunchValue,
|
||||
keys::kLaunchWebURL);
|
||||
return false;
|
||||
@ -1386,7 +1386,7 @@ bool Extension::LoadManifestVersion(string16* error) {
|
||||
manifest_version_ < kModernManifestVersion &&
|
||||
!CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kAllowLegacyExtensionManifests)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidManifestVersionOld,
|
||||
base::IntToString(kModernManifestVersion));
|
||||
return false;
|
||||
@ -1400,7 +1400,7 @@ bool Extension::LoadHomepageURL(string16* error) {
|
||||
return true;
|
||||
std::string tmp_homepage_url;
|
||||
if (!manifest_->GetString(keys::kHomepageURL, &tmp_homepage_url)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidHomepageURL, "");
|
||||
return false;
|
||||
}
|
||||
@ -1408,7 +1408,7 @@ bool Extension::LoadHomepageURL(string16* error) {
|
||||
if (!homepage_url_.is_valid() ||
|
||||
(!homepage_url_.SchemeIs("http") &&
|
||||
!homepage_url_.SchemeIs("https"))) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidHomepageURL, tmp_homepage_url);
|
||||
return false;
|
||||
}
|
||||
@ -1420,14 +1420,14 @@ bool Extension::LoadUpdateURL(string16* error) {
|
||||
return true;
|
||||
std::string tmp_update_url;
|
||||
if (!manifest_->GetString(keys::kUpdateURL, &tmp_update_url)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidUpdateURL, "");
|
||||
return false;
|
||||
}
|
||||
update_url_ = GURL(tmp_update_url);
|
||||
if (!update_url_.is_valid() ||
|
||||
update_url_.has_ref()) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidUpdateURL, tmp_update_url);
|
||||
return false;
|
||||
}
|
||||
@ -1459,7 +1459,7 @@ bool Extension::LoadCommands(string16* error) {
|
||||
}
|
||||
|
||||
if (commands->size() > kMaxCommandsPerExtension) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidKeyBindingTooMany,
|
||||
base::IntToString(kMaxCommandsPerExtension));
|
||||
return false;
|
||||
@ -1472,7 +1472,7 @@ bool Extension::LoadCommands(string16* error) {
|
||||
|
||||
DictionaryValue* command = NULL;
|
||||
if (!commands->GetDictionary(*iter, &command)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidKeyBindingDictionary,
|
||||
base::IntToString(command_index));
|
||||
return false;
|
||||
@ -1528,7 +1528,7 @@ bool Extension::LoadPlugins(string16* error) {
|
||||
// Get plugins[i].path.
|
||||
std::string path_str;
|
||||
if (!plugin_value->GetString(keys::kPluginsPath, &path_str)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidPluginsPath, base::IntToString(i));
|
||||
return false;
|
||||
}
|
||||
@ -1537,7 +1537,7 @@ bool Extension::LoadPlugins(string16* error) {
|
||||
bool is_public = false;
|
||||
if (plugin_value->HasKey(keys::kPluginsPublic)) {
|
||||
if (!plugin_value->GetBoolean(keys::kPluginsPublic, &is_public)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidPluginsPublic, base::IntToString(i));
|
||||
return false;
|
||||
}
|
||||
@ -1580,7 +1580,7 @@ bool Extension::LoadNaClModules(string16* error) {
|
||||
// Get nacl_modules[i].path.
|
||||
std::string path_str;
|
||||
if (!module_value->GetString(keys::kNaClModulesPath, &path_str)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidNaClModulesPath, base::IntToString(i));
|
||||
return false;
|
||||
}
|
||||
@ -1588,7 +1588,7 @@ bool Extension::LoadNaClModules(string16* error) {
|
||||
// Get nacl_modules[i].mime_type.
|
||||
std::string mime_type;
|
||||
if (!module_value->GetString(keys::kNaClModulesMIMEType, &mime_type)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidNaClModulesMIMEType, base::IntToString(i));
|
||||
return false;
|
||||
}
|
||||
@ -1612,13 +1612,13 @@ bool Extension::LoadWebAccessibleResources(string16* error) {
|
||||
for (size_t i = 0; i < list_value->GetSize(); ++i) {
|
||||
std::string relative_path;
|
||||
if (!list_value->GetString(i, &relative_path)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidWebAccessibleResource, base::IntToString(i));
|
||||
return false;
|
||||
}
|
||||
URLPattern pattern(URLPattern::SCHEME_EXTENSION);
|
||||
if (pattern.Parse(extension_url_.spec()) != URLPattern::PARSE_SUCCESS) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidURLPatternError, extension_url_.spec());
|
||||
return false;
|
||||
}
|
||||
@ -1643,13 +1643,13 @@ bool Extension::LoadSandboxedPages(string16* error) {
|
||||
for (size_t i = 0; i < list_value->GetSize(); ++i) {
|
||||
std::string relative_path;
|
||||
if (!list_value->GetString(i, &relative_path)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidSandboxedPage, base::IntToString(i));
|
||||
return false;
|
||||
}
|
||||
URLPattern pattern(URLPattern::SCHEME_EXTENSION);
|
||||
if (pattern.Parse(extension_url_.spec()) != URLPattern::PARSE_SUCCESS) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidURLPatternError, extension_url_.spec());
|
||||
return false;
|
||||
}
|
||||
@ -1704,7 +1704,7 @@ bool Extension::LoadRequirements(string16* error) {
|
||||
DictionaryValue* requirement_value;
|
||||
if (!requirements_value->GetDictionaryWithoutPathExpansion(
|
||||
*it, &requirement_value)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidRequirement, *it);
|
||||
return false;
|
||||
}
|
||||
@ -1715,14 +1715,14 @@ bool Extension::LoadRequirements(string16* error) {
|
||||
plugin_it != requirement_value->end_keys(); ++plugin_it) {
|
||||
bool plugin_required = false;
|
||||
if (!requirement_value->GetBoolean(*plugin_it, &plugin_required)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidRequirement, *it);
|
||||
return false;
|
||||
}
|
||||
if (*plugin_it == "npapi") {
|
||||
requirements_.npapi = plugin_required;
|
||||
} else {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidRequirement, *it);
|
||||
return false;
|
||||
}
|
||||
@ -1732,7 +1732,7 @@ bool Extension::LoadRequirements(string16* error) {
|
||||
if (!requirement_value->GetListWithoutPathExpansion("features",
|
||||
&features) ||
|
||||
!features) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidRequirement, *it);
|
||||
return false;
|
||||
}
|
||||
@ -1747,7 +1747,7 @@ bool Extension::LoadRequirements(string16* error) {
|
||||
} else if (feature == "css3d") {
|
||||
requirements_.css3d = true;
|
||||
} else {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidRequirement, *it);
|
||||
return false;
|
||||
}
|
||||
@ -1841,7 +1841,7 @@ bool Extension::LoadBackgroundScripts(const std::string& key, string16* error) {
|
||||
for (size_t i = 0; i < background_scripts->GetSize(); ++i) {
|
||||
std::string script;
|
||||
if (!background_scripts->GetString(i, &script)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidBackgroundScript, base::IntToString(i));
|
||||
return false;
|
||||
}
|
||||
@ -1970,7 +1970,7 @@ bool Extension::LoadWebIntentAction(const std::string& action_name,
|
||||
if (!intent_service.HasKey(keys::kIntentType) ||
|
||||
!intent_service.GetList(keys::kIntentType, &mime_types) ||
|
||||
mime_types->GetSize() == 0) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidIntentType, action_name);
|
||||
return false;
|
||||
}
|
||||
@ -1985,7 +1985,7 @@ bool Extension::LoadWebIntentAction(const std::string& action_name,
|
||||
|
||||
if (intent_service.HasKey(keys::kIntentHref)) {
|
||||
if (!href.empty()) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidIntentHrefOldAndNewKey, action_name,
|
||||
keys::kIntentPath, keys::kIntentHref);
|
||||
return false;
|
||||
@ -2008,11 +2008,11 @@ bool Extension::LoadWebIntentAction(const std::string& action_name,
|
||||
// If there still is not an href, the manifest is malformed, unless this is a
|
||||
// platform app in which case the href should not be present.
|
||||
if (href.empty() && !is_platform_app()) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidIntentHrefEmpty, action_name);
|
||||
return false;
|
||||
} else if (!href.empty() && is_platform_app()) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidIntentHrefInPlatformApp, action_name);
|
||||
return false;
|
||||
}
|
||||
@ -2022,7 +2022,7 @@ bool Extension::LoadWebIntentAction(const std::string& action_name,
|
||||
// Hosted apps require an absolute URL for intents.
|
||||
if (!service_url.is_valid() ||
|
||||
!(web_extent().MatchesURL(service_url))) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidIntentPageInHostedApp, action_name);
|
||||
return false;
|
||||
}
|
||||
@ -2032,7 +2032,7 @@ bool Extension::LoadWebIntentAction(const std::string& action_name,
|
||||
} else {
|
||||
// We do not allow absolute intent URLs in non-hosted apps.
|
||||
if (service_url.is_valid()) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kCannotAccessPage, href);
|
||||
return false;
|
||||
}
|
||||
@ -2047,7 +2047,7 @@ bool Extension::LoadWebIntentAction(const std::string& action_name,
|
||||
|
||||
if (intent_service.HasKey(keys::kIntentDisposition)) {
|
||||
if (is_platform_app()) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidIntentDispositionInPlatformApp, action_name);
|
||||
return false;
|
||||
}
|
||||
@ -2068,7 +2068,7 @@ bool Extension::LoadWebIntentAction(const std::string& action_name,
|
||||
|
||||
for (size_t i = 0; i < mime_types->GetSize(); ++i) {
|
||||
if (!mime_types->GetString(i, &service.type)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidIntentTypeElement, action_name,
|
||||
std::string(base::IntToString(i)));
|
||||
return false;
|
||||
@ -2134,7 +2134,7 @@ bool Extension::LoadFileHandler(const std::string& handler_id,
|
||||
if (!handler_info.HasKey(keys::kFileHandlerTypes) ||
|
||||
!handler_info.GetList(keys::kFileHandlerTypes, &mime_types) ||
|
||||
mime_types->GetSize() == 0) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidFileHandlerType, handler_id);
|
||||
return false;
|
||||
}
|
||||
@ -2149,7 +2149,7 @@ bool Extension::LoadFileHandler(const std::string& handler_id,
|
||||
|
||||
for (size_t i = 0; i < mime_types->GetSize(); ++i) {
|
||||
if (!mime_types->GetString(i, &service.type)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidFileHandlerTypeElement, handler_id,
|
||||
std::string(base::IntToString(i)));
|
||||
return false;
|
||||
@ -2252,7 +2252,7 @@ bool Extension::LoadInputComponents(const APIPermissionSet& api_permissions,
|
||||
|
||||
// Get input_components[i].name.
|
||||
if (!module_value->GetString(keys::kName, &name_str)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidInputComponentName, base::IntToString(i));
|
||||
return false;
|
||||
}
|
||||
@ -2263,12 +2263,12 @@ bool Extension::LoadInputComponents(const APIPermissionSet& api_permissions,
|
||||
if (type_str == "ime") {
|
||||
type = INPUT_COMPONENT_TYPE_IME;
|
||||
} else {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidInputComponentType, base::IntToString(i));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidInputComponentType, base::IntToString(i));
|
||||
return false;
|
||||
}
|
||||
@ -2280,7 +2280,7 @@ bool Extension::LoadInputComponents(const APIPermissionSet& api_permissions,
|
||||
|
||||
// Get input_components[i].description.
|
||||
if (!module_value->GetString(keys::kDescription, &description_str)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidInputComponentDescription, base::IntToString(i));
|
||||
return false;
|
||||
}
|
||||
@ -2299,7 +2299,7 @@ bool Extension::LoadInputComponents(const APIPermissionSet& api_permissions,
|
||||
for (size_t j = 0; j < layouts_value->GetSize(); ++j) {
|
||||
std::string layout_name_str;
|
||||
if (!layouts_value->GetString(j, &layout_name_str)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidInputComponentLayoutName, base::IntToString(i),
|
||||
base::IntToString(j));
|
||||
return false;
|
||||
@ -2310,14 +2310,14 @@ bool Extension::LoadInputComponents(const APIPermissionSet& api_permissions,
|
||||
if (module_value->HasKey(keys::kShortcutKey)) {
|
||||
DictionaryValue* shortcut_value = NULL;
|
||||
if (!module_value->GetDictionary(keys::kShortcutKey, &shortcut_value)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidInputComponentShortcutKey, base::IntToString(i));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get input_components[i].shortcut_keycode.
|
||||
if (!shortcut_value->GetString(keys::kKeycode, &shortcut_keycode_str)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidInputComponentShortcutKeycode,
|
||||
base::IntToString(i));
|
||||
return false;
|
||||
@ -2367,7 +2367,7 @@ bool Extension::LoadContentScripts(string16* error) {
|
||||
for (size_t i = 0; i < list_value->GetSize(); ++i) {
|
||||
DictionaryValue* content_script = NULL;
|
||||
if (!list_value->GetDictionary(i, &content_script)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidContentScript, base::IntToString(i));
|
||||
return false;
|
||||
}
|
||||
@ -2572,7 +2572,7 @@ FileBrowserHandler* Extension::LoadFileBrowserHandler(
|
||||
std::string access;
|
||||
if (!access_list_value->GetString(i, &access) ||
|
||||
result->AddFileAccessPermission(access)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidFileAccessValue, base::IntToString(i));
|
||||
return NULL;
|
||||
}
|
||||
@ -2596,7 +2596,7 @@ FileBrowserHandler* Extension::LoadFileBrowserHandler(
|
||||
for (size_t i = 0; i < list_value->GetSize(); ++i) {
|
||||
std::string filter;
|
||||
if (!list_value->GetString(i, &filter)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidFileFilterValue, base::IntToString(i));
|
||||
return NULL;
|
||||
}
|
||||
@ -2604,7 +2604,7 @@ FileBrowserHandler* Extension::LoadFileBrowserHandler(
|
||||
if (!StartsWithASCII(filter,
|
||||
std::string(chrome::kFileSystemScheme) + ':',
|
||||
true)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidURLPatternError, filter);
|
||||
return NULL;
|
||||
}
|
||||
@ -2613,7 +2613,7 @@ FileBrowserHandler* Extension::LoadFileBrowserHandler(
|
||||
filter.replace(0, 11, "chrome-extension://*/");
|
||||
URLPattern pattern(URLPattern::SCHEME_EXTENSION);
|
||||
if (pattern.Parse(filter) != URLPattern::PARSE_SUCCESS) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidURLPatternError, filter);
|
||||
return NULL;
|
||||
}
|
||||
@ -2622,7 +2622,7 @@ FileBrowserHandler* Extension::LoadFileBrowserHandler(
|
||||
(path.compare(0, 3, "/*.") == 0 &&
|
||||
path.find_first_of('*', 3) == std::string::npos);
|
||||
if (!allowed) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidURLPatternError, filter);
|
||||
return NULL;
|
||||
}
|
||||
@ -2687,7 +2687,7 @@ bool Extension::LoadChromeURLOverrides(string16* error) {
|
||||
std::string url = base::StringPrintf(kOverrideExtentUrlPatternFormat,
|
||||
page.c_str());
|
||||
if (pattern.Parse(url) != URLPattern::PARSE_SUCCESS) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidURLPatternError, url);
|
||||
return false;
|
||||
}
|
||||
@ -2880,7 +2880,7 @@ bool Extension::LoadAppIsolation(const APIPermissionSet& api_permissions,
|
||||
for (size_t i = 0; i < isolation_list->GetSize(); ++i) {
|
||||
std::string isolation_string;
|
||||
if (!isolation_list->GetString(i, &isolation_string)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidIsolationValue,
|
||||
base::UintToString(i));
|
||||
return false;
|
||||
@ -3434,7 +3434,7 @@ bool Extension::ParsePermissions(const char* key,
|
||||
if (manifest_->HasKey(key)) {
|
||||
ListValue* permissions = NULL;
|
||||
if (!manifest_->GetList(key, &permissions)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidPermissions, "");
|
||||
return false;
|
||||
}
|
||||
@ -3505,7 +3505,7 @@ bool Extension::ParsePermissions(const char* key,
|
||||
URLPattern::ParseResult parse_result = pattern.Parse(permission_str);
|
||||
if (parse_result == URLPattern::PARSE_SUCCESS) {
|
||||
if (!CanSpecifyHostPermission(pattern, *api_permissions)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidPermissionScheme, permission_str);
|
||||
return false;
|
||||
}
|
||||
@ -3729,7 +3729,7 @@ bool Extension::CanExecuteScriptOnPage(const GURL& document_url,
|
||||
}
|
||||
|
||||
if (error) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(errors::kCannotAccessPage,
|
||||
*error = ErrorUtils::FormatErrorMessage(errors::kCannotAccessPage,
|
||||
document_url.spec());
|
||||
}
|
||||
|
||||
@ -3794,7 +3794,7 @@ bool Extension::CanCaptureVisiblePage(const GURL& page_url,
|
||||
return true;
|
||||
|
||||
if (error) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(errors::kCannotAccessPage,
|
||||
*error = ErrorUtils::FormatErrorMessage(errors::kCannotAccessPage,
|
||||
page_url.spec());
|
||||
}
|
||||
return false;
|
||||
@ -4007,7 +4007,7 @@ bool Extension::CheckMinimumChromeVersion(string16* error) const {
|
||||
}
|
||||
|
||||
if (current_version.CompareTo(minimum_version) < 0) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kChromeVersionTooLow,
|
||||
l10n_util::GetStringUTF8(IDS_PRODUCT_NAME),
|
||||
minimum_version_string);
|
||||
|
@ -26,9 +26,9 @@
|
||||
#include "chrome/common/extensions/permissions/api_permission.h"
|
||||
#include "chrome/common/extensions/permissions/api_permission_set.h"
|
||||
#include "chrome/common/extensions/permissions/permission_message.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "chrome/common/extensions/user_script.h"
|
||||
#include "extensions/common/url_pattern.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "ui/base/accelerators/accelerator.h"
|
||||
#include "ui/gfx/size.h"
|
||||
|
@ -1,69 +0,0 @@
|
||||
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
|
||||
#include "base/string_util.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
|
||||
std::string ExtensionErrorUtils::FormatErrorMessage(
|
||||
const std::string& format,
|
||||
const std::string& s1) {
|
||||
std::string ret_val = format;
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
std::string ExtensionErrorUtils::FormatErrorMessage(
|
||||
const std::string& format,
|
||||
const std::string& s1,
|
||||
const std::string& s2) {
|
||||
std::string ret_val = format;
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
std::string ExtensionErrorUtils::FormatErrorMessage(
|
||||
const std::string& format,
|
||||
const std::string& s1,
|
||||
const std::string& s2,
|
||||
const std::string& s3) {
|
||||
std::string ret_val = format;
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2);
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s3);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
string16 ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
const std::string& format,
|
||||
const std::string& s1) {
|
||||
std::string ret_val = format;
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
|
||||
return UTF8ToUTF16(ret_val);
|
||||
}
|
||||
|
||||
string16 ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
const std::string& format,
|
||||
const std::string& s1,
|
||||
const std::string& s2) {
|
||||
std::string ret_val = format;
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2);
|
||||
return UTF8ToUTF16(ret_val);
|
||||
}
|
||||
|
||||
string16 ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
const std::string& format,
|
||||
const std::string& s1,
|
||||
const std::string& s2,
|
||||
const std::string& s3) {
|
||||
std::string ret_val = format;
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2);
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s3);
|
||||
return UTF8ToUTF16(ret_val);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ using extensions::APIPermissionSet;
|
||||
using extensions::Extension;
|
||||
using extensions::PermissionSet;
|
||||
using extensions::SocketPermissionData;
|
||||
using extensions::URLPatternSet;
|
||||
|
||||
ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params()
|
||||
: location(Extension::INVALID),
|
||||
|
@ -11,11 +11,11 @@
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/permissions/permission_set.h"
|
||||
#include "chrome/common/extensions/permissions/socket_permission_data.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "chrome/common/view_type.h"
|
||||
#include "chrome/common/web_apps.h"
|
||||
#include "content/public/common/common_param_traits.h"
|
||||
#include "extensions/common/url_pattern.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "ipc/ipc_message_macros.h"
|
||||
|
||||
@ -135,8 +135,8 @@ struct ExtensionMsg_Loaded_Params {
|
||||
|
||||
// The extension's active permissions.
|
||||
extensions::APIPermissionSet apis;
|
||||
URLPatternSet explicit_hosts;
|
||||
URLPatternSet scriptable_hosts;
|
||||
extensions::URLPatternSet explicit_hosts;
|
||||
extensions::URLPatternSet scriptable_hosts;
|
||||
|
||||
// We keep this separate so that it can be used in logging.
|
||||
std::string id;
|
||||
@ -156,8 +156,8 @@ struct ParamTraits<URLPattern> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<URLPatternSet> {
|
||||
typedef URLPatternSet param_type;
|
||||
struct ParamTraits<extensions::URLPatternSet> {
|
||||
typedef extensions::URLPatternSet param_type;
|
||||
static void Write(Message* m, const param_type& p);
|
||||
static bool Read(const Message* m, PickleIterator* iter, param_type* p);
|
||||
static void Log(const param_type& p, std::string* l);
|
||||
@ -282,15 +282,15 @@ IPC_MESSAGE_CONTROL5(ExtensionMsg_UpdatePermissions,
|
||||
int /* UpdateExtensionPermissionsInfo::REASON */,
|
||||
std::string /* extension_id */,
|
||||
extensions::APIPermissionSet /* permissions */,
|
||||
URLPatternSet /* explicit_hosts */,
|
||||
URLPatternSet /* scriptable_hosts */)
|
||||
extensions::URLPatternSet /* explicit_hosts */,
|
||||
extensions::URLPatternSet /* scriptable_hosts */)
|
||||
|
||||
// Tell the renderer about new tab-specific permissions for an extension.
|
||||
IPC_MESSAGE_CONTROL4(ExtensionMsg_UpdateTabSpecificPermissions,
|
||||
int32 /* page_id (only relevant for the target tab) */,
|
||||
int /* tab_id */,
|
||||
std::string /* extension_id */,
|
||||
URLPatternSet /* hosts */)
|
||||
extensions::URLPatternSet /* hosts */)
|
||||
|
||||
// Tell the renderer to clear tab-specific permissions for some extensions.
|
||||
IPC_MESSAGE_CONTROL2(ExtensionMsg_ClearTabSpecificPermissions,
|
||||
|
@ -113,7 +113,7 @@ const Extension* ExtensionSet::GetHostedAppByURL(
|
||||
}
|
||||
|
||||
const Extension* ExtensionSet::GetHostedAppByOverlappingWebExtent(
|
||||
const URLPatternSet& extent) const {
|
||||
const extensions::URLPatternSet& extent) const {
|
||||
for (ExtensionMap::const_iterator iter = extensions_.begin();
|
||||
iter != extensions_.end(); ++iter) {
|
||||
if (iter->second->web_extent().OverlapsWith(extent))
|
||||
|
@ -114,7 +114,7 @@ class ExtensionSet {
|
||||
// Returns a hosted app that contains any URL that overlaps with the given
|
||||
// extent, if one exists.
|
||||
const extensions::Extension* GetHostedAppByOverlappingWebExtent(
|
||||
const URLPatternSet& extent) const;
|
||||
const extensions::URLPatternSet& extent) const;
|
||||
|
||||
// Returns true if |new_url| is in the extent of the same extension as
|
||||
// |old_url|. Also returns true if neither URL is in an app.
|
||||
|
@ -4,17 +4,16 @@
|
||||
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
|
||||
#include "base/format_macros.h"
|
||||
#include "base/file_path.h"
|
||||
#include "base/file_util.h"
|
||||
#include "base/format_macros.h"
|
||||
#include "base/json/json_file_value_serializer.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/stringprintf.h"
|
||||
#include "base/string_number_conversions.h"
|
||||
#include "base/stringprintf.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "chrome/common/extensions/command.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_file_util.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "chrome/common/extensions/extension_resource.h"
|
||||
@ -23,10 +22,11 @@
|
||||
#include "chrome/common/extensions/permissions/permission_set.h"
|
||||
#include "chrome/common/extensions/permissions/socket_permission.h"
|
||||
#include "chrome/common/url_constants.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "net/base/mime_sniffer.h"
|
||||
#include "skia/ext/image_operations.h"
|
||||
#include "net/base/mock_host_resolver.h"
|
||||
#include "skia/ext/image_operations.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "ui/gfx/codec/png_codec.h"
|
||||
@ -34,10 +34,12 @@
|
||||
using content::SocketPermissionRequest;
|
||||
using extensions::APIPermission;
|
||||
using extensions::APIPermissionSet;
|
||||
using extensions::ErrorUtils;
|
||||
using extensions::Extension;
|
||||
using extensions::Feature;
|
||||
using extensions::PermissionSet;
|
||||
using extensions::SocketPermission;
|
||||
using extensions::URLPatternSet;
|
||||
|
||||
namespace keys = extension_manifest_keys;
|
||||
namespace values = extension_manifest_values;
|
||||
@ -285,7 +287,7 @@ TEST(ExtensionTest, LoadPageActionHelper) {
|
||||
|
||||
// Use both "popup" and "default_popup", expect failure.
|
||||
LoadActionAndExpectError("page_action_popup_and_default_popup.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidPageActionOldAndNewKeys,
|
||||
keys::kPageActionDefaultPopup,
|
||||
keys::kPageActionPopup));
|
||||
@ -472,7 +474,7 @@ TEST(ExtensionTest, SocketPermissions) {
|
||||
Extension::INTERNAL, Extension::NO_FLAGS,
|
||||
&error);
|
||||
EXPECT_TRUE(extension == NULL);
|
||||
ASSERT_EQ(ExtensionErrorUtils::FormatErrorMessage(
|
||||
ASSERT_EQ(ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidPermission, "socket"), error);
|
||||
|
||||
extension = LoadManifest("socket_permissions", "socket2.json");
|
||||
@ -902,7 +904,7 @@ TEST_F(ExtensionScriptAndCaptureVisibleTest, Permissions) {
|
||||
Extension::INTERNAL, Extension::NO_FLAGS,
|
||||
&error);
|
||||
EXPECT_TRUE(extension == NULL);
|
||||
EXPECT_EQ(ExtensionErrorUtils::FormatErrorMessage(
|
||||
EXPECT_EQ(ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidPermissionScheme, "chrome://*/"), error);
|
||||
|
||||
// Having chrome://favicon/* should not give you chrome://*
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "extensions/common/url_pattern.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
|
||||
class URLPattern;
|
||||
@ -36,7 +36,7 @@ class FileBrowserHandler {
|
||||
void set_title(const std::string& title) { title_ = title; }
|
||||
|
||||
// File schema URL patterns.
|
||||
const URLPatternSet& file_url_patterns() const {
|
||||
const extensions::URLPatternSet& file_url_patterns() const {
|
||||
return url_set_;
|
||||
}
|
||||
void AddPattern(const URLPattern& pattern);
|
||||
@ -75,7 +75,7 @@ class FileBrowserHandler {
|
||||
unsigned int file_access_permission_flags_;
|
||||
|
||||
// A list of file filters.
|
||||
URLPatternSet url_set_;
|
||||
extensions::URLPatternSet url_set_;
|
||||
};
|
||||
|
||||
#endif // CHROME_COMMON_EXTENSIONS_FILE_BROWSER_HANDLER_H_
|
||||
|
@ -11,8 +11,8 @@
|
||||
#include "base/stringprintf.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/features/simple_feature_provider.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
namespace errors = extension_manifest_errors;
|
||||
namespace keys = extension_manifest_keys;
|
||||
|
@ -176,7 +176,7 @@ void ExtensionManifestTest::LoadAndExpectError(
|
||||
Manifest(manifest_name), expected_error, location, flags);
|
||||
}
|
||||
|
||||
void ExtensionManifestTest::AddPattern(URLPatternSet* extent,
|
||||
void ExtensionManifestTest::AddPattern(extensions::URLPatternSet* extent,
|
||||
const std::string& pattern) {
|
||||
int schemes = URLPattern::SCHEME_ALL;
|
||||
extent->AddPattern(URLPattern(schemes, pattern));
|
||||
|
@ -104,7 +104,8 @@ class ExtensionManifestTest : public testing::Test {
|
||||
extensions::Extension::INTERNAL,
|
||||
int flags = extensions::Extension::NO_FLAGS);
|
||||
|
||||
void AddPattern(URLPatternSet* extent, const std::string& pattern);
|
||||
void AddPattern(extensions::URLPatternSet* extent,
|
||||
const std::string& pattern);
|
||||
|
||||
// used to differentiate between calls to LoadAndExpectError,
|
||||
// LoadAndExpectWarning and LoadAndExpectSuccess via function RunTestcases.
|
||||
|
@ -9,10 +9,10 @@
|
||||
#include "base/values.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "chrome/common/extensions/features/feature.h"
|
||||
#include "chrome/common/extensions/features/simple_feature_provider.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace errors = extension_manifest_errors;
|
||||
|
@ -3,11 +3,11 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/common/extensions/extension_builder.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_icon_set.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
|
||||
#include "chrome/common/extensions/value_builder.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace errors = extension_manifest_errors;
|
||||
@ -93,7 +93,7 @@ TEST_F(ExtensionManifestTest, BrowserActionManifestIcons_InvalidDefaultIcon) {
|
||||
.Set("38", "icon38.png")))
|
||||
.Build();
|
||||
|
||||
string16 error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
string16 error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidIconPath, "19");
|
||||
LoadAndExpectError(Manifest(manifest_value.get(), "Invalid default icon"),
|
||||
errors::kInvalidIconPath);
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
#include "base/string_number_conversions.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace errors = extension_manifest_errors;
|
||||
@ -16,7 +16,7 @@ TEST_F(ExtensionManifestTest, ContentScriptMatchPattern) {
|
||||
Testcase testcases[] = {
|
||||
// chrome:// urls are not allowed.
|
||||
Testcase("content_script_chrome_url_invalid.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
extensions::ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidMatch,
|
||||
base::IntToString(0),
|
||||
base::IntToString(0),
|
||||
@ -25,10 +25,10 @@ TEST_F(ExtensionManifestTest, ContentScriptMatchPattern) {
|
||||
|
||||
// Match paterns must be strings.
|
||||
Testcase("content_script_match_pattern_not_string.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatch,
|
||||
base::IntToString(0),
|
||||
base::IntToString(0),
|
||||
errors::kExpectString))
|
||||
extensions::ErrorUtils::FormatErrorMessage(errors::kInvalidMatch,
|
||||
base::IntToString(0),
|
||||
base::IntToString(0),
|
||||
errors::kExpectString))
|
||||
};
|
||||
RunTestcases(testcases, arraysize(testcases),
|
||||
EXPECT_TYPE_ERROR);
|
||||
|
@ -6,19 +6,21 @@
|
||||
|
||||
#include "base/string_number_conversions.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "chrome/common/extensions/file_browser_handler.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
using extensions::ErrorUtils;
|
||||
using extensions::Extension;
|
||||
using extensions::URLPatternSet;
|
||||
|
||||
namespace errors = extension_manifest_errors;
|
||||
|
||||
TEST_F(ExtensionManifestTest, FileBrowserHandlers) {
|
||||
Testcase testcases[] = {
|
||||
Testcase("filebrowser_invalid_access_permission.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidFileAccessValue, base::IntToString(1))),
|
||||
Testcase("filebrowser_invalid_access_permission_list.json",
|
||||
errors::kInvalidFileAccessList),
|
||||
@ -35,10 +37,10 @@ TEST_F(ExtensionManifestTest, FileBrowserHandlers) {
|
||||
Testcase("filebrowser_invalid_file_filters_1.json",
|
||||
errors::kInvalidFileFiltersList),
|
||||
Testcase("filebrowser_invalid_file_filters_2.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidFileFilterValue, base::IntToString(0))),
|
||||
Testcase("filebrowser_invalid_file_filters_url.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidURLPatternError, "http:*.html"))
|
||||
};
|
||||
RunTestcases(testcases, arraysize(testcases),
|
||||
|
@ -7,12 +7,14 @@
|
||||
#include "base/command_line.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace errors = extension_manifest_errors;
|
||||
|
||||
using extensions::ErrorUtils;
|
||||
|
||||
TEST_F(ExtensionManifestTest, AppLaunchContainer) {
|
||||
scoped_refptr<extensions::Extension> extension;
|
||||
|
||||
@ -40,19 +42,19 @@ TEST_F(ExtensionManifestTest, AppLaunchContainer) {
|
||||
Testcase("launch_container_without_launch_url.json",
|
||||
errors::kLaunchURLRequired),
|
||||
Testcase("launch_width_invalid.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidLaunchValueContainer,
|
||||
keys::kLaunchWidth)),
|
||||
Testcase("launch_width_negative.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidLaunchValue,
|
||||
keys::kLaunchWidth)),
|
||||
Testcase("launch_height_invalid.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidLaunchValueContainer,
|
||||
keys::kLaunchHeight)),
|
||||
Testcase("launch_height_negative.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidLaunchValue,
|
||||
keys::kLaunchHeight))
|
||||
};
|
||||
@ -67,31 +69,31 @@ TEST_F(ExtensionManifestTest, AppLaunchURL) {
|
||||
Testcase("launch_path_and_extent.json",
|
||||
errors::kLaunchPathAndExtentAreExclusive),
|
||||
Testcase("launch_path_invalid_type.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidLaunchValue,
|
||||
keys::kLaunchLocalPath)),
|
||||
Testcase("launch_path_invalid_value.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidLaunchValue,
|
||||
keys::kLaunchLocalPath)),
|
||||
Testcase("launch_path_invalid_localized.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidLaunchValue,
|
||||
keys::kLaunchLocalPath)),
|
||||
Testcase("launch_url_invalid_type_1.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidLaunchValue,
|
||||
keys::kLaunchWebURL)),
|
||||
Testcase("launch_url_invalid_type_2.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidLaunchValue,
|
||||
keys::kLaunchWebURL)),
|
||||
Testcase("launch_url_invalid_type_3.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidLaunchValue,
|
||||
keys::kLaunchWebURL)),
|
||||
Testcase("launch_url_invalid_localized.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidLaunchValue,
|
||||
keys::kLaunchWebURL))
|
||||
};
|
||||
@ -108,7 +110,7 @@ TEST_F(ExtensionManifestTest, AppLaunchURL) {
|
||||
extension->GetFullLaunchURL().spec());
|
||||
|
||||
LoadAndExpectError("launch_web_url_relative.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidLaunchValue,
|
||||
keys::kLaunchWebURL));
|
||||
|
||||
|
@ -4,37 +4,39 @@
|
||||
|
||||
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
|
||||
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace errors = extension_manifest_errors;
|
||||
|
||||
using extensions::ErrorUtils;
|
||||
|
||||
TEST_F(ExtensionManifestTest, RequirementsInvalid) {
|
||||
Testcase testcases[] = {
|
||||
Testcase("requirements_invalid_requirements.json",
|
||||
errors::kInvalidRequirements),
|
||||
Testcase("requirements_invalid_keys.json", errors::kInvalidRequirements),
|
||||
Testcase("requirements_invalid_3d.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidRequirement, "3D")),
|
||||
Testcase("requirements_invalid_3d_features.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidRequirement, "3D")),
|
||||
Testcase("requirements_invalid_3d_features_value.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidRequirement, "3D")),
|
||||
Testcase("requirements_invalid_3d_no_features.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidRequirement, "3D")),
|
||||
Testcase("requirements_invalid_plugins.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidRequirement, "plugins")),
|
||||
Testcase("requirements_invalid_plugins_key.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidRequirement, "plugins")),
|
||||
Testcase("requirements_invalid_plugins_value.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidRequirement, "plugins"))
|
||||
};
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
TEST_F(ExtensionManifestTest, ValidApp) {
|
||||
scoped_refptr<extensions::Extension> extension(
|
||||
LoadAndExpectSuccess("valid_app.json"));
|
||||
URLPatternSet expected_patterns;
|
||||
extensions::URLPatternSet expected_patterns;
|
||||
AddPattern(&expected_patterns, "http://www.google.com/mail/*");
|
||||
AddPattern(&expected_patterns, "http://www.google.com/foobar/*");
|
||||
EXPECT_EQ(expected_patterns, extension->web_extent());
|
||||
|
@ -6,11 +6,12 @@
|
||||
|
||||
#include "base/string_number_conversions.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webkit/glue/web_intent_service_data.h"
|
||||
|
||||
using extensions::ErrorUtils;
|
||||
using extensions::Extension;
|
||||
|
||||
namespace errors = extension_manifest_errors;
|
||||
@ -214,28 +215,28 @@ TEST_F(ExtensionManifestTest, AppWebUrls) {
|
||||
Testcase testcases[] = {
|
||||
Testcase("web_urls_wrong_type.json", errors::kInvalidWebURLs),
|
||||
Testcase("web_urls_invalid_1.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidWebURL,
|
||||
base::IntToString(0),
|
||||
errors::kExpectString)),
|
||||
Testcase("web_urls_invalid_2.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidWebURL,
|
||||
base::IntToString(0),
|
||||
URLPattern::GetParseResultString(
|
||||
URLPattern::PARSE_ERROR_MISSING_SCHEME_SEPARATOR))),
|
||||
Testcase("web_urls_invalid_3.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidWebURL,
|
||||
base::IntToString(0),
|
||||
errors::kNoWildCardsInPaths)),
|
||||
Testcase("web_urls_invalid_4.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidWebURL,
|
||||
base::IntToString(0),
|
||||
errors::kCannotClaimAllURLsInExtent)),
|
||||
Testcase("web_urls_invalid_5.json",
|
||||
ExtensionErrorUtils::FormatErrorMessage(
|
||||
ErrorUtils::FormatErrorMessage(
|
||||
errors::kInvalidWebURL,
|
||||
base::IntToString(1),
|
||||
errors::kCannotClaimAllHostsInExtent))
|
||||
|
@ -12,8 +12,8 @@
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/features/feature.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace errors = extension_manifest_errors;
|
||||
|
@ -8,9 +8,9 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/stringprintf.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/matcher/url_matcher_constants.h"
|
||||
#include "chrome/common/extensions/matcher/url_matcher_helpers.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "third_party/re2/re2/re2.h"
|
||||
|
||||
namespace helpers = extensions::url_matcher_helpers;
|
||||
@ -134,7 +134,7 @@ URLMatcherFactory::CreateFromURLFilterDictionary(
|
||||
return scoped_refptr<URLMatcherConditionSet>(NULL);
|
||||
} else {
|
||||
// Handle unknown attributes.
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(
|
||||
*error = ErrorUtils::FormatErrorMessage(
|
||||
kUnknownURLFilterAttribute,
|
||||
condition_attribute_name);
|
||||
return scoped_refptr<URLMatcherConditionSet>(NULL);
|
||||
@ -171,7 +171,7 @@ URLMatcherCondition URLMatcherFactory::CreateURLMatcherCondition(
|
||||
std::string* error) {
|
||||
std::string str_value;
|
||||
if (!value->GetAsString(&str_value)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(kAttributeExpectedString,
|
||||
*error = ErrorUtils::FormatErrorMessage(kAttributeExpectedString,
|
||||
condition_attribute_name);
|
||||
return URLMatcherCondition();
|
||||
}
|
||||
@ -179,7 +179,7 @@ URLMatcherCondition URLMatcherFactory::CreateURLMatcherCondition(
|
||||
if (condition_attribute_name == keys::kURLMatchesKey) {
|
||||
re2::RE2 regex(str_value);
|
||||
if (!regex.ok()) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(kUnparseableRegexString,
|
||||
*error = ErrorUtils::FormatErrorMessage(kUnparseableRegexString,
|
||||
str_value,
|
||||
regex.error());
|
||||
return URLMatcherCondition();
|
||||
@ -195,7 +195,7 @@ scoped_ptr<URLMatcherSchemeFilter> URLMatcherFactory::CreateURLMatcherScheme(
|
||||
std::string* error) {
|
||||
std::vector<std::string> schemas;
|
||||
if (!helpers::GetAsStringVector(value, &schemas)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(kVectorOfStringsExpected,
|
||||
*error = ErrorUtils::FormatErrorMessage(kVectorOfStringsExpected,
|
||||
keys::kSchemesKey);
|
||||
return scoped_ptr<URLMatcherSchemeFilter>(NULL);
|
||||
}
|
||||
|
@ -16,9 +16,9 @@
|
||||
#include "base/stringprintf.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_l10n_util.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
|
||||
namespace errors = extension_manifest_errors;
|
||||
@ -118,7 +118,7 @@ bool MessageBundle::AppendReservedMessagesForLocale(
|
||||
SubstitutionMap::iterator it = append_messages.begin();
|
||||
for (; it != append_messages.end(); ++it) {
|
||||
if (ContainsKey(dictionary_, it->first)) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(
|
||||
*error = ErrorUtils::FormatErrorMessage(
|
||||
errors::kReservedMessageFound, it->first);
|
||||
return false;
|
||||
} else {
|
||||
|
@ -13,9 +13,9 @@
|
||||
#include "base/string_util.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_l10n_util.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace errors = extension_manifest_errors;
|
||||
@ -265,7 +265,7 @@ TEST_F(MessageBundleTest, ReservedMessagesOverrideDeveloperMessages) {
|
||||
std::string error = CreateMessageBundle();
|
||||
|
||||
EXPECT_TRUE(handler_.get() == NULL);
|
||||
std::string expected_error = ExtensionErrorUtils::FormatErrorMessage(
|
||||
std::string expected_error = ErrorUtils::FormatErrorMessage(
|
||||
errors::kReservedMessageFound, MessageBundle::kUILocaleKey);
|
||||
EXPECT_EQ(expected_error, error);
|
||||
}
|
||||
|
@ -7,9 +7,9 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/string_number_conversions.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "chrome/common/extensions/permissions/permissions_info.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
namespace errors = extension_manifest_errors;
|
||||
|
||||
@ -19,6 +19,7 @@ using extensions::PermissionsInfo;
|
||||
using extensions::APIPermission;
|
||||
using extensions::APIPermissionInfo;
|
||||
using extensions::APIPermissionSet;
|
||||
using extensions::ErrorUtils;
|
||||
|
||||
bool CreateAPIPermission(
|
||||
const std::string& permission_str,
|
||||
@ -34,7 +35,7 @@ bool CreateAPIPermission(
|
||||
permission_info->CreateAPIPermission());
|
||||
if (!permission->FromValue(permission_value)) {
|
||||
if (error) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidPermission, permission_info->name());
|
||||
return false;
|
||||
}
|
||||
@ -62,7 +63,7 @@ bool ParseChildPermissions(const std::string& base_name,
|
||||
const ListValue* permissions;
|
||||
if (!permission_value->GetAsList(&permissions)) {
|
||||
if (error) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidPermission, base_name);
|
||||
return false;
|
||||
}
|
||||
@ -77,7 +78,7 @@ bool ParseChildPermissions(const std::string& base_name,
|
||||
if (!permissions->GetString(i, &permission_str)) {
|
||||
// permission should be a string
|
||||
if (error) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidPermission,
|
||||
base_name + '.' + base::IntToString(i));
|
||||
return false;
|
||||
@ -293,7 +294,7 @@ bool APIPermissionSet::ParseFromJSON(
|
||||
// permission should be a string or a single key dict.
|
||||
if (!permissions->GetDictionary(i, &dict) || dict->size() != 1) {
|
||||
if (error) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
||||
*error = ErrorUtils::FormatErrorMessageUTF16(
|
||||
errors::kInvalidPermission, base::IntToString(i));
|
||||
return false;
|
||||
}
|
||||
|
@ -10,13 +10,15 @@
|
||||
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/permissions/permissions_info.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "content/public/common/url_constants.h"
|
||||
#include "extensions/common/url_pattern.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
#include "grit/generated_resources.h"
|
||||
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
|
||||
using extensions::URLPatternSet;
|
||||
|
||||
namespace {
|
||||
|
||||
// Helper for GetDistinctHosts(): com > net > org > everything else.
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "chrome/common/extensions/permissions/api_permission.h"
|
||||
#include "chrome/common/extensions/permissions/api_permission_set.h"
|
||||
#include "chrome/common/extensions/permissions/permission_message.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
|
@ -10,12 +10,12 @@
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "chrome/common/extensions/features/feature.h"
|
||||
#include "chrome/common/extensions/permissions/permission_set.h"
|
||||
#include "chrome/common/extensions/permissions/permissions_info.h"
|
||||
#include "chrome/common/extensions/permissions/socket_permission.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
using extensions::Extension;
|
||||
@ -23,6 +23,9 @@ using extensions::Extension;
|
||||
namespace errors = extension_manifest_errors;
|
||||
namespace keys = extension_manifest_keys;
|
||||
namespace values = extension_manifest_values;
|
||||
|
||||
namespace extensions {
|
||||
|
||||
namespace {
|
||||
|
||||
scoped_refptr<Extension> LoadManifest(const std::string& dir,
|
||||
@ -76,7 +79,6 @@ bool Contains(const std::vector<string16>& warnings,
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace extensions {
|
||||
|
||||
class PermissionsTest : public testing::Test {
|
||||
};
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
#include "base/file_path.h"
|
||||
#include "base/string_piece.h"
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "extensions/common/url_pattern.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
|
||||
class Pickle;
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "chrome/common/extensions/extension_manifest_constants.h"
|
||||
#include "chrome/common/extensions/extension_messages.h"
|
||||
#include "chrome/renderer/extensions/dispatcher.h"
|
||||
@ -15,6 +14,7 @@
|
||||
#include "chrome/renderer/extensions/user_script_slave.h"
|
||||
#include "content/public/renderer/render_view.h"
|
||||
#include "content/public/renderer/v8_value_converter.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
|
||||
@ -183,7 +183,7 @@ void UserScriptScheduler::ExecuteCodeImpl(
|
||||
if (child_frame->parent()) {
|
||||
continue;
|
||||
} else {
|
||||
error = ExtensionErrorUtils::FormatErrorMessage(
|
||||
error = ErrorUtils::FormatErrorMessage(
|
||||
extension_manifest_errors::kCannotAccessPage,
|
||||
child_frame->document().url().spec());
|
||||
break;
|
||||
|
@ -1,4 +1,5 @@
|
||||
include_rules = [
|
||||
"+base",
|
||||
"+googleurl"
|
||||
"+googleurl",
|
||||
"+testing"
|
||||
]
|
||||
|
66
extensions/common/error_utils.cc
Normal file
66
extensions/common/error_utils.cc
Normal file
@ -0,0 +1,66 @@
|
||||
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "extensions/common/error_utils.h"
|
||||
|
||||
#include "base/string_util.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
std::string ErrorUtils::FormatErrorMessage(const std::string& format,
|
||||
const std::string& s1) {
|
||||
std::string ret_val = format;
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
std::string ErrorUtils::FormatErrorMessage(const std::string& format,
|
||||
const std::string& s1,
|
||||
const std::string& s2) {
|
||||
std::string ret_val = format;
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
std::string ErrorUtils::FormatErrorMessage(const std::string& format,
|
||||
const std::string& s1,
|
||||
const std::string& s2,
|
||||
const std::string& s3) {
|
||||
std::string ret_val = format;
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2);
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s3);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
string16 ErrorUtils::FormatErrorMessageUTF16(const std::string& format,
|
||||
const std::string& s1) {
|
||||
std::string ret_val = format;
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
|
||||
return UTF8ToUTF16(ret_val);
|
||||
}
|
||||
|
||||
string16 ErrorUtils::FormatErrorMessageUTF16(const std::string& format,
|
||||
const std::string& s1,
|
||||
const std::string& s2) {
|
||||
std::string ret_val = format;
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2);
|
||||
return UTF8ToUTF16(ret_val);
|
||||
}
|
||||
|
||||
string16 ErrorUtils::FormatErrorMessageUTF16(const std::string& format,
|
||||
const std::string& s1,
|
||||
const std::string& s2,
|
||||
const std::string& s3) {
|
||||
std::string ret_val = format;
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1);
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2);
|
||||
ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s3);
|
||||
return UTF8ToUTF16(ret_val);
|
||||
}
|
||||
|
||||
} // namespace
|
@ -2,14 +2,16 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_ERROR_UTILS_H_
|
||||
#define CHROME_COMMON_EXTENSIONS_EXTENSION_ERROR_UTILS_H_
|
||||
#ifndef EXTENSIONS_COMMON_ERROR_UTILS_H_
|
||||
#define EXTENSIONS_COMMON_ERROR_UTILS_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/string16.h"
|
||||
|
||||
class ExtensionErrorUtils {
|
||||
namespace extensions {
|
||||
|
||||
class ErrorUtils {
|
||||
public:
|
||||
// Creates an error messages from a pattern.
|
||||
static std::string FormatErrorMessage(const std::string& format,
|
||||
@ -37,4 +39,6 @@ class ExtensionErrorUtils {
|
||||
const std::string& s3);
|
||||
};
|
||||
|
||||
#endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ERROR_UTILS_H_
|
||||
} // namespace extensions
|
||||
|
||||
#endif // EXTENSIONS_COMMON_ERROR_UTILS_H_
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/common/extensions/url_pattern_set.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
@ -10,11 +10,13 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/linked_ptr.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/common/extensions/extension_error_utils.h"
|
||||
#include "content/public/common/url_constants.h"
|
||||
#include "extensions/common/error_utils.h"
|
||||
#include "extensions/common/url_pattern.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
namespace {
|
||||
|
||||
const char kInvalidURLPatternError[] = "Invalid url pattern '*'";
|
||||
@ -184,8 +186,8 @@ bool URLPatternSet::Populate(const std::vector<std::string>& patterns,
|
||||
URLPattern pattern(valid_schemes);
|
||||
if (pattern.Parse(patterns[i]) != URLPattern::PARSE_SUCCESS) {
|
||||
if (error) {
|
||||
*error = ExtensionErrorUtils::FormatErrorMessage(
|
||||
kInvalidURLPatternError, patterns[i]);
|
||||
*error = ErrorUtils::FormatErrorMessage(kInvalidURLPatternError,
|
||||
patterns[i]);
|
||||
} else {
|
||||
LOG(ERROR) << "Invalid url pattern: " << patterns[i];
|
||||
}
|
||||
@ -213,3 +215,5 @@ bool URLPatternSet::Populate(const base::ListValue& value,
|
||||
}
|
||||
return Populate(patterns, valid_schemes, allow_file_access, error);
|
||||
}
|
||||
|
||||
} // namespace extensions
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CHROME_COMMON_EXTENSIONS_URL_PATTERN_SET_H_
|
||||
#define CHROME_COMMON_EXTENSIONS_URL_PATTERN_SET_H_
|
||||
#ifndef EXTENSIONS_COMMMON_URL_PATTERN_SET_H_
|
||||
#define EXTENSIONS_COMMMON_URL_PATTERN_SET_H_
|
||||
|
||||
#include <set>
|
||||
|
||||
@ -17,6 +17,8 @@ class ListValue;
|
||||
class Value;
|
||||
}
|
||||
|
||||
namespace extensions {
|
||||
|
||||
// Represents the set of URLs an extension uses for web content.
|
||||
class URLPatternSet {
|
||||
public:
|
||||
@ -94,4 +96,6 @@ class URLPatternSet {
|
||||
std::set<URLPattern> patterns_;
|
||||
};
|
||||
|
||||
#endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_SET_H_
|
||||
} // namespace extensions
|
||||
|
||||
#endif // EXTENSIONS_COMMMON_URL_PATTERN_SET_H_
|
6
chrome/common/extensions/url_pattern_set_unittest.cc → extensions/common/url_pattern_set_unittest.cc
6
chrome/common/extensions/url_pattern_set_unittest.cc → extensions/common/url_pattern_set_unittest.cc
@ -2,12 +2,14 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/common/extensions/extension.h"
|
||||
#include "extensions/common/url_pattern_set.h"
|
||||
|
||||
#include "base/values.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
namespace {
|
||||
|
||||
void AddPattern(URLPatternSet* set, const std::string& pattern) {
|
||||
@ -390,3 +392,5 @@ TEST(URLPatternSetTest, NwayUnion) {
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace extensions
|
Reference in New Issue
Block a user