diff options
23 files changed, 79 insertions, 86 deletions
diff --git a/chrome/DEPS b/chrome/DEPS index 4d20732..2580f54 100644 --- a/chrome/DEPS +++ b/chrome/DEPS @@ -13,6 +13,7 @@ include_rules = [ "+chrome/test", "-content", "+content/common", + "+content/public/common", "+content/test", # Don't allow inclusion of these other libs we shouldn't be calling directly. diff --git a/chrome/browser/chromeos/login/web_page_view.cc b/chrome/browser/chromeos/login/web_page_view.cc index 9f8e79d..d6f78ee 100644 --- a/chrome/browser/chromeos/login/web_page_view.cc +++ b/chrome/browser/chromeos/login/web_page_view.cc @@ -15,7 +15,7 @@ #include "content/browser/child_process_security_policy.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/webui/web_ui.h" -#include "content/common/bindings_policy.h" +#include "content/public/common/bindings_policy.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "ipc/ipc_message.h" diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc index d896519..a71e4f0 100644 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -39,9 +39,9 @@ #include "content/browser/tab_contents/navigation_entry.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents_view.h" -#include "content/common/bindings_policy.h" #include "content/common/devtools_messages.h" #include "content/common/notification_service.h" +#include "content/public/common/bindings_policy.h" #include "grit/generated_resources.h" const char DevToolsWindow::kDevToolsApp[] = "DevToolsApp"; @@ -121,7 +121,8 @@ DevToolsWindow* DevToolsWindow::Create( // Create TabContents with devtools. TabContentsWrapper* tab_contents = Browser::TabContentsFactory(profile, NULL, MSG_ROUTING_NONE, NULL, NULL); - tab_contents->render_view_host()->AllowBindings(BindingsPolicy::WEB_UI); + tab_contents->render_view_host()->AllowBindings( + content::BINDINGS_POLICY_WEB_UI); tab_contents->controller().LoadURL( GetDevToolsUrl(profile, docked, shared_worker_frontend), GURL(), diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 50e2642..0902ba7 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -44,11 +44,11 @@ #include "content/browser/tab_contents/popup_menu_helper_mac.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents_view.h" -#include "content/common/bindings_policy.h" #include "content/common/content_client.h" #include "content/common/native_web_keyboard_event.h" #include "content/common/notification_service.h" #include "content/common/view_messages.h" +#include "content/public/common/bindings_policy.h" #include "grit/browser_resources.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -145,7 +145,7 @@ ExtensionHost::ExtensionHost(const Extension* extension, render_view_host_ = new RenderViewHost(site_instance, this, MSG_ROUTING_NONE, NULL); if (enable_dom_automation_) - render_view_host_->AllowBindings(BindingsPolicy::DOM_AUTOMATION); + render_view_host_->AllowBindings(content::BINDINGS_POLICY_DOM_AUTOMATION); // Listen for when the render process' handle is available so we can add it // to the task manager then. diff --git a/chrome/browser/extensions/extension_web_ui.cc b/chrome/browser/extensions/extension_web_ui.cc index eeca442..2a14e58 100644 --- a/chrome/browser/extensions/extension_web_ui.cc +++ b/chrome/browser/extensions/extension_web_ui.cc @@ -25,8 +25,8 @@ #include "chrome/common/extensions/extension_resource.h" #include "chrome/common/url_constants.h" #include "content/browser/tab_contents/tab_contents.h" -#include "content/common/bindings_policy.h" #include "content/common/page_transition_types.h" +#include "content/public/common/bindings_policy.h" #include "net/base/file_stream.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/codec/png_codec.h" @@ -145,7 +145,7 @@ ExtensionWebUI::ExtensionWebUI(TabContents* tab_contents, const GURL& url) // Bind externalHost to Extension WebUI loaded in Chrome Frame. const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); if (browser_command_line.HasSwitch(switches::kChromeFrame)) - bindings_ |= BindingsPolicy::EXTERNAL_HOST; + bindings_ |= content::BINDINGS_POLICY_EXTERNAL_HOST; // For chrome:// overrides, some of the defaults are a little different. GURL effective_url = tab_contents->GetURL(); if (effective_url.SchemeIs(chrome::kChromeUIScheme)) { diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc index c7905c3..14799d7c 100644 --- a/chrome/browser/external_tab_container_win.cc +++ b/chrome/browser/external_tab_container_win.cc @@ -43,12 +43,12 @@ #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" #include "content/browser/tab_contents/navigation_details.h" #include "content/browser/tab_contents/provisional_load_details.h" -#include "content/common/bindings_policy.h" #include "content/common/native_web_keyboard_event.h" #include "content/common/notification_service.h" #include "content/common/page_transition_types.h" #include "content/common/page_zoom.h" #include "content/common/view_messages.h" +#include "content/public/common/bindings_policy.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "ui/base/l10n/l10n_util.h" @@ -204,7 +204,7 @@ bool ExternalTabContainer::Init(Profile* profile, if (!existing_contents) { tab_contents_->render_view_host()->AllowBindings( - BindingsPolicy::EXTERNAL_HOST); + content::BINDINGS_POLICY_EXTERNAL_HOST); } NavigationController* controller = &tab_contents_->controller(); diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc index 8d7faf1..fd49b30 100644 --- a/chrome/browser/memory_details.cc +++ b/chrome/browser/memory_details.cc @@ -22,7 +22,7 @@ #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/navigation_entry.h" #include "content/browser/tab_contents/tab_contents.h" -#include "content/common/bindings_policy.h" +#include "content/public/common/bindings_policy.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -165,7 +165,7 @@ void MemoryDetails::CollectChildInfoOnUIThread() { DCHECK(host_delegate); GURL url = host_delegate->GetURL(); content::ViewType::Type type = host_delegate->GetRenderViewType(); - if (host->enabled_bindings() & BindingsPolicy::WEB_UI) { + if (host->enabled_bindings() & content::BINDINGS_POLICY_WEB_UI) { // TODO(erikkay) the type for devtools doesn't actually appear to // be set. if (type == content::ViewType::DEV_TOOLS_UI) diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc index 3f39566..7d412ec 100644 --- a/chrome/browser/notifications/balloon_host.cc +++ b/chrome/browser/notifications/balloon_host.cc @@ -17,11 +17,11 @@ #include "content/browser/renderer_host/browser_render_process_host.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/site_instance.h" -#include "content/common/bindings_policy.h" #include "content/common/notification_service.h" #include "content/common/notification_source.h" #include "content/common/renderer_preferences.h" #include "content/common/view_messages.h" +#include "content/public/common/bindings_policy.h" #include "ipc/ipc_message.h" #include "webkit/glue/webpreferences.h" @@ -178,7 +178,7 @@ void BalloonHost::Init() { RenderViewHost* rvh = new RenderViewHost( site_instance_.get(), this, MSG_ROUTING_NONE, NULL); if (enable_web_ui_) - rvh->AllowBindings(BindingsPolicy::WEB_UI); + rvh->AllowBindings(content::BINDINGS_POLICY_WEB_UI); // Do platform-specific initialization. render_view_host_ = rvh; diff --git a/chrome/browser/renderer_host/chrome_render_view_host_observer.cc b/chrome/browser/renderer_host/chrome_render_view_host_observer.cc index db5c193..8945f04 100644 --- a/chrome/browser/renderer_host/chrome_render_view_host_observer.cc +++ b/chrome/browser/renderer_host/chrome_render_view_host_observer.cc @@ -19,7 +19,6 @@ #include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/site_instance.h" -#include "content/common/bindings_policy.h" #include "content/common/notification_service.h" #include "content/common/view_messages.h" diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc index 3de88e9..29d2676 100644 --- a/chrome/browser/tab_contents/web_contents_unittest.cc +++ b/chrome/browser/tab_contents/web_contents_unittest.cc @@ -21,11 +21,11 @@ #include "content/browser/tab_contents/navigation_details.h" #include "content/browser/tab_contents/navigation_entry.h" #include "content/browser/tab_contents/test_tab_contents.h" -#include "content/common/bindings_policy.h" #include "content/common/content_constants.h" #include "content/common/notification_service.h" #include "content/common/notification_source.h" #include "content/common/view_messages.h" +#include "content/public/common/bindings_policy.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/message_box_flags.h" #include "webkit/glue/webkit_glue.h" @@ -610,7 +610,7 @@ TEST_F(TabContentsTest, CrossSiteNavigationBackPreempted) { EXPECT_EQ(ntp_rvh, contents()->render_view_host()); EXPECT_EQ(url1, entry1->url()); EXPECT_EQ(instance1, entry1->site_instance()); - EXPECT_TRUE(BindingsPolicy::is_web_ui_enabled(ntp_rvh->enabled_bindings())); + EXPECT_TRUE(ntp_rvh->enabled_bindings() & content::BINDINGS_POLICY_WEB_UI); // Navigate to new site. const GURL url2("http://www.google.com"); @@ -635,8 +635,8 @@ TEST_F(TabContentsTest, CrossSiteNavigationBackPreempted) { EXPECT_FALSE(contents()->pending_rvh()); EXPECT_EQ(url2, entry2->url()); EXPECT_EQ(instance2, entry2->site_instance()); - EXPECT_FALSE(BindingsPolicy::is_web_ui_enabled( - google_rvh->enabled_bindings())); + EXPECT_FALSE(google_rvh->enabled_bindings() & + content::BINDINGS_POLICY_WEB_UI); // Navigate to third page on same site. const GURL url3("http://news.google.com"); diff --git a/chrome/browser/ui/webui/chromeos/enterprise_enrollment_ui.cc b/chrome/browser/ui/webui/chromeos/enterprise_enrollment_ui.cc index ea34265..b7d461f 100644 --- a/chrome/browser/ui/webui/chromeos/enterprise_enrollment_ui.cc +++ b/chrome/browser/ui/webui/chromeos/enterprise_enrollment_ui.cc @@ -18,7 +18,7 @@ #include "chrome/common/url_constants.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" -#include "content/common/bindings_policy.h" +#include "content/public/common/bindings_policy.h" #include "grit/browser_resources.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -159,7 +159,7 @@ EnterpriseEnrollmentUI::~EnterpriseEnrollmentUI() {} void EnterpriseEnrollmentUI::RenderViewCreated( RenderViewHost* render_view_host) { // Bail out early if web ui is disabled. - if (!(bindings_ & BindingsPolicy::WEB_UI)) + if (!(bindings_ & content::BINDINGS_POLICY_WEB_UI)) return; handler_ = new SingleEnterpriseEnrollmentScreenHandler(); diff --git a/chrome/browser/ui/webui/html_dialog_ui.cc b/chrome/browser/ui/webui/html_dialog_ui.cc index d6dc51a5..ca071a3 100644 --- a/chrome/browser/ui/webui/html_dialog_ui.cc +++ b/chrome/browser/ui/webui/html_dialog_ui.cc @@ -11,8 +11,8 @@ #include "chrome/common/chrome_notification_types.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" -#include "content/common/bindings_policy.h" #include "content/common/notification_service.h" +#include "content/public/common/bindings_policy.h" static base::LazyInstance<PropertyAccessor<HtmlDialogUIDelegate*> > g_html_dialog_ui_property_accessor(base::LINKER_INITIALIZED); @@ -60,7 +60,7 @@ void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { (*delegate)->GetWebUIMessageHandlers(&handlers); } - if (0 != (bindings_ & BindingsPolicy::WEB_UI)) + if (0 != (bindings_ & content::BINDINGS_POLICY_WEB_UI)) render_view_host->SetWebUIProperty("dialogArguments", dialog_args); for (std::vector<WebUIMessageHandler*>::iterator it = handlers.begin(); it != handlers.end(); ++it) { @@ -92,7 +92,7 @@ ExternalHtmlDialogUI::ExternalHtmlDialogUI(TabContents* tab_contents) // for security reasons. The code hosting the dialog should provide // dialog specific functionality through other bindings and methods // that are scoped in duration to the dialogs existence. - bindings_ &= ~BindingsPolicy::WEB_UI; + bindings_ &= ~content::BINDINGS_POLICY_WEB_UI; } ExternalHtmlDialogUI::~ExternalHtmlDialogUI() { diff --git a/chrome/renderer/chrome_render_view_observer.cc b/chrome/renderer/chrome_render_view_observer.cc index ec5b610..39dc76d 100644 --- a/chrome/renderer/chrome_render_view_observer.cc +++ b/chrome/renderer/chrome_render_view_observer.cc @@ -25,8 +25,8 @@ #include "chrome/renderer/prerender/prerender_helper.h" #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" #include "chrome/renderer/translate_helper.h" -#include "content/common/bindings_policy.h" #include "content/common/view_messages.h" +#include "content/public/common/bindings_policy.h" #include "content/public/renderer/render_view.h" #include "content/public/renderer/content_renderer_client.h" #include "net/base/data_url.h" @@ -233,7 +233,7 @@ ChromeRenderViewObserver::ChromeRenderViewObserver( if (command_line.HasSwitch(switches::kDomAutomationController)) { int old_bindings = render_view->GetEnabledBindings(); render_view->SetEnabledBindings( - old_bindings |= BindingsPolicy::DOM_AUTOMATION); + old_bindings |= content::BINDINGS_POLICY_DOM_AUTOMATION); } render_view->GetWebView()->setPermissionClient(this); if (!command_line.HasSwitch(switches::kDisableClientSidePhishingDetection)) @@ -665,7 +665,7 @@ void ChromeRenderViewObserver::OnSetIsPrerendering(bool is_prerendering) { } void ChromeRenderViewObserver::DidStartLoading() { - if (BindingsPolicy::is_web_ui_enabled(render_view()->GetEnabledBindings()) && + if ((render_view()->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) && webui_javascript_.get()) { render_view()->EvaluateScript(webui_javascript_->frame_xpath, webui_javascript_->jscript, @@ -743,13 +743,13 @@ void ChromeRenderViewObserver::DidCommitProvisionalLoad( } void ChromeRenderViewObserver::DidClearWindowObject(WebFrame* frame) { - if (BindingsPolicy::is_dom_automation_enabled( - render_view()->GetEnabledBindings())) { + if (render_view()->GetEnabledBindings() & + content::BINDINGS_POLICY_DOM_AUTOMATION) { BindDOMAutomationController(frame); } - if (BindingsPolicy::is_external_host_enabled( - render_view()->GetEnabledBindings())) { + if (render_view()->GetEnabledBindings() & + content::BINDINGS_POLICY_EXTERNAL_HOST) { GetExternalHostBindings()->BindToJavascript(frame, "externalHost"); } } diff --git a/content/DEPS b/content/DEPS index a646685..28c15c0 100644 --- a/content/DEPS +++ b/content/DEPS @@ -19,6 +19,7 @@ include_rules = [ # directories in content/ so we disallow all of them. "-content", "+content/common", + "+content/public/common", "+content/test", "+dbus", diff --git a/content/browser/child_process_security_policy.cc b/content/browser/child_process_security_policy.cc index 44dad89..0da4110 100644 --- a/content/browser/child_process_security_policy.cc +++ b/content/browser/child_process_security_policy.cc @@ -9,8 +9,8 @@ #include "base/platform_file.h" #include "base/stl_util.h" #include "base/string_util.h" -#include "content/common/bindings_policy.h" #include "content/common/url_constants.h" +#include "content/public/common/bindings_policy.h" #include "googleurl/src/gurl.h" #include "net/url_request/url_request.h" @@ -93,7 +93,7 @@ class ChildProcessSecurityPolicy::SecurityState { } bool has_web_ui_bindings() const { - return BindingsPolicy::is_web_ui_enabled(enabled_bindings_); + return enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI; } bool can_read_raw_cookies() const { @@ -299,7 +299,7 @@ void ChildProcessSecurityPolicy::GrantWebUIBindings(int child_id) { if (state == security_state_.end()) return; - state->second->GrantBindings(BindingsPolicy::WEB_UI); + state->second->GrantBindings(content::BINDINGS_POLICY_WEB_UI); // Web UI bindings need the ability to request chrome: URLs. state->second->GrantScheme(chrome::kChromeUIScheme); diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index f2b1a76..5298315 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -29,7 +29,6 @@ #include "content/browser/renderer_host/render_widget_host_view.h" #include "content/browser/site_instance.h" #include "content/browser/user_metrics.h" -#include "content/common/bindings_policy.h" #include "content/common/content_constants.h" #include "content/common/content_notification_types.h" #include "content/common/desktop_notification_messages.h" @@ -42,6 +41,7 @@ #include "content/common/swapped_out_messages.h" #include "content/common/url_constants.h" #include "content/common/view_messages.h" +#include "content/public/common/bindings_policy.h" #include "net/base/net_util.h" #include "net/url_request/url_request_context_getter.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -163,7 +163,7 @@ bool RenderViewHost::CreateRenderView(const string16& frame_name) { DCHECK(process()->HasConnection()); DCHECK(process()->browser_context()); - if (BindingsPolicy::is_web_ui_enabled(enabled_bindings_)) { + if (enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) { ChildProcessSecurityPolicy::GetInstance()->GrantWebUIBindings( process()->id()); } @@ -534,7 +534,7 @@ void RenderViewHost::AllowBindings(int bindings_flags) { void RenderViewHost::SetWebUIProperty(const std::string& name, const std::string& value) { - DCHECK(BindingsPolicy::is_web_ui_enabled(enabled_bindings_)); + DCHECK(enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI); Send(new ViewMsg_SetWebUIProperty(routing_id(), name, value)); } @@ -1070,7 +1070,7 @@ void RenderViewHost::OnAddMessageToConsole(int32 level, const string16& source_id) { // Pass through log level only on WebUI pages to limit console spew. int32 resolved_level = - BindingsPolicy::is_web_ui_enabled(enabled_bindings_) ? level : 0; + (enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) ? level : 0; logging::LogMessage("CONSOLE", line_no, resolved_level).stream() << "\"" << message << "\", source: " << source_id << " (" << line_no << ")"; diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc index 9e7db60..538ad8a 100644 --- a/content/browser/tab_contents/interstitial_page.cc +++ b/content/browser/tab_contents/interstitial_page.cc @@ -22,13 +22,13 @@ #include "content/browser/tab_contents/navigation_entry.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents_view.h" -#include "content/common/bindings_policy.h" #include "content/common/dom_storage_common.h" #include "content/common/notification_service.h" #include "content/common/notification_source.h" #include "content/common/page_transition_types.h" #include "content/common/view_messages.h" #include "content/common/view_types.h" +#include "content/public/common/bindings_policy.h" #include "net/base/escape.h" #include "net/url_request/url_request_context_getter.h" @@ -422,7 +422,7 @@ TabContentsView* InterstitialPage::CreateTabContentsView() { RenderWidgetHostView* view = tab_contents_view->CreateViewForWidget(render_view_host_); render_view_host_->SetView(view); - render_view_host_->AllowBindings(BindingsPolicy::DOM_AUTOMATION); + render_view_host_->AllowBindings(content::BINDINGS_POLICY_DOM_AUTOMATION); render_view_host_->CreateRenderView(string16()); view->SetSize(tab_contents_view->GetContainerSize()); diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 1865ac5..b2572a6 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -39,7 +39,6 @@ #include "content/browser/tab_contents/title_updated_details.h" #include "content/browser/user_metrics.h" #include "content/browser/webui/web_ui_factory.h" -#include "content/common/bindings_policy.h" #include "content/common/content_client.h" #include "content/common/content_constants.h" #include "content/common/content_restriction.h" @@ -49,6 +48,7 @@ #include "content/common/url_constants.h" #include "content/common/view_messages.h" #include "content/common/view_types.h" +#include "content/public/common/bindings_policy.h" #include "net/base/net_util.h" #include "net/url_request/url_request_context_getter.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" @@ -574,7 +574,7 @@ bool TabContents::NavigateToEntry( bool is_allowed_in_web_ui_renderer = content::GetContentClient()-> browser()->GetWebUIFactory()->IsURLAcceptableForWebUI(browser_context(), entry.url()); - CHECK(!BindingsPolicy::is_web_ui_enabled(enabled_bindings) || + CHECK(!(enabled_bindings & content::BINDINGS_POLICY_WEB_UI) || is_allowed_in_web_ui_renderer); // Tell DevTools agent that it is attached prior to the navigation. diff --git a/content/browser/webui/web_ui.cc b/content/browser/webui/web_ui.cc index 59e2a07..206d221 100644 --- a/content/browser/webui/web_ui.cc +++ b/content/browser/webui/web_ui.cc @@ -16,8 +16,8 @@ #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents_view.h" #include "content/browser/webui/generic_handler.h" -#include "content/common/bindings_policy.h" #include "content/common/view_messages.h" +#include "content/public/common/bindings_policy.h" #include "ipc/ipc_message.h" #include "ipc/ipc_message_macros.h" @@ -43,7 +43,7 @@ WebUI::WebUI(TabContents* contents) focus_location_bar_by_default_(false), should_hide_url_(false), link_transition_type_(PageTransition::LINK), - bindings_(BindingsPolicy::WEB_UI), + bindings_(content::BINDINGS_POLICY_WEB_UI), register_callback_overwrites_(false), tab_contents_(contents) { DCHECK(contents); @@ -102,7 +102,7 @@ void WebUI::OnWebUISend(const GURL& source_url, void WebUI::RenderViewCreated(RenderViewHost* render_view_host) { // Do not attempt to set the toolkit property if WebUI is not enabled, e.g., // the bookmarks manager page. - if (!(bindings_ & BindingsPolicy::WEB_UI)) + if (!(bindings_ & content::BINDINGS_POLICY_WEB_UI)) return; #if defined(TOOLKIT_VIEWS) diff --git a/content/common/bindings_policy.h b/content/common/bindings_policy.h deleted file mode 100644 index ecdc1a6..0000000 --- a/content/common/bindings_policy.h +++ /dev/null @@ -1,37 +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. - -#ifndef CONTENT_COMMON_BINDINGS_POLICY_H_ -#define CONTENT_COMMON_BINDINGS_POLICY_H_ -#pragma once - -// This is a utility class that specifies flag values for the types of -// JavaScript bindings exposed to renderers. -class BindingsPolicy { - public: - enum { - // HTML-based UI bindings that allows the JS content to send JSON-encoded - // data back to the browser process. - WEB_UI = 1 << 0, - // DOM automation bindings that allows the JS content to send JSON-encoded - // data back to automation in the parent process. (By default this isn't - // allowed unless the app has been started up with the --dom-automation - // switch.) - DOM_AUTOMATION = 1 << 1, - // Bindings that allow access to the external host (through automation). - EXTERNAL_HOST = 1 << 2, - }; - - static bool is_web_ui_enabled(int flags) { - return (flags & WEB_UI) != 0; - } - static bool is_dom_automation_enabled(int flags) { - return (flags & DOM_AUTOMATION) != 0; - } - static bool is_external_host_enabled(int flags) { - return (flags & EXTERNAL_HOST) != 0; - } -}; - -#endif // CONTENT_COMMON_BINDINGS_POLICY_H_ diff --git a/content/content_common.gypi b/content/content_common.gypi index c32f977..6319cea 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -28,12 +28,12 @@ '../base/base.gyp:base', ], 'sources': [ + 'public/common/bindings_policy.h', 'common/appcache/appcache_backend_proxy.cc', 'common/appcache/appcache_backend_proxy.h', 'common/appcache/appcache_dispatcher.cc', 'common/appcache/appcache_dispatcher.h', 'common/appcache_messages.h', - 'common/bindings_policy.h', 'common/child_process.cc', 'common/child_process.h', 'common/child_process_host.cc', diff --git a/content/public/common/bindings_policy.h b/content/public/common/bindings_policy.h new file mode 100644 index 0000000..b350c90 --- /dev/null +++ b/content/public/common/bindings_policy.h @@ -0,0 +1,28 @@ +// 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. + +#ifndef CONTENT_PUBLIC_COMMON_BINDINGS_POLICY_H_ +#define CONTENT_PUBLIC_COMMON_BINDINGS_POLICY_H_ +#pragma once + +namespace content { + +// This enum specifies flag values for the types of JavaScript bindings exposed +// to renderers. +enum BindingsPolicy { + // HTML-based UI bindings that allows the JS content to send JSON-encoded + // data back to the browser process. + BINDINGS_POLICY_WEB_UI = 1 << 0, + // DOM automation bindings that allows the JS content to send JSON-encoded + // data back to automation in the parent process. (By default this isn't + // allowed unless the app has been started up with the --dom-automation + // switch.) + BINDINGS_POLICY_DOM_AUTOMATION = 1 << 1, + // Bindings that allow access to the external host (through automation). + BINDINGS_POLICY_EXTERNAL_HOST = 1 << 2, +}; + +} + +#endif // CONTENT_PUBLIC_COMMON_BINDINGS_POLICY_H_ diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index e6bf678..418ab2c 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -25,7 +25,6 @@ #include "base/time.h" #include "base/utf_string_conversions.h" #include "content/common/appcache/appcache_dispatcher.h" -#include "content/common/bindings_policy.h" #include "content/common/clipboard_messages.h" #include "content/common/content_constants.h" #include "content/common/content_switches.h" @@ -42,6 +41,7 @@ #include "content/common/request_extra_data.h" #include "content/common/url_constants.h" #include "content/common/view_messages.h" +#include "content/public/common/bindings_policy.h" #include "content/public/renderer/content_renderer_client.h" #include "content/public/renderer/navigation_state.h" #include "content/public/renderer/render_view_observer.h" @@ -2042,7 +2042,7 @@ WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( request.httpMethod() == "GET" && !url.SchemeIs(chrome::kAboutScheme)) { bool send_referrer = false; bool should_fork = - BindingsPolicy::is_web_ui_enabled(enabled_bindings_) || + (enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) || frame->isViewSourceModeEnabled() || url.SchemeIs(chrome::kViewSourceScheme); @@ -2498,7 +2498,7 @@ void RenderViewImpl::didClearWindowObject(WebFrame* frame) { DidClearWindowObject(frame)); GURL frame_url = frame->document().url(); - if (BindingsPolicy::is_web_ui_enabled(enabled_bindings_) && + if ((enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) && (frame_url.SchemeIs(chrome::kChromeUIScheme) || frame_url.SchemeIs(chrome::kDataScheme))) { GetWebUIBindings()->BindToJavascript(frame, "chrome"); @@ -3572,7 +3572,7 @@ void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { void RenderViewImpl::OnSetWebUIProperty(const std::string& name, const std::string& value) { - DCHECK(BindingsPolicy::is_web_ui_enabled(enabled_bindings_)); + DCHECK(enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI); GetWebUIBindings()->SetProperty(name, value); } |