Skip to content

Commit

Permalink
Establish /extensions directory and move URLPattern there.
Browse files Browse the repository at this point in the history
This doesn't create an extensions gyp target, or a module with a public API.
It does set of DEPS rules and seems like it will make it easier for people to
write correctly layered code today, while we are in transition.

BUG=159265
TBR=ben@chromium.org

Review URL: https://codereview.chromium.org/11410015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167454 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
aa@chromium.org committed Nov 13, 2012
1 parent bf4d4ef commit 885c0e9
Show file tree
Hide file tree
Showing 105 changed files with 276 additions and 175 deletions.
1 change: 1 addition & 0 deletions chrome/browser/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ include_rules = [
"+content/components",
"+content/public/browser",
"+device",
"+extensions/common",
"+google/cacheinvalidation", # Sync invalidation API protobuf files.
"+google_apis",
"+google_update",
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/automation/testing_automation_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,9 @@
#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.h"
#include "chrome/common/extensions/url_pattern_set.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_child_process_host_iterator.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/favicon_status.h"
Expand All @@ -149,6 +147,7 @@
#include "content/public/common/common_param_traits.h"
#include "content/public/common/geoposition.h"
#include "content/public/common/ssl_status.h"
#include "extensions/common/url_pattern.h"
#include "net/cookies/cookie_store.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "ui/base/events/event_constants.h"
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/browser_process_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/common/pepper_plugin_info.h"
#include "extensions/common/constants.h"
#include "net/socket/client_socket_pool_manager.h"
#include "net/url_request/url_request_context_getter.h"
#include "ui/base/l10n/l10n_util.h"
Expand Down Expand Up @@ -161,7 +162,7 @@ BrowserProcessImpl::BrowserProcessImpl(
net_log_.reset(new ChromeNetLog);

ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme(
chrome::kExtensionScheme);
extensions::kExtensionScheme);
ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme(
chrome::kExtensionResourceScheme);

Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/browsing_data/browsing_data_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/child_process_security_policy.h"
#include "extensions/common/constants.h"
#include "googleurl/src/gurl.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"

Expand Down Expand Up @@ -44,7 +45,7 @@ bool BrowsingDataHelper::HasWebScheme(const GURL& origin) {

// Static
bool BrowsingDataHelper::IsExtensionScheme(const std::string& scheme) {
return scheme == chrome::kExtensionScheme;
return scheme == extensions::kExtensionScheme;
}

// Static
Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/browsing_data/browsing_data_helper_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "chrome/browser/extensions/mock_extension_special_storage_policy.h"
#include "chrome/common/url_constants.h"
#include "content/public/common/url_constants.h"
#include "extensions/common/constants.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
Expand Down Expand Up @@ -73,7 +74,7 @@ TEST_F(BrowsingDataHelperTest, WebSafeSchemesAreWebSafe) {
}

TEST_F(BrowsingDataHelperTest, ChromeSchemesAreNotWebSafe) {
EXPECT_FALSE(IsWebScheme(chrome::kExtensionScheme));
EXPECT_FALSE(IsWebScheme(extensions::kExtensionScheme));
EXPECT_FALSE(IsWebScheme(chrome::kAboutScheme));
EXPECT_FALSE(IsWebScheme(chrome::kChromeDevToolsScheme));
EXPECT_FALSE(IsWebScheme(chrome::kChromeInternalScheme));
Expand All @@ -97,7 +98,7 @@ TEST_F(BrowsingDataHelperTest, WebSafeSchemesAreNotExtensions) {
}

TEST_F(BrowsingDataHelperTest, ChromeSchemesAreNotAllExtension) {
EXPECT_TRUE(IsExtensionScheme(chrome::kExtensionScheme));
EXPECT_TRUE(IsExtensionScheme(extensions::kExtensionScheme));

EXPECT_FALSE(IsExtensionScheme(chrome::kAboutScheme));
EXPECT_FALSE(IsExtensionScheme(chrome::kChromeDevToolsScheme));
Expand Down
19 changes: 11 additions & 8 deletions chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
#include "content/public/browser/web_contents_view.h"
#include "content/public/common/child_process_host.h"
#include "content/public/common/content_descriptors.h"
#include "extensions/common/constants.h"
#include "grit/generated_resources.h"
#include "grit/ui_resources.h"
#include "net/base/escape.h"
Expand Down Expand Up @@ -306,7 +307,7 @@ RenderProcessHostPrivilege GetPrivilegeRequiredByUrl(
if (!url.is_valid())
return PRIV_NORMAL;

if (url.SchemeIs(chrome::kExtensionScheme)) {
if (url.SchemeIs(extensions::kExtensionScheme)) {
const Extension* extension =
service->extensions()->GetByID(url.host());
if (extension && extension->is_storage_isolated())
Expand Down Expand Up @@ -641,7 +642,7 @@ bool ChromeContentBrowserClient::ShouldUseProcessPerSite(
// Non-extension URLs should generally use process-per-site-instance.
// Because we expect to use the effective URL, URLs for hosted apps (apart
// from bookmark apps) should have an extension scheme by now.
if (!effective_url.SchemeIs(chrome::kExtensionScheme))
if (!effective_url.SchemeIs(extensions::kExtensionScheme))
return false;

Profile* profile = Profile::FromBrowserContext(browser_context);
Expand Down Expand Up @@ -828,16 +829,16 @@ bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation(
// Always choose a new process when navigating to extension URLs. The
// process grouping logic will combine all of a given extension's pages
// into the same process.
if (new_url.SchemeIs(chrome::kExtensionScheme))
if (new_url.SchemeIs(extensions::kExtensionScheme))
return true;

return false;
}

// Also, we must switch if one is an extension and the other is not the exact
// same extension.
if (current_url.SchemeIs(chrome::kExtensionScheme) ||
new_url.SchemeIs(chrome::kExtensionScheme)) {
if (current_url.SchemeIs(extensions::kExtensionScheme) ||
new_url.SchemeIs(extensions::kExtensionScheme)) {
if (current_url.GetOrigin() != new_url.GetOrigin())
return true;
}
Expand Down Expand Up @@ -1188,7 +1189,7 @@ net::URLRequestContext*
ChromeContentBrowserClient::OverrideRequestContextForURL(
const GURL& url, content::ResourceContext* context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (url.SchemeIs(chrome::kExtensionScheme)) {
if (url.SchemeIs(extensions::kExtensionScheme)) {
ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
return io_data->extensions_request_context();
}
Expand Down Expand Up @@ -1637,7 +1638,7 @@ void ChromeContentBrowserClient::OverrideWebkitPrefs(
// the correct scheme. Without this check, chrome-guest:// schemes used by
// webview tags as well as hosts that happen to match the id of an
// installed extension would get the wrong preferences.
if (url.SchemeIs(chrome::kExtensionScheme)) {
if (url.SchemeIs(extensions::kExtensionScheme)) {
extension_webkit_preferences::SetPreferences(
extension, view_type, web_prefs);
}
Expand Down Expand Up @@ -1765,8 +1766,10 @@ bool ChromeContentBrowserClient::AllowPepperSocketAPI(
return false;

std::string host = url.host();
if (url.SchemeIs(kExtensionScheme) && allowed_socket_origins_.count(host))
if (url.SchemeIs(extensions::kExtensionScheme) &&
allowed_socket_origins_.count(host)) {
return true;
}

Profile* profile = Profile::FromBrowserContext(browser_context);
const Extension* extension = NULL;
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/enrollment_dialog_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/common/url_constants.h"
#include "content/public/common/page_transition_types.h"
#include "extensions/common/constants.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
Expand Down Expand Up @@ -230,7 +230,7 @@ void DialogEnrollmentDelegate::Enroll(const std::vector<std::string>& uri_list,
for (std::vector<std::string>::const_iterator iter = uri_list.begin();
iter != uri_list.end(); ++iter) {
GURL uri(*iter);
if (uri.IsStandard() || uri.scheme() == chrome::kExtensionScheme) {
if (uri.IsStandard() || uri.scheme() == extensions::kExtensionScheme) {
// If this is a "standard" scheme, like http, ftp, etc., then open that in
// the enrollment dialog.
EnrollmentDialogView::ShowDialog(owning_window_,
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/web_socket_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
#include "chrome/browser/chromeos/web_socket_proxy_helper.h"
#include "chrome/browser/internal_auth.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/common/url_constants.h"
#include "extensions/common/constants.h"
#include "googleurl/src/gurl.h"
#include "googleurl/src/url_parse.h"
#include "net/base/address_list.h"
Expand Down Expand Up @@ -155,7 +155,7 @@ std::string FetchAsciiSnippet(uint8* begin, uint8* end, AsciiFilter filter) {

std::string FetchExtensionIdFromOrigin(const std::string &origin) {
GURL url(origin);
if (url.SchemeIs(chrome::kExtensionScheme))
if (url.SchemeIs(extensions::kExtensionScheme))
return url.host();
else
return std::string();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#include "chrome/common/content_settings_pattern.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_set.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "extensions/common/constants.h"

using extensions::UnloadedExtensionInfo;

Expand Down Expand Up @@ -104,7 +104,7 @@ void InternalExtensionProvider::SetContentSettingForExtension(
ContentSetting setting) {
scoped_ptr<ContentSettingsPattern::BuilderInterface> pattern_builder(
ContentSettingsPattern::CreateBuilder(false));
pattern_builder->WithScheme(chrome::kExtensionScheme);
pattern_builder->WithScheme(extensions::kExtensionScheme);
pattern_builder->WithHost(extension->id());
pattern_builder->WithPathWildcard();

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/content_settings/cookie_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/content_settings_pattern.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/user_metrics.h"
#include "extensions/common/constants.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_errors.h"
#include "net/base/static_cookie_policy.h"
Expand Down Expand Up @@ -192,7 +192,7 @@ ContentSetting CookieSettings::GetCookieSetting(
if (info.primary_pattern.MatchesAllHosts() &&
info.secondary_pattern.MatchesAllHosts() &&
ShouldBlockThirdPartyCookies() &&
!first_party_url.SchemeIs(chrome::kExtensionScheme)) {
!first_party_url.SchemeIs(extensions::kExtensionScheme)) {
bool not_strict = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kOnlyBlockSettingThirdPartyCookies);
net::StaticCookiePolicy policy(not_strict ?
Expand Down
9 changes: 5 additions & 4 deletions chrome/browser/content_settings/host_content_settings_map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
#include "base/stl_util.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/content_settings/content_settings_custom_extension_provider.h"
#include "chrome/browser/content_settings/content_settings_default_provider.h"
#include "chrome/browser/content_settings/content_settings_details.h"
#include "chrome/browser/content_settings/content_settings_custom_extension_provider.h"
#include "chrome/browser/content_settings/content_settings_observable_provider.h"
#include "chrome/browser/content_settings/content_settings_internal_extension_provider.h"
#include "chrome/browser/content_settings/content_settings_observable_provider.h"
#include "chrome/browser/content_settings/content_settings_policy_provider.h"
#include "chrome/browser/content_settings/content_settings_pref_provider.h"
#include "chrome/browser/content_settings/content_settings_provider.h"
Expand All @@ -34,6 +34,7 @@
#include "content/public/browser/notification_source.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/common/content_switches.h"
#include "extensions/common/constants.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_errors.h"
#include "net/base/static_cookie_policy.h"
Expand Down Expand Up @@ -507,10 +508,10 @@ bool HostContentSettingsMap::ShouldAllowAllContent(
primary_url.SchemeIsSecure()) {
return true;
}
if (primary_url.SchemeIs(chrome::kExtensionScheme)) {
if (primary_url.SchemeIs(extensions::kExtensionScheme)) {
return content_type != CONTENT_SETTINGS_TYPE_PLUGINS &&
(content_type != CONTENT_SETTINGS_TYPE_COOKIES ||
secondary_url.SchemeIs(chrome::kExtensionScheme));
secondary_url.SchemeIs(extensions::kExtensionScheme));
}
return primary_url.SchemeIs(chrome::kChromeDevToolsScheme) ||
primary_url.SchemeIs(chrome::kChromeInternalScheme) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/common/extensions/url_pattern.h"
#include "content/public/common/url_constants.h"
#include "extensions/common/url_pattern.h"

namespace {

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/api/management/management_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
#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 "chrome/common/extensions/url_pattern.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/url_pattern.h"

#if !defined(OS_ANDROID)
#include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/extensions/api/tabs/tabs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
#include "chrome/browser/extensions/extension_function_util.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/script_executor.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/extensions/window_controller.h"
#include "chrome/browser/extensions/window_controller_list.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
Expand Down Expand Up @@ -67,6 +67,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "content/public/common/url_constants.h"
#include "extensions/common/constants.h"
#include "skia/ext/image_operations.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/skia/include/core/SkBitmap.h"
Expand Down Expand Up @@ -1056,7 +1057,7 @@ bool CreateTabFunction::RunImpl() {

// We can't load extension URLs into incognito windows unless the extension
// uses split mode. Special case to fall back to a tabbed window.
if (url.SchemeIs(chrome::kExtensionScheme) &&
if (url.SchemeIs(extensions::kExtensionScheme) &&
!GetExtension()->incognito_split_mode() &&
browser->profile()->IsOffTheRecord()) {
Profile* profile = browser->profile()->GetOriginalProfile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "base/logging.h"
#include "chrome/common/url_constants.h"
#include "extensions/common/constants.h"

namespace extensions {

Expand Down Expand Up @@ -83,7 +84,7 @@ bool FrameNavigationState::IsValidUrl(const GURL& url) const {
// Allow about:blank.
if (url.spec() == chrome::kAboutBlankURL)
return true;
if (allow_extension_scheme_ && url.scheme() == chrome::kExtensionScheme)
if (allow_extension_scheme_ && url.scheme() == extensions::kExtensionScheme)
return true;
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
#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/extensions/url_pattern.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_message_filter.h"
#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/url_pattern.h"
#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
#include "net/base/auth.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/resource_request_info.h"
#include "extensions/common/constants.h"
#include "googleurl/src/gurl.h"
#include "net/url_request/url_request.h"

Expand Down Expand Up @@ -67,7 +68,7 @@ bool HasWebRequestScheme(const GURL& url) {
url.SchemeIs(chrome::kFtpScheme) ||
url.SchemeIs(chrome::kHttpScheme) ||
url.SchemeIs(chrome::kHttpsScheme) ||
url.SchemeIs(chrome::kExtensionScheme));
url.SchemeIs(extensions::kExtensionScheme));
}

} // namespace
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/convert_web_app_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "chrome/common/extensions/extension_icon_set.h"
#include "chrome/common/extensions/extension_resource.h"
#include "chrome/common/extensions/permissions/permission_set.h"
#include "chrome/common/extensions/url_pattern.h"
#include "chrome/common/web_apps.h"
#include "extensions/common/url_pattern.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/codec/png_codec.h"
Expand Down
Loading

0 comments on commit 885c0e9

Please sign in to comment.