diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-18 05:00:10 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-18 05:00:10 +0000 |
commit | 9966325b7197accb38248ebf48983bf0d06c525b (patch) | |
tree | b33fb7ebf51ae47074e5db5c7f255ffd7c9e75f9 /content | |
parent | 9db98a2b1c29c70dc1a2a8a9d5169c7c5411297c (diff) | |
download | chromium_src-9966325b7197accb38248ebf48983bf0d06c525b.zip chromium_src-9966325b7197accb38248ebf48983bf0d06c525b.tar.gz chromium_src-9966325b7197accb38248ebf48983bf0d06c525b.tar.bz2 |
Remove the last Chrome dependencies from renderer, and enforce no more includes through DEPS. I also added DEPS checking for gpu/plugin/worker directories as well. I moved the Chrome specific browser tests to the chrome directory, and removed render_widget_unittest since it didn't seem to be testing much (there are tests that test it much more fully). I had to move bindings_policy.h, which ideally would be split into separate pieces so that the content layer only has to know about the content bindings. Given that it's basically an enum, I moved the whole file now since it's used in a lot of places, and the value of turning on DEPS checking is really high.
Review URL: http://codereview.chromium.org/6874038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81924 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
31 files changed, 295 insertions, 952 deletions
diff --git a/content/browser/child_process_security_policy.cc b/content/browser/child_process_security_policy.cc index 81eca77..1f4e9ce 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-inl.h" #include "base/string_util.h" -#include "chrome/common/bindings_policy.h" #include "chrome/common/url_constants.h" +#include "content/common/bindings_policy.h" #include "googleurl/src/gurl.h" #include "net/url_request/url_request.h" diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index da1e2e0..920d462 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -19,7 +19,6 @@ #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/net/predictor_api.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/common/bindings_policy.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension_messages.h" @@ -38,6 +37,8 @@ #include "content/browser/renderer_host/render_widget_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" #include "content/browser/site_instance.h" +#include "content/common/bindings_policy.h" +#include "content/common/content_constants.h" #include "content/common/drag_messages.h" #include "content/common/native_web_keyboard_event.h" #include "content/common/notification_details.h" @@ -514,29 +515,35 @@ void RenderViewHost::InsertCSSInWebFrame( void RenderViewHost::Undo() { Send(new ViewMsg_Undo(routing_id())); + UserMetrics::RecordAction(UserMetricsAction("Undo")); } void RenderViewHost::Redo() { Send(new ViewMsg_Redo(routing_id())); + UserMetrics::RecordAction(UserMetricsAction("Redo")); } void RenderViewHost::Cut() { Send(new ViewMsg_Cut(routing_id())); + UserMetrics::RecordAction(UserMetricsAction("Cut")); } void RenderViewHost::Copy() { Send(new ViewMsg_Copy(routing_id())); + UserMetrics::RecordAction(UserMetricsAction("Copy")); } void RenderViewHost::CopyToFindPboard() { #if defined(OS_MACOSX) // Windows/Linux don't have the concept of a find pasteboard. Send(new ViewMsg_CopyToFindPboard(routing_id())); + UserMetrics::RecordAction(UserMetricsAction("CopyToFindPboard")); #endif } void RenderViewHost::Paste() { Send(new ViewMsg_Paste(routing_id())); + UserMetrics::RecordAction(UserMetricsAction("Paste")); } void RenderViewHost::ToggleSpellCheck() { @@ -545,10 +552,12 @@ void RenderViewHost::ToggleSpellCheck() { void RenderViewHost::Delete() { Send(new ViewMsg_Delete(routing_id())); + UserMetrics::RecordAction(UserMetricsAction("DeleteSelection")); } void RenderViewHost::SelectAll() { Send(new ViewMsg_SelectAll(routing_id())); + UserMetrics::RecordAction(UserMetricsAction("SelectAll")); } void RenderViewHost::ToggleSpellPanel(bool is_currently_visible) { @@ -991,7 +1000,7 @@ void RenderViewHost::OnMsgUpdateState(int32 page_id, void RenderViewHost::OnMsgUpdateTitle(int32 page_id, const std::wstring& title) { - if (title.length() > chrome::kMaxTitleChars) { + if (title.length() > content::kMaxTitleChars) { NOTREACHED() << "Renderer sent too many characters in title."; return; } @@ -1149,10 +1158,6 @@ void RenderViewHost::DisassociateFromPopupCount() { Send(new ViewMsg_DisassociateFromPopupCount(routing_id())); } -void RenderViewHost::AllowScriptToClose(bool script_can_close) { - Send(new ViewMsg_AllowScriptToClose(routing_id(), script_can_close)); -} - void RenderViewHost::OnMsgSetTooltipText( const std::wstring& tooltip_text, WebTextDirection text_direction_hint) { diff --git a/content/browser/renderer_host/render_view_host.h b/content/browser/renderer_host/render_view_host.h index 4e9139f..196e6e6 100644 --- a/content/browser/renderer_host/render_view_host.h +++ b/content/browser/renderer_host/render_view_host.h @@ -403,10 +403,6 @@ class RenderViewHost : public RenderWidgetHost { // as a popup. void DisassociateFromPopupCount(); - // Tells the renderer whether it should allow window.close. This is initially - // set to false when creating a renderer-initiated window via window.open. - void AllowScriptToClose(bool visible); - // Notifies the Renderer that a move or resize of its containing window has // started (this is used to hide the autocomplete popups if any). void WindowMoveOrResizeStarted(); diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc index 0669286..da0b968 100644 --- a/content/browser/tab_contents/interstitial_page.cc +++ b/content/browser/tab_contents/interstitial_page.cc @@ -16,7 +16,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/renderer_preferences_util.h" #include "chrome/browser/ui/browser_list.h" -#include "chrome/common/bindings_policy.h" #include "content/browser/browser_thread.h" #include "content/browser/renderer_host/render_process_host.h" #include "content/browser/renderer_host/render_view_host.h" @@ -27,6 +26,7 @@ #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" diff --git a/content/browser/tab_contents/navigation_controller.cc b/content/browser/tab_contents/navigation_controller.cc index ba75cd0..5bdbd23 100644 --- a/content/browser/tab_contents/navigation_controller.cc +++ b/content/browser/tab_contents/navigation_controller.cc @@ -23,6 +23,7 @@ #include "content/browser/tab_contents/navigation_entry.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents_delegate.h" +#include "content/common/content_constants.h" #include "content/common/navigation_types.h" #include "content/common/notification_service.h" #include "content/common/view_messages.h" @@ -107,7 +108,7 @@ bool AreURLsInPageNavigation(const GURL& existing_url, const GURL& new_url) { // static size_t NavigationController::max_entry_count_ = - chrome::kMaxSessionHistoryEntries; + content::kMaxSessionHistoryEntries; // static bool NavigationController::check_for_repost_ = true; diff --git a/content/browser/tab_contents/navigation_entry.cc b/content/browser/tab_contents/navigation_entry.cc index 535f463..01a8c77 100644 --- a/content/browser/tab_contents/navigation_entry.cc +++ b/content/browser/tab_contents/navigation_entry.cc @@ -11,6 +11,7 @@ #include "chrome/common/url_constants.h" #include "content/browser/site_instance.h" #include "content/browser/tab_contents/navigation_controller.h" +#include "content/common/content_constants.h" #include "grit/app_resources.h" #include "net/base/net_util.h" #include "ui/base/resource/resource_bundle.h" @@ -102,7 +103,7 @@ const string16& NavigationEntry::GetTitleForDisplay( title = title.substr(slashpos + 1); } - ui::ElideString(title, chrome::kMaxTitleChars, &cached_display_title_); + ui::ElideString(title, content::kMaxTitleChars, &cached_display_title_); return cached_display_title_; } diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 3b4d4a9..e7071e3 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -52,7 +52,6 @@ #include "chrome/browser/tab_contents/thumbnail_generator.h" #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" #include "chrome/browser/ui/browser_dialogs.h" -#include "chrome/common/bindings_policy.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/content_restriction.h" @@ -78,6 +77,7 @@ #include "content/browser/tab_contents/tab_contents_observer.h" #include "content/browser/tab_contents/tab_contents_view.h" #include "content/browser/webui/web_ui_factory.h" +#include "content/common/bindings_policy.h" #include "content/common/content_client.h" #include "content/common/navigation_types.h" #include "content/common/notification_service.h" @@ -240,7 +240,6 @@ TabContents::TabContents(Profile* profile, received_page_title_(false), blocked_contents_(NULL), all_contents_blocked_(false), - dont_notify_render_view_(false), displayed_insecure_content_(false), capturing_contents_(false), is_being_destroyed_(false), @@ -851,8 +850,6 @@ void TabContents::PopupNotificationVisibilityChanged(bool visible) { if (is_being_destroyed_) return; content_settings_delegate_->SetPopupsBlocked(visible); - if (!dont_notify_render_view_) - render_view_host()->AllowScriptToClose(!visible); } gfx::NativeView TabContents::GetContentNativeView() const { @@ -1539,7 +1536,6 @@ void TabContents::DidNavigateMainFramePostCommit( if (!details.is_in_page) { // Close blocked popups. if (blocked_contents_) { - AutoReset<bool> auto_reset(&dont_notify_render_view_, true); blocked_contents_->Destroy(); blocked_contents_ = NULL; } diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index 73dd143..3f6c1fe 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -1004,9 +1004,6 @@ class TabContents : public PageNavigator, // Should we block all child TabContents this attempts to spawn. bool all_contents_blocked_; - // TODO(pkasting): Hack to try and fix Linux browser tests. - bool dont_notify_render_view_; - // True if this is a secure page which displayed insecure content. bool displayed_insecure_content_; diff --git a/content/browser/webui/web_ui.cc b/content/browser/webui/web_ui.cc index 3cc3633..636f9e8 100644 --- a/content/browser/webui/web_ui.cc +++ b/content/browser/webui/web_ui.cc @@ -10,13 +10,13 @@ #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "base/values.h" -#include "chrome/common/bindings_policy.h" #include "chrome/common/extensions/extension_messages.h" #include "chrome/common/render_messages.h" #include "content/browser/renderer_host/render_view_host.h" #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" namespace { diff --git a/content/common/bindings_policy.h b/content/common/bindings_policy.h new file mode 100644 index 0000000..2dcea30 --- /dev/null +++ b/content/common/bindings_policy.h @@ -0,0 +1,43 @@ +// 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 he 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, + // Special bindings with privileged APIs for code running in the extension + // process. + EXTENSION = 1 << 3, + }; + + 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; + } + static bool is_extension_enabled(int flags) { + return (flags & EXTENSION) != 0; + } +}; + +#endif // CONTENT_COMMON_BINDINGS_POLICY_H_ diff --git a/content/common/content_constants.cc b/content/common/content_constants.cc index 2532fc1..3ecda57 100644 --- a/content/common/content_constants.cc +++ b/content/common/content_constants.cc @@ -6,6 +6,8 @@ namespace content { +const int kMaxSessionHistoryEntries = 50; +const size_t kMaxTitleChars = 4 * 1024; const size_t kMaxURLChars = 2 * 1024 * 1024; const size_t kMaxURLDisplayChars = 32 * 1024; diff --git a/content/common/content_constants.h b/content/common/content_constants.h index ca94329..05739ff 100644 --- a/content/common/content_constants.h +++ b/content/common/content_constants.h @@ -12,6 +12,13 @@ namespace content { +// The maximum number of session history entries per tab. +extern const int kMaxSessionHistoryEntries; + +// The maximum number of characters of the document's title that we're willing +// to accept in the browser process. +extern const size_t kMaxTitleChars; + // The maximum number of characters in the URL that we're willing to accept // in the browser process. It is set low enough to avoid damage to the browser // but high enough that a web site can abuse location.hash for a little storage. diff --git a/content/common/content_switches.cc b/content/common/content_switches.cc index a03233d..9e64cb7 100644 --- a/content/common/content_switches.cc +++ b/content/common/content_switches.cc @@ -27,6 +27,10 @@ const char kDisableAcceleratedCompositing[] = "disable-accelerated-compositing"; // Disable the ApplicationCache. const char kDisableApplicationCache[] = "disable-application-cache"; +// +// TODO(scherkus): remove --disable-audio when we have a proper fallback +// mechanism. +const char kDisableAudio[] = "disable-audio"; // Disable limits on the number of backing stores. Can prevent blinking for // users with many windows/tabs and lots of memory. @@ -117,6 +121,9 @@ const char kDisableWebSockets[] = "disable-web-sockets"; // in build/features_override.gypi. const char kEnableAcceleratedDrawing[] = "enable-accelerated-drawing"; +// Enables WebKit accessibility within the renderer process. +const char kEnableAccessibility[] = "enable-accessibility"; + // Enables the benchmarking extensions. const char kEnableBenchmarking[] = "enable-benchmarking"; @@ -135,6 +142,9 @@ const char kEnableLogging[] = "enable-logging"; // assumed to be sRGB. const char kEnableMonitorProfile[] = "enable-monitor-profile"; +// Enable Pepper and JavaScript P2P API. +const char kEnableP2PApi[] = "enable-p2papi"; + // Enable caching of pre-parsed JS script data. See http://crbug.com/32407. const char kEnablePreparsedJsCaching[] = "enable-preparsed-js-caching"; @@ -148,6 +158,14 @@ const char kEnableSeccompSandbox[] = "enable-seccomp-sandbox"; // Enables StatsTable, logging statistics to a global named shared memory table. const char kEnableStatsTable[] = "enable-stats-table"; +// Enables support for fullscreen video. Current implementation is +// incomplete and this flag is used for development and testing. +const char kEnableVideoFullscreen[] = "enable-video-fullscreen"; + +// Enables video logging where video elements log playback performance data to +// the debug log. +const char kEnableVideoLogging[] = "enable-video-logging"; + // Enable web audio API. const char kEnableWebAudio[] = "enable-webaudio"; @@ -306,6 +324,10 @@ const char kServiceProcess[] = "service"; // Visibly render a border around paint rects in the web page to help debug // and study painting behavior. const char kShowPaintRects[] = "show-paint-rects"; +// +// TODO(scherkus): remove --simple-data-source when our media resource loading +// is cleaned up and playback testing completed. +const char kSimpleDataSource[] = "simple-data-source"; // Runs the renderer and plugins in the same process as the browser const char kSingleProcess[] = "single-process"; diff --git a/content/common/content_switches.h b/content/common/content_switches.h index e37e70a..761b35b 100644 --- a/content/common/content_switches.h +++ b/content/common/content_switches.h @@ -16,6 +16,7 @@ extern const char kBrowserSubprocessPath[]; extern const char kDisable3DAPIs[]; extern const char kDisableAcceleratedCompositing[]; extern const char kDisableApplicationCache[]; +extern const char kDisableAudio[]; extern const char kDisableBackingStoreLimit[]; extern const char kDisableDatabases[]; extern const char kDisableDataTransferItems[]; @@ -43,15 +44,19 @@ extern const char kDisableSharedWorkers[]; extern const char kDisableSpeechInput[]; extern const char kDisableWebSockets[]; extern const char kEnableAcceleratedDrawing[]; +extern const char kEnableAccessibility[]; extern const char kEnableBenchmarking[]; extern const char kEnableDeviceMotion[]; extern const char kEnableGPUPlugin[]; extern const char kEnableLogging[]; extern const char kEnableMonitorProfile[]; +extern const char kEnableP2PApi[]; extern const char kEnablePreparsedJsCaching[]; extern const char kEnableSandboxLogging[]; extern const char kEnableSeccompSandbox[]; extern const char kEnableStatsTable[]; +extern const char kEnableVideoFullscreen[]; +extern const char kEnableVideoLogging[]; extern const char kEnableWebAudio[]; extern const char kExperimentalLocationFeatures[]; // TODO(jam): this doesn't belong in content. @@ -100,6 +105,7 @@ extern const char kSafePlugins[]; // TODO(jam): this doesn't belong in content. extern const char kServiceProcess[]; extern const char kShowPaintRects[]; +extern const char kSimpleDataSource[]; extern const char kSingleProcess[]; extern const char kTestSandbox[]; extern const char kUnlimitedQuotaForFiles[]; diff --git a/content/common/url_constants.cc b/content/common/url_constants.cc new file mode 100644 index 0000000..74ce5f4 --- /dev/null +++ b/content/common/url_constants.cc @@ -0,0 +1,34 @@ +// 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 "content/common/url_constants.h" + +namespace chrome { + +const char kAboutScheme[] = "about"; +const char kBlobScheme[] = "blob"; +const char kChromeDevToolsScheme[] = "chrome-devtools"; +const char kChromeInternalScheme[] = "chrome-internal"; +const char kChromeUIScheme[] = "chrome"; +const char kDataScheme[] = "data"; +const char kExtensionScheme[] = "chrome-extension"; +const char kFileScheme[] = "file"; +const char kFileSystemScheme[] = "filesystem"; +const char kFtpScheme[] = "ftp"; +const char kHttpScheme[] = "http"; +const char kHttpsScheme[] = "https"; +const char kJavaScriptScheme[] = "javascript"; +const char kMailToScheme[] = "mailto"; +const char kMetadataScheme[] = "metadata"; +const char kUserScriptScheme[] = "chrome-user-script"; +const char kViewSourceScheme[] = "view-source"; + +const char kStandardSchemeSeparator[] = "://"; + +const char kAboutBlankURL[] = "about:blank"; +const char kAboutCrashURL[] = "about:crash"; + +const char kUnreachableWebDataURL[] = "chrome://chromewebdata/"; + +} // namespace chrome diff --git a/content/common/url_constants.h b/content/common/url_constants.h new file mode 100644 index 0000000..86ce54d --- /dev/null +++ b/content/common/url_constants.h @@ -0,0 +1,49 @@ +// 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. + +// Contains constants for known URLs and portions thereof. + +#ifndef CONTENT_COMMON_URL_CONSTANTS_H_ +#define CONTENT_COMMON_URL_CONSTANTS_H_ +#pragma once + +#include "content/common/url_constants.h" + +namespace chrome { + +// Canonical schemes you can use as input to GURL.SchemeIs(). +// TODO(jam): some of these don't below in the content layer, but are accessed +// from there. +extern const char kAboutScheme[]; +extern const char kBlobScheme[]; +extern const char kChromeDevToolsScheme[]; +extern const char kChromeInternalScheme[]; +extern const char kChromeUIScheme[]; // The scheme used for WebUIs. +extern const char kCrosScheme[]; // The scheme used for ChromeOS. +extern const char kDataScheme[]; +extern const char kExtensionScheme[]; +extern const char kFileScheme[]; +extern const char kFileSystemScheme[]; +extern const char kFtpScheme[]; +extern const char kHttpScheme[]; +extern const char kHttpsScheme[]; +extern const char kJavaScriptScheme[]; +extern const char kMailToScheme[]; +extern const char kMetadataScheme[]; +extern const char kUserScriptScheme[]; +extern const char kViewSourceScheme[]; + +// Used to separate a standard scheme and the hostname: "://". +extern const char kStandardSchemeSeparator[]; + +// About URLs (including schemes). +extern const char kAboutBlankURL[]; +extern const char kAboutCrashURL[]; + +// Special URL used to start a navigation to an error page. +extern const char kUnreachableWebDataURL[]; + +} // namespace chrome + +#endif // CONTENT_COMMON_URL_CONSTANTS_H_ diff --git a/content/common/view_messages.h b/content/common/view_messages.h index 8c31bdc..70f25e07 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -65,6 +65,15 @@ struct ViewHostMsg_AccessibilityNotification_Type { }; }; +// Values that may be OR'd together to form the 'flags' parameter of the +// ViewMsg_EnablePreferredSizeChangedMode message. +enum ViewHostMsg_EnablePreferredSizeChangedMode_Flags { + kPreferredSizeNothing, + kPreferredSizeWidth = 1 << 0, + // Requesting the height currently requires a polling loop in render_view.cc. + kPreferredSizeHeightThisIsSlow = 1 << 1, +}; + struct ViewHostMsg_RunFileChooser_Mode { public: enum Value { @@ -1160,6 +1169,18 @@ IPC_MESSAGE_ROUTED2(ViewMsg_PpapiBrokerChannelCreated, IPC_MESSAGE_CONTROL1(ViewMsg_PurgePluginListCache, bool /* reload_pages */) +// Install the first missing pluign. +IPC_MESSAGE_ROUTED0(ViewMsg_InstallMissingPlugin) + +// Sent to the renderer when a popup window should no longer count against +// the current popup count (either because it's not a popup or because it was +// a generated by a user action or because a constrained popup got turned +// into a full window). +IPC_MESSAGE_ROUTED0(ViewMsg_DisassociateFromPopupCount) + +// Tells the render view a prerendered page is about to be displayed. +IPC_MESSAGE_ROUTED0(ViewMsg_DisplayPrerenderedPage) + // Messages sent from the renderer to the browser. @@ -1907,3 +1928,37 @@ IPC_MESSAGE_CONTROL3(ViewHostMsg_DidGenerateCacheableMetadata, GURL /* url */, double /* expected_response_time */, std::vector<char> /* data */) + +// Updates the content restrictions, i.e. to disable print/copy. +IPC_MESSAGE_ROUTED1(ViewHostMsg_UpdateContentRestrictions, + int /* restrictions */) + +// The currently displayed PDF has an unsupported feature. +IPC_MESSAGE_ROUTED0(ViewHostMsg_PDFHasUnsupportedFeature) + +// Brings up SaveAs... dialog (similar to the wrench->SaveAs...). +IPC_MESSAGE_ROUTED0(ViewHostMsg_SaveAs) + +// Notifies when default plugin updates status of the missing plugin. +IPC_MESSAGE_ROUTED1(ViewHostMsg_MissingPluginStatus, + int /* status */) + +// Displays a JavaScript out-of-memory message in the infobar. +IPC_MESSAGE_ROUTED0(ViewHostMsg_JSOutOfMemory) + +// Register a new handler for URL requests with the given scheme. +IPC_MESSAGE_ROUTED3(ViewHostMsg_RegisterProtocolHandler, + std::string /* scheme */, + GURL /* url */, + string16 /* title */) + +// Stores new inspector setting in the profile. +// TODO(jam): this should be in the chrome module +IPC_MESSAGE_ROUTED2(ViewHostMsg_UpdateInspectorSetting, + std::string, /* key */ + std::string /* value */) + +// Message sent from the renderer to the browser to notify it of events which +// may lead to the cancellation of a prerender. The message is sent only when +// the renderer is in prerender mode. +IPC_MESSAGE_ROUTED0(ViewHostMsg_MaybeCancelPrerenderForHTML5Media)
\ No newline at end of file diff --git a/content/content_common.gypi b/content/content_common.gypi index bf9f1d3..7a4c001 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -30,6 +30,7 @@ 'common/appcache_messages.h', 'common/audio_messages.h', 'common/audio_stream_state.h', + 'common/bindings_policy.h', 'common/child_process.cc', 'common/child_process.h', 'common/child_process_host.cc', @@ -200,6 +201,8 @@ 'common/speech_input_result.h', 'common/unix_domain_socket_posix.cc', 'common/unix_domain_socket_posix.h', + 'common/url_constants.cc', + 'common/url_constants.h', 'common/video_capture_messages.h', 'common/view_messages.h', 'common/web_database_observer_impl.cc', diff --git a/content/gpu/gpu_child_thread.cc b/content/gpu/gpu_child_thread.cc index af52c53..1a04e1b 100644 --- a/content/gpu/gpu_child_thread.cc +++ b/content/gpu/gpu_child_thread.cc @@ -11,9 +11,9 @@ #include "base/command_line.h" #include "base/threading/worker_pool.h" #include "build/build_config.h" -#include "chrome/common/chrome_switches.h" #include "content/common/child_process.h" #include "content/common/content_client.h" +#include "content/common/content_switches.h" #include "content/common/gpu_messages.h" #include "content/gpu/gpu_info_collector.h" #include "content/gpu/gpu_watchdog_thread.h" diff --git a/content/renderer/content_renderer_client.cc b/content/renderer/content_renderer_client.cc index 540a980..4c1e2e2 100644 --- a/content/renderer/content_renderer_client.cc +++ b/content/renderer/content_renderer_client.cc @@ -33,6 +33,11 @@ WebKit::WebPlugin* ContentRendererClient::CreatePlugin(RenderView* render_view, return render_view->CreatePluginNoCheck(frame, params); } +void ContentRendererClient::ShowErrorPage(RenderView* render_view, + WebKit::WebFrame* frame, + int http_status_code) { +} + std::string ContentRendererClient::GetNavigationErrorHtml( const WebKit::WebURLRequest& failed_request, const WebKit::WebURLError& error) { diff --git a/content/renderer/content_renderer_client.h b/content/renderer/content_renderer_client.h index 7bba2e8..a315695 100644 --- a/content/renderer/content_renderer_client.h +++ b/content/renderer/content_renderer_client.h @@ -51,6 +51,11 @@ class ContentRendererClient { WebKit::WebFrame* frame, const WebKit::WebPluginParams& params); + // Give the embedder the ability to set an error page. + virtual void ShowErrorPage(RenderView* render_view, + WebKit::WebFrame* frame, + int http_status_code); + // Returns the html to display when a navigation error occurs. virtual std::string GetNavigationErrorHtml( const WebKit::WebURLRequest& failed_request, diff --git a/content/renderer/navigation_state.h b/content/renderer/navigation_state.h index f8ff13f..0656a5e 100644 --- a/content/renderer/navigation_state.h +++ b/content/renderer/navigation_state.h @@ -11,7 +11,6 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/time.h" -#include "chrome/common/extensions/url_pattern.h" #include "content/common/page_transition_types.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" diff --git a/content/renderer/notification_provider.cc b/content/renderer/notification_provider.cc index d1aecba..ea6b54a 100644 --- a/content/renderer/notification_provider.cc +++ b/content/renderer/notification_provider.cc @@ -6,8 +6,6 @@ #include "base/string_util.h" #include "base/task.h" -#include "chrome/common/url_constants.h" -#include "chrome/common/render_messages.h" #include "content/common/desktop_notification_messages.h" #include "content/common/view_messages.h" #include "content/renderer/render_thread.h" @@ -102,15 +100,6 @@ bool NotificationProvider::OnMessageReceived(const IPC::Message& message) { bool NotificationProvider::ShowHTML(const WebNotification& notification, int id) { - // Disallow HTML notifications from unwanted schemes. javascript: - // in particular allows unwanted cross-domain access. - GURL url = notification.url(); - if (!url.SchemeIs(chrome::kHttpScheme) && - !url.SchemeIs(chrome::kHttpsScheme) && - !url.SchemeIs(chrome::kExtensionScheme) && - !url.SchemeIs(chrome::kDataScheme)) - return false; - DCHECK(notification.isHTML()); DesktopNotificationHostMsg_Show_Params params; params.origin = diff --git a/content/renderer/render_thread.cc b/content/renderer/render_thread.cc index 0500e70..625ebbc 100644 --- a/content/renderer/render_thread.cc +++ b/content/renderer/render_thread.cc @@ -21,7 +21,6 @@ #include "base/task.h" #include "base/threading/thread_local.h" #include "base/values.h" -// DO NOT ADD ANY MORE INCLUDES TO "chrome/"! #include "content/common/appcache/appcache_dispatcher.h" #include "content/common/content_switches.h" #include "content/common/database_messages.h" diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc index 57de066..7a339f8 100644 --- a/content/renderer/render_view.cc +++ b/content/renderer/render_view.cc @@ -21,19 +21,13 @@ #include "base/sys_string_conversions.h" #include "base/time.h" #include "base/utf_string_conversions.h" -#include "chrome/common/bindings_policy.h" -#include "chrome/common/chrome_constants.h" -#include "chrome/common/chrome_paths.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/pepper_plugin_registry.h" #include "chrome/common/render_messages.h" -#include "chrome/common/url_constants.h" -#include "chrome/renderer/automation/dom_automation_controller.h" -#include "chrome/renderer/external_host_bindings.h" -#include "chrome/renderer/localized_error.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" #include "content/common/database_messages.h" #include "content/common/drag_messages.h" #include "content/common/file_system/file_system_dispatcher.h" @@ -43,6 +37,7 @@ #include "content/common/pepper_messages.h" #include "content/common/quota_dispatcher.h" #include "content/common/renderer_preferences.h" +#include "content/common/url_constants.h" #include "content/common/view_messages.h" #include "content/renderer/audio_message_filter.h" #include "content/renderer/content_renderer_client.h" @@ -72,7 +67,6 @@ #include "media/base/filter_collection.h" #include "media/base/media_switches.h" #include "media/base/message_loop_factory_impl.h" -#include "net/base/data_url.h" #include "net/base/escape.h" #include "net/base/net_errors.h" #include "net/http/http_util.h" @@ -97,7 +91,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifier.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" @@ -122,21 +115,16 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/message_box_flags.h" -#include "ui/gfx/favicon_size.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/point.h" #include "ui/gfx/rect.h" -#include "v8/include/v8-testing.h" #include "v8/include/v8.h" #include "webkit/appcache/web_application_cache_host_impl.h" #include "webkit/glue/alt_error_page_resource_fetcher.h" #include "webkit/glue/context_menu.h" -#include "webkit/glue/dom_operations.h" #include "webkit/glue/form_data.h" #include "webkit/glue/form_field.h" #include "webkit/glue/glue_serialize.h" -#include "webkit/glue/image_decoder.h" -#include "webkit/glue/image_resource_fetcher.h" #include "webkit/glue/media/video_renderer_impl.h" #include "webkit/glue/password_form_dom_manager.h" #include "webkit/glue/site_isolation_metrics.h" @@ -202,8 +190,6 @@ using WebKit::WebNavigationPolicy; using WebKit::WebNavigationType; using WebKit::WebNetworkStateNotifier; using WebKit::WebNode; -using WebKit::WebPageSerializer; -using WebKit::WebPageSerializerClient; using WebKit::WebPlugin; using WebKit::WebPluginContainer; using WebKit::WebPluginDocument; @@ -240,7 +226,6 @@ using base::Time; using base::TimeDelta; using webkit_glue::AltErrorPageResourceFetcher; using webkit_glue::FormField; -using webkit_glue::ImageResourceFetcher; using webkit_glue::PasswordForm; using webkit_glue::PasswordFormDomManager; using webkit_glue::ResourceFetcher; @@ -395,7 +380,6 @@ RenderView::RenderView(RenderThreadBase* render_thread, send_content_state_immediately_(false), enabled_bindings_(0), send_preferred_size_changes_(false), - script_can_close_(true), is_loading_(false), navigation_gesture_(NavigationGestureUnknown), opened_by_user_gesture_(true), @@ -407,8 +391,6 @@ RenderView::RenderView(RenderThreadBase* render_thread, history_list_length_(0), has_unload_listener_(false), target_url_status_(TARGET_NONE), - view_type_(ViewType::INVALID), - browser_window_id_(-1), ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), @@ -464,18 +446,14 @@ RenderView::RenderView(RenderThreadBase* render_thread, host_window_ = parent_hwnd; const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - if (command_line.HasSwitch(switches::kDomAutomationController)) - enabled_bindings_ |= BindingsPolicy::DOM_AUTOMATION; if (command_line.HasSwitch(switches::kEnableAccessibility)) WebAccessibilityCache::enableAccessibility(); audio_message_filter_ = new AudioMessageFilter(routing_id_); render_thread_->AddFilter(audio_message_filter_); - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableP2PApi)) { + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableP2PApi)) p2p_socket_dispatcher_ = new P2PSocketDispatcher(this); - } content::GetContentClient()->renderer()->RenderViewCreated(this); } @@ -587,10 +565,6 @@ WebKit::WebView* RenderView::webview() const { return static_cast<WebKit::WebView*>(webwidget()); } -void RenderView::UserMetricsRecordAction(const std::string& action) { - Send(new ViewHostMsg_UserMetricsRecordAction(action)); -} - void RenderView::SetReportLoadProgressEnabled(bool enabled) { if (!enabled) { load_progress_tracker_.reset(NULL); @@ -689,7 +663,6 @@ bool RenderView::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, OnResetPageEncodingToDefault) - IPC_MESSAGE_HANDLER(ViewMsg_DownloadFavicon, OnDownloadFavicon) IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) IPC_MESSAGE_HANDLER(ViewMsg_ReservePageIDRange, OnReservePageIDRange) @@ -714,21 +687,11 @@ bool RenderView::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, OnEnumerateDirectoryResponse) IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) - IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) - IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, - OnGetAllSavableResourceLinksForCurrentPage) - IPC_MESSAGE_HANDLER( - ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, - OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnShouldClose) IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) - IPC_MESSAGE_HANDLER(ViewMsg_HandleMessageFromExternalHost, - OnHandleMessageFromExternalHost) IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount, OnDisassociateFromPopupCount) - IPC_MESSAGE_HANDLER(ViewMsg_AllowScriptToClose, - OnAllowScriptToClose) IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedNode, OnClearFocusedNode) IPC_MESSAGE_HANDLER(ViewMsg_SetBackground, OnSetBackground) @@ -737,10 +700,6 @@ bool RenderView::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, OnDisableScrollbarsForSmallWindows) IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) - IPC_MESSAGE_HANDLER(ViewMsg_UpdateBrowserWindowId, - OnUpdateBrowserWindowId) - IPC_MESSAGE_HANDLER(ViewMsg_NotifyRenderViewType, - OnNotifyRendererViewType) IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) #if defined(OS_MACOSX) @@ -765,8 +724,6 @@ bool RenderView::OnMessageReceived(const IPC::Message& message) { #if defined(OS_MACOSX) IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) #endif - IPC_MESSAGE_HANDLER(ViewMsg_JavaScriptStressTestControl, - OnJavaScriptStressTestControl) IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) IPC_MESSAGE_HANDLER(ViewMsg_NetworkStateChanged, OnNetworkStateChanged) // TODO(viettrungluu): Move to a separate message filter. @@ -925,7 +882,6 @@ void RenderView::OnUndo() { return; webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Undo")); - UserMetricsRecordAction("Undo"); } void RenderView::OnRedo() { @@ -933,7 +889,6 @@ void RenderView::OnRedo() { return; webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Redo")); - UserMetricsRecordAction("Redo"); } void RenderView::OnCut() { @@ -941,7 +896,6 @@ void RenderView::OnCut() { return; webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Cut")); - UserMetricsRecordAction("Cut"); } void RenderView::OnCopy() { @@ -949,7 +903,6 @@ void RenderView::OnCopy() { return; webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Copy")); - UserMetricsRecordAction("Copy"); } #if defined(OS_MACOSX) @@ -965,8 +918,6 @@ void RenderView::OnCopyToFindPboard() { RenderThread::current()->Send( new ClipboardHostMsg_FindPboardWriteStringAsync(selection)); } - - UserMetricsRecordAction("CopyToFindPboard"); } #endif @@ -975,7 +926,6 @@ void RenderView::OnPaste() { return; webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Paste")); - UserMetricsRecordAction("Paste"); } void RenderView::OnReplace(const string16& text) { @@ -993,7 +943,6 @@ void RenderView::OnDelete() { return; webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Delete")); - UserMetricsRecordAction("DeleteSelection"); } void RenderView::OnSelectAll() { @@ -1002,7 +951,6 @@ void RenderView::OnSelectAll() { webview()->focusedFrame()->executeCommand( WebString::fromUTF8("SelectAll")); - UserMetricsRecordAction("SelectAll"); } void RenderView::OnSetInitialFocus(bool reverse) { @@ -1231,8 +1179,8 @@ void RenderView::UpdateTitle(WebFrame* frame, const string16& title) { Send(new ViewHostMsg_UpdateTitle( routing_id_, page_id_, - UTF16ToWideHack(title.length() > chrome::kMaxTitleChars ? - title.substr(0, chrome::kMaxTitleChars) : title))); + UTF16ToWideHack(title.length() > content::kMaxTitleChars ? + title.substr(0, content::kMaxTitleChars) : title))); } } @@ -1289,16 +1237,6 @@ void RenderView::LoadNavigationErrorPage(WebFrame* frame, replace); } -void RenderView::BindDOMAutomationController(WebFrame* frame) { - if (!dom_automation_controller_.get()) { - dom_automation_controller_.reset(new DomAutomationController()); - } - dom_automation_controller_->set_message_sender(this); - dom_automation_controller_->set_routing_id(routing_id_); - dom_automation_controller_->BindToJavascript(frame, - "domAutomationController"); -} - bool RenderView::RunJavaScriptMessage(int type, const std::wstring& message, const std::wstring& default_value, @@ -1326,43 +1264,6 @@ bool RenderView::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) { return Send(message); } -void RenderView::AddGURLSearchProvider( - const GURL& osd_url, - search_provider::OSDDType provider_type) { - if (!osd_url.is_empty()) - Send(new ViewHostMsg_PageHasOSDD(routing_id_, page_id_, osd_url, - provider_type)); -} - -void RenderView::OnAllowScriptToClose(bool script_can_close) { - script_can_close_ = script_can_close; -} - -void RenderView::AddSearchProvider( - const std::string& url, - search_provider::OSDDType provider_type) { - if (provider_type == search_provider::EXPLICIT_DEFAULT_PROVIDER && - !webview()->mainFrame()->isProcessingUserGesture()) - return; - - AddGURLSearchProvider(GURL(url), provider_type); -} - -search_provider::InstallState -RenderView::GetSearchProviderInstallState(WebFrame* frame, - const std::string& url) { - GURL inquiry_url = GURL(url); - if (inquiry_url.is_empty()) - return search_provider::DENIED; - - search_provider::InstallState install; - Send(new ViewHostMsg_GetSearchProviderInstallState(routing_id_, - frame->url(), - inquiry_url, - &install)); - return install; -} - void RenderView::OnMissingPluginStatus( WebPluginDelegateProxy* delegate, int status) { @@ -1400,10 +1301,6 @@ WebView* RenderView::createView( if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups) return NULL; - // This window can't be closed from a window.close() call until we receive a - // message from the Browser process explicitly allowing it. - script_can_close_ = false; - ViewHostMsg_CreateWindow_Params params; params.opener_id = routing_id_; params.user_gesture = creator->isProcessingUserGesture(); @@ -1562,18 +1459,6 @@ void RenderView::didStopLoading() { // displayed when done loading. Ideally we would send notification when // finished parsing the head, but webkit doesn't support that yet. // The feed discovery code would also benefit from access to the head. - - // TODO : Get both favicon and touch icon url, and send them to the browser. - GURL favicon_url(webview()->mainFrame()->favIconURL()); - if (!favicon_url.is_empty()) { - std::vector<FaviconURL> urls; - urls.push_back(FaviconURL(favicon_url, FAVICON)); - Send(new ViewHostMsg_UpdateFaviconURL(routing_id_, page_id_, urls)); - } - - AddGURLSearchProvider(webview()->mainFrame()->openSearchDescriptionURL(), - search_provider::AUTODETECTED_PROVIDER); - Send(new ViewHostMsg_DidStopLoading(routing_id_)); if (load_progress_tracker_ != NULL) @@ -1635,7 +1520,7 @@ void RenderView::didExecuteCommand(const WebString& command_name) { StartsWithASCII(name, "Insert", true) || StartsWithASCII(name, "Delete", true)) return; - UserMetricsRecordAction(name); + webkit_glue::UserMetricsRecordAction(name); } void RenderView::SendPendingAccessibilityNotifications() { @@ -2037,8 +1922,7 @@ WebMediaPlayer* RenderView::createMediaPlayer( WebFrame* frame, WebMediaPlayerClient* client) { // If this is a prerendering page, start the cancel of the prerender. if (is_prerendering_) { - Send(new ViewHostMsg_MaybeCancelPrerender(routing_id_, - prerender::PRERENDER_CANCELLATION_REASON_HTML5_MEDIA)); + Send(new ViewHostMsg_MaybeCancelPrerenderForHTML5Media(routing_id_)); } scoped_ptr<media::MessageLoopFactory> message_loop_factory( @@ -2580,8 +2464,8 @@ void RenderView::didCommitProvisionalLoad(WebFrame* frame, // Advance our offset in session history, applying the length limit. There // is now no forward history. history_list_offset_++; - if (history_list_offset_ >= chrome::kMaxSessionHistoryEntries) - history_list_offset_ = chrome::kMaxSessionHistoryEntries - 1; + if (history_list_offset_ >= content::kMaxSessionHistoryEntries) + history_list_offset_ = content::kMaxSessionHistoryEntries - 1; history_list_length_ = history_list_offset_ + 1; } else { // Inspect the navigation_state on this frame to see if the navigation @@ -2626,8 +2510,9 @@ void RenderView::didCommitProvisionalLoad(WebFrame* frame, } void RenderView::didClearWindowObject(WebFrame* frame) { - if (BindingsPolicy::is_dom_automation_enabled(enabled_bindings_)) - BindDOMAutomationController(frame); + FOR_EACH_OBSERVER(RenderViewObserver, observers_, + DidClearWindowObject(frame)); + GURL frame_url = frame->url(); if (BindingsPolicy::is_web_ui_enabled(enabled_bindings_) && (frame_url.SchemeIs(chrome::kChromeUIScheme) || @@ -2636,11 +2521,6 @@ void RenderView::didClearWindowObject(WebFrame* frame) { GetWebUIBindings()->set_routing_id(routing_id_); GetWebUIBindings()->BindToJavascript(frame, "chrome"); } - if (BindingsPolicy::is_external_host_enabled(enabled_bindings_)) { - GetExternalHostBindings()->set_message_sender(this); - GetExternalHostBindings()->set_routing_id(routing_id_); - GetExternalHostBindings()->BindToJavascript(frame, "externalHost"); - } } void RenderView::didCreateDocumentElement(WebFrame* frame) { @@ -2663,11 +2543,7 @@ void RenderView::didReceiveTitle(WebFrame* frame, const WebString& title) { } void RenderView::didChangeIcons(WebFrame* frame) { - if (!frame->parent()) { - std::vector<FaviconURL> urls; - urls.push_back(FaviconURL(frame->favIconURL(), FAVICON)); - Send(new ViewHostMsg_UpdateFaviconURL(routing_id_, page_id_, urls)); - } + FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidChangeIcons(frame)); } void RenderView::didFinishDocumentLoad(WebFrame* frame) { @@ -2841,17 +2717,8 @@ void RenderView::didFinishResourceLoad( } } - // Use an internal error page, if we have one for the status code. - if (LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, - http_status_code)) { - WebURLError error; - error.unreachableURL = frame->url(); - error.domain = WebString::fromUTF8(LocalizedError::kHttpErrorDomain); - error.reason = http_status_code; - - LoadNavigationErrorPage(frame, frame->dataSource()->request(), error, - std::string(), true); - } + content::GetContentClient()->renderer()->ShowErrorPage( + this, frame, http_status_code); } void RenderView::didFailResourceLoad( @@ -3156,75 +3023,6 @@ void RenderView::SyncNavigationState() { routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); } -bool RenderView::DownloadFavicon(int id, const GURL& image_url, - int image_size) { - // Make sure webview was not shut down. - if (!webview()) - return false; - // Create an image resource fetcher and assign it with a call back object. - image_fetchers_.push_back(linked_ptr<ImageResourceFetcher>( - new ImageResourceFetcher( - image_url, webview()->mainFrame(), id, image_size, - WebURLRequest::TargetIsFavicon, - NewCallback(this, &RenderView::DidDownloadFavicon)))); - return true; -} - -void RenderView::DidDownloadFavicon(ImageResourceFetcher* fetcher, - const SkBitmap& image) { - // Notify requester of image download status. - Send(new ViewHostMsg_DidDownloadFavicon(routing_id_, - fetcher->id(), - fetcher->image_url(), - image.isNull(), - image)); - - // Remove the image fetcher from our pending list. We're in the callback from - // ImageResourceFetcher, best to delay deletion. - for (ImageResourceFetcherList::iterator iter = image_fetchers_.begin(); - iter != image_fetchers_.end(); ++iter) { - if (iter->get() == fetcher) { - iter->release(); - image_fetchers_.erase(iter); - break; - } - } - MessageLoop::current()->DeleteSoon(FROM_HERE, fetcher); -} - -void RenderView::OnDownloadFavicon(int id, - const GURL& image_url, - int image_size) { - bool data_image_failed = false; - if (image_url.SchemeIs("data")) { - SkBitmap data_image = ImageFromDataUrl(image_url); - data_image_failed = data_image.empty(); - if (!data_image_failed) { - Send(new ViewHostMsg_DidDownloadFavicon(routing_id_, id, image_url, false, - data_image)); - } - } - - if (data_image_failed || - !DownloadFavicon(id, image_url, image_size)) { - Send(new ViewHostMsg_DidDownloadFavicon(routing_id_, id, image_url, true, - SkBitmap())); - } -} - -SkBitmap RenderView::ImageFromDataUrl(const GURL& url) const { - std::string mime_type, char_set, data; - if (net::DataURL::Parse(url, &mime_type, &char_set, &data) && !data.empty()) { - // Decode the favicon using WebKit's image decoder. - webkit_glue::ImageDecoder decoder(gfx::Size(kFaviconSize, kFaviconSize)); - const unsigned char* src_data = - reinterpret_cast<const unsigned char*>(&data[0]); - - return decoder.Decode(src_data, data.size()); - } - return SkBitmap(); -} - GURL RenderView::GetAlternateErrorPageURL(const GURL& failed_url, ErrorPageType error_type) { if (failed_url.SchemeIsSecure()) { @@ -3289,13 +3087,6 @@ WebUIBindings* RenderView::GetWebUIBindings() { return web_ui_bindings_.get(); } -ExternalHostBindings* RenderView::GetExternalHostBindings() { - if (!external_host_bindings_.get()) { - external_host_bindings_.reset(new ExternalHostBindings()); - } - return external_host_bindings_.get(); -} - WebKit::WebPlugin* RenderView::GetWebPluginFromPluginDocument() { return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); } @@ -3814,16 +3605,6 @@ void RenderView::OnFileChooserResponse(const std::vector<FilePath>& paths) { } } -void RenderView::OnEnableViewSourceMode() { - if (!webview()) - return; - WebFrame* main_frame = webview()->mainFrame(); - if (!main_frame) - return; - - main_frame->enableViewSourceMode(true); -} - void RenderView::OnEnablePreferredSizeChangedMode(int flags) { DCHECK(flags != kPreferredSizeNothing); if (send_preferred_size_changes_) @@ -3879,14 +3660,6 @@ void RenderView::OnMediaPlayerActionAt(const gfx::Point& location, webview()->performMediaPlayerAction(action, location); } -void RenderView::OnNotifyRendererViewType(ViewType::Type type) { - view_type_ = type; -} - -void RenderView::OnUpdateBrowserWindowId(int window_id) { - browser_window_id_ = window_id; -} - void RenderView::OnEnableAccessibility() { if (WebAccessibilityCache::accessibilityEnabled()) return; @@ -3937,64 +3710,6 @@ void RenderView::OnAccessibilityNotificationsAck() { SendPendingAccessibilityNotifications(); } -void RenderView::OnGetAllSavableResourceLinksForCurrentPage( - const GURL& page_url) { - // Prepare list to storage all savable resource links. - std::vector<GURL> resources_list; - std::vector<GURL> referrers_list; - std::vector<GURL> frames_list; - webkit_glue::SavableResourcesResult result(&resources_list, - &referrers_list, - &frames_list); - - if (!webkit_glue::GetAllSavableResourceLinksForCurrentPage( - webview(), - page_url, - &result, - chrome::kSavableSchemes)) { - // If something is wrong when collecting all savable resource links, - // send empty list to embedder(browser) to tell it failed. - referrers_list.clear(); - resources_list.clear(); - frames_list.clear(); - } - - // Send result of all savable resource links to embedder. - Send(new ViewHostMsg_SendCurrentPageAllSavableResourceLinks(routing_id_, - resources_list, - referrers_list, - frames_list)); -} - -void RenderView::OnGetSerializedHtmlDataForCurrentPageWithLocalLinks( - const std::vector<GURL>& links, - const std::vector<FilePath>& local_paths, - const FilePath& local_directory_name) { - - // Convert std::vector of GURLs to WebVector<WebURL> - WebVector<WebURL> weburl_links(links); - - // Convert std::vector of std::strings to WebVector<WebString> - WebVector<WebString> webstring_paths(local_paths.size()); - for (size_t i = 0; i < local_paths.size(); i++) - webstring_paths[i] = webkit_glue::FilePathToWebString(local_paths[i]); - - WebPageSerializer::serialize(webview()->mainFrame(), - true, this, weburl_links, webstring_paths, - webkit_glue::FilePathToWebString( - local_directory_name)); -} - -void RenderView::didSerializeDataForFrame(const WebURL& frame_url, - const WebCString& data, - WebPageSerializerClient::PageSerializationStatus status) { - Send(new ViewHostMsg_SendSerializedHtmlData( - routing_id_, - frame_url, - data.data(), - static_cast<int32>(status))); -} - void RenderView::OnShouldClose() { bool should_close = webview()->dispatchBeforeUnloadEvent(); Send(new ViewHostMsg_ShouldClose_ACK(routing_id_, should_close)); @@ -4025,15 +3740,6 @@ void RenderView::OnThemeChanged() { #endif } -void RenderView::OnHandleMessageFromExternalHost(const std::string& message, - const std::string& origin, - const std::string& target) { - if (message.empty()) - return; - GetExternalHostBindings()->ForwardMessageFromExternalHost(message, origin, - target); -} - void RenderView::OnDisassociateFromPopupCount() { if (decrement_shared_popup_at_destruction_) shared_popup_counter_->data--; @@ -4606,14 +4312,6 @@ void RenderView::OnConnectTcpACK( } #endif -void RenderView::OnJavaScriptStressTestControl(int cmd, int param) { - if (cmd == kJavaScriptStressTestSetStressRunType) { - v8::Testing::SetStressRunType(static_cast<v8::Testing::StressType>(param)); - } else if (cmd == kJavaScriptStressTestPrepareStressRun) { - v8::Testing::PrepareStressRun(param); - } -} - void RenderView::OnContextMenuClosed( const webkit_glue::CustomContextMenuContext& custom_context) { if (custom_context.is_pepper_menu) diff --git a/content/renderer/render_view.h b/content/renderer/render_view.h index 620ed24..548117e1 100644 --- a/content/renderer/render_view.h +++ b/content/renderer/render_view.h @@ -22,8 +22,6 @@ #include "base/timer.h" #include "build/build_config.h" #include "chrome/common/content_settings.h" -#include "chrome/common/search_provider.h" -#include "chrome/common/view_types.h" #include "content/renderer/renderer_webcookiejar_impl.h" #include "content/common/edit_command.h" #include "content/common/navigation_gesture.h" @@ -36,7 +34,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystem.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializerClient.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" @@ -54,8 +51,6 @@ class AudioMessageFilter; class DeviceOrientationDispatcher; -class DomAutomationController; -class ExternalHostBindings; class ExternalPopupMenu; class FilePath; class GeolocationDispatcher; @@ -170,7 +165,6 @@ typedef base::RefCountedData<int> SharedRenderViewCounter; class RenderView : public RenderWidget, public WebKit::WebViewClient, public WebKit::WebFrameClient, - public WebKit::WebPageSerializerClient, public webkit::npapi::WebPluginPageDelegate, public base::SupportsWeakPtr<RenderView> { public: @@ -204,17 +198,9 @@ class RenderView : public RenderWidget, // May return NULL when the view is closing. WebKit::WebView* webview() const; - int browser_window_id() const { - return browser_window_id_; - } - - ViewType::Type view_type() const { - return view_type_; - } - - int page_id() const { - return page_id_; - } + bool is_prerendering() const { return is_prerendering_; } + int page_id() const { return page_id_; } + PepperPluginDelegateImpl* pepper_delegate() { return &pepper_delegate_; } AudioMessageFilter* audio_message_filter() { return audio_message_filter_; @@ -225,6 +211,8 @@ class RenderView : public RenderWidget, } bool content_state_immediately() { return send_content_state_immediately_; } + int enabled_bindings() const { return enabled_bindings_; } + void set_enabled_bindings(int b) { enabled_bindings_ = b; } void set_send_content_state_immediately(bool value) { send_content_state_immediately_ = value; } @@ -248,16 +236,6 @@ class RenderView : public RenderWidget, void AddObserver(RenderViewObserver* observer); void RemoveObserver(RenderViewObserver* observer); - // Called from JavaScript window.external.AddSearchProvider() to add a - // keyword for a provider described in the given OpenSearch document. - void AddSearchProvider(const std::string& url, - search_provider::OSDDType provider_type); - - // Returns the install state for the given search provider url. - search_provider::InstallState GetSearchProviderInstallState( - WebKit::WebFrame* frame, - const std::string& url); - // Evaluates a string of JavaScript in a particular frame. void EvaluateScript(const string16& frame_xpath, const string16& jscript, @@ -277,10 +255,6 @@ class RenderView : public RenderWidget, // allowPlugins(). void SetContentSettings(const ContentSettings& settings); - // Notifies the browser that the given action has been performed. This is - // aggregated to the user metrics service. - void UserMetricsRecordAction(const std::string& action); - // Sets whether the renderer should report load progress to the browser. void SetReportLoadProgressEnabled(bool enabled); @@ -291,6 +265,12 @@ class RenderView : public RenderWidget, // editable div. bool IsEditableNode(const WebKit::WebNode& node); + void LoadNavigationErrorPage(WebKit::WebFrame* frame, + const WebKit::WebURLRequest& failed_request, + const WebKit::WebURLError& error, + const std::string& html, + bool replace); + // Plugin-related functions -------------------------------------------------- // (See also WebPluginPageDelegate implementation.) @@ -302,6 +282,19 @@ class RenderView : public RenderWidget, void OnMissingPluginStatus(WebPluginDelegateProxy* delegate, int status); + // Create a new NPAPI plugin. + WebKit::WebPlugin* CreateNPAPIPlugin(WebKit::WebFrame* frame, + const WebKit::WebPluginParams& params, + const FilePath& path, + const std::string& mime_type); + + // Create a new Pepper plugin. + WebKit::WebPlugin* CreatePepperPlugin( + WebKit::WebFrame* frame, + const WebKit::WebPluginParams& params, + const FilePath& path, + webkit::ppapi::PluginModule* pepper_module); + // Creates a fullscreen container for a pepper plugin instance. RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer( webkit::ppapi::PluginInstance* plugin); @@ -585,12 +578,6 @@ class RenderView : public RenderWidget, unsigned long long requested_size, WebKit::WebStorageQuotaCallbacks* callbacks); - // WebKit::WebPageSerializerClient implementation ---------------------------- - - virtual void didSerializeDataForFrame(const WebKit::WebURL& frame_url, - const WebKit::WebCString& data, - PageSerializationStatus status); - // webkit_glue::WebPluginPageDelegate implementation ------------------------- virtual webkit::npapi::WebPluginDelegate* CreatePluginDelegate( @@ -723,11 +710,6 @@ class RenderView : public RenderWidget, // Sends a message and runs a nested message loop. bool SendAndRunNestedMessageLoop(IPC::SyncMessage* message); - // Adds search provider from the given OpenSearch description URL as a - // keyword search. - void AddGURLSearchProvider(const GURL& osd_url, - search_provider::OSDDType provider_type); - // Send queued accessibility notifications from the renderer to the browser. void SendPendingAccessibilityNotifications(); @@ -773,7 +755,6 @@ class RenderView : public RenderWidget, void OnDisableScrollbarsForSmallWindows( const gfx::Size& disable_scrollbars_size_limit); void OnDisassociateFromPopupCount(); - void OnDownloadFavicon(int id, const GURL& image_url, int image_size); void OnDragSourceEndedOrMoved(const gfx::Point& client_point, const gfx::Point& screen_point, bool ended, @@ -790,21 +771,12 @@ class RenderView : public RenderWidget, const gfx::Point& screen_pt, WebKit::WebDragOperationsMask operations_allowed); void OnEnablePreferredSizeChangedMode(int flags); - void OnEnableViewSourceMode(); void OnEnumerateDirectoryResponse(int id, const std::vector<FilePath>& paths); void OnExecuteEditCommand(const std::string& name, const std::string& value); void OnFileChooserResponse(const std::vector<FilePath>& paths); void OnFind(int request_id, const string16&, const WebKit::WebFindOptions&); void OnFindReplyAck(); void OnEnableAccessibility(); - void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url); - void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks( - const std::vector<GURL>& links, - const std::vector<FilePath>& local_paths, - const FilePath& local_directory_name); - void OnHandleMessageFromExternalHost(const std::string& message, - const std::string& origin, - const std::string& target); void OnInstallMissingPlugin(); void OnDisplayPrerenderedPage(); void OnMediaPlayerActionAt(const gfx::Point& location, @@ -812,7 +784,6 @@ class RenderView : public RenderWidget, void OnMoveOrResizeStarted(); void OnNavigate(const ViewMsg_Navigate_Params& params); void OnNetworkStateChanged(bool online); - void OnNotifyRendererViewType(ViewType::Type view_type); void OnPaste(); #if defined(OS_MACOSX) void OnPluginImeCompositionCompleted(const string16& text, int plugin_id); @@ -850,7 +821,6 @@ class RenderView : public RenderWidget, void OnStopFinding(const ViewMsg_StopFinding_Params& params); void OnThemeChanged(); void OnUndo(); - void OnUpdateBrowserWindowId(int window_id); void OnUpdateTargetURLAck(); void OnUpdateWebPreferences(const WebPreferences& prefs); #if defined(OS_MACOSX) @@ -859,7 +829,6 @@ class RenderView : public RenderWidget, void OnSelectPopupMenuItem(int selected_index); #endif void OnZoom(PageZoom::Function function); - void OnJavaScriptStressTestControl(int cmd, int param); // Adding a new message handler? Please add it in alphabetical order above // and put it in the same position in the .cc file. @@ -874,10 +843,6 @@ class RenderView : public RenderWidget, const WebKit::WebURLError& original_error, const std::string& html); - // Exposes the DOMAutomationController object that allows JS to send - // information to the browser process. - void BindDOMAutomationController(WebKit::WebFrame* webframe); - // Check whether the preferred size has changed. This is called periodically // by preferred_size_change_timer_. void CheckPreferredSize(); @@ -885,19 +850,6 @@ class RenderView : public RenderWidget, // Resets the |content_blocked_| array. void ClearBlockedContentSettings(); - // Create a new NPAPI plugin. - WebKit::WebPlugin* CreateNPAPIPlugin(WebKit::WebFrame* frame, - const WebKit::WebPluginParams& params, - const FilePath& path, - const std::string& mime_type); - - // Create a new Pepper plugin. - WebKit::WebPlugin* CreatePepperPlugin( - WebKit::WebFrame* frame, - const WebKit::WebPluginParams& params, - const FilePath& path, - webkit::ppapi::PluginModule* pepper_module); - // Sends an IPC notification that the specified content type was blocked. // If the content type requires it, |resource_identifier| names the specific // resource that was blocked (the plugin path in the case of plugins), @@ -905,21 +857,6 @@ class RenderView : public RenderWidget, void DidBlockContentType(ContentSettingsType settings_type, const std::string& resource_identifier); - // This callback is triggered when DownloadFavicon completes, either - // succesfully or with a failure. See DownloadFavicon for more - // details. - void DidDownloadFavicon(webkit_glue::ImageResourceFetcher* fetcher, - const SkBitmap& image); - - // Requests to download a favicon image. When done, the RenderView - // is notified by way of DidDownloadFavicon. Returns true if the - // request was successfully started, false otherwise. id is used to - // uniquely identify the request and passed back to the - // DidDownloadFavicon method. If the image has multiple frames, the - // frame whose size is image_size is returned. If the image doesn't - // have a frame at the specified size, the first is returned. - bool DownloadFavicon(int id, const GURL& image_url, int image_size); - GURL GetAlternateErrorPageURL(const GURL& failed_url, ErrorPageType error_type); @@ -928,14 +865,9 @@ class RenderView : public RenderWidget, WebUIBindings* GetWebUIBindings(); - ExternalHostBindings* GetExternalHostBindings(); - // Should only be called if this object wraps a PluginDocument. WebKit::WebPlugin* GetWebPluginFromPluginDocument(); - // Decodes a data: URL image or returns an empty image in case of failure. - SkBitmap ImageFromDataUrl(const GURL&) const; - // Inserts a string of CSS in a particular frame. |id| can be specified to // give the CSS style element an id, and (if specified) will replace the // element with the same id. @@ -948,12 +880,6 @@ class RenderView : public RenderWidget, WebKit::WebFrame* frame, WebKit::WebNavigationType type); - void LoadNavigationErrorPage(WebKit::WebFrame* frame, - const WebKit::WebURLRequest& failed_request, - const WebKit::WebURLError& error, - const std::string& html, - bool replace); - bool MaybeLoadAlternateErrorPage(WebKit::WebFrame* frame, const WebKit::WebURLError& error, bool replace); @@ -1017,15 +943,6 @@ class RenderView : public RenderWidget, // should be drawn. gfx::Size disable_scrollbars_size_limit_; - // We need to prevent windows from closing themselves with a window.close() - // call while a blocked popup notification is being displayed. We cannot - // synchronously query the Browser process. We cannot wait for the Browser - // process to send a message to us saying that a blocked popup notification - // is being displayed. We instead assume that when we create a window off - // this RenderView, that it is going to be blocked until we get a message - // from the Browser process telling us otherwise. - bool script_can_close_; - // Loading state ------------------------------------------------------------- // True if the top level frame is currently being loaded. @@ -1134,13 +1051,6 @@ class RenderView : public RenderWidget, // View ---------------------------------------------------------------------- - // Type of view attached with RenderView. See view_types.h - ViewType::Type view_type_; - - // Id number of browser window which RenderView is attached to. This is used - // for extensions. - int browser_window_id_; - // Cache the preferred size of the page in order to prevent sending the IPC // when layout() recomputes but doesn't actually change sizes. gfx::Size preferred_size_; @@ -1222,9 +1132,6 @@ class RenderView : public RenderWidget, std::map<int, WebKit::WebFileChooserCompletion*> enumeration_completions_; int enumeration_completion_id_; - // ImageResourceFetchers schedule via DownloadImage. - ImageResourceFetcherList image_fetchers_; - // The SessionStorage namespace that we're assigned to has an ID, and that ID // is passed to us upon creation. WebKit asks for this ID upon first use and // uses it whenever asking the browser process to allocate new storage areas. @@ -1249,17 +1156,10 @@ class RenderView : public RenderWidget, // Shall be cleared as soon as the next key event is processed. EditCommands edit_commands_; - // Allows JS to access DOM automation. The JS object is only exposed when the - // DOM automation bindings are enabled. - scoped_ptr<DomAutomationController> dom_automation_controller_; - // Allows Web UI pages (new tab page, etc.) to talk to the browser. The JS // object is only exposed when Web UI bindings are enabled. scoped_ptr<WebUIBindings> web_ui_bindings_; - // External host exposed through automation controller. - scoped_ptr<ExternalHostBindings> external_host_bindings_; - // The external popup for the currently showing select popup. scoped_ptr<ExternalPopupMenu> external_popup_menu_; diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc index f64c0df..afce5c3 100644 --- a/content/renderer/render_view_browsertest.cc +++ b/content/renderer/render_view_browsertest.cc @@ -4,46 +4,26 @@ #include "base/basictypes.h" -#include "base/file_util.h" #include "base/shared_memory.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "chrome/common/autofill_messages.h" -#include "chrome/common/content_settings.h" #include "chrome/common/render_messages.h" -#include "chrome/renderer/print_web_view_helper.h" #include "chrome/test/render_view_test.h" #include "content/common/native_web_keyboard_event.h" #include "content/common/view_messages.h" #include "net/base/net_errors.h" -#include "printing/image.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/gfx/codec/jpeg_codec.h" -#include "webkit/glue/form_data.h" -#include "webkit/glue/form_field.h" #include "webkit/glue/web_io_operators.h" -using WebKit::WebDocument; using WebKit::WebFrame; -using WebKit::WebInputElement; using WebKit::WebString; using WebKit::WebTextDirection; using WebKit::WebURLError; -using webkit_glue::FormData; -using webkit_glue::FormField; - -namespace { - -const char kPrintWithJSHTML[] = - "<body>Hello<script>window.print()</script>World</body>"; - -} // namespace // Test that we get form state change notifications when input fields change. TEST_F(RenderViewTest, OnNavStateChanged) { @@ -394,186 +374,6 @@ TEST_F(RenderViewTest, OnSetTextDirection) { } } -// Tests that printing pages work and sending and receiving messages through -// that channel all works. -TEST_F(RenderViewTest, OnPrintPages) { - // Lets simulate a print pages with Hello world. - LoadHTML("<body><p>Hello World!</p></body>"); - PrintWebViewHelper::Get(view_)->OnPrintPages(); - - VerifyPageCount(1); - VerifyPagesPrinted(true); -} - -// Duplicate of OnPrintPagesTest only using javascript to print. -TEST_F(RenderViewTest, PrintWithJavascript) { - // HTML contains a call to window.print() - LoadHTML(kPrintWithJSHTML); - - VerifyPageCount(1); - VerifyPagesPrinted(true); -} - -// Tests that the renderer blocks window.print() calls if they occur too -// frequently. -TEST_F(RenderViewTest, BlockScriptInitiatedPrinting) { - // Pretend user will cancel printing. - render_thread_.set_print_dialog_user_response(false); - // Try to print with window.print() a few times. - LoadHTML(kPrintWithJSHTML); - LoadHTML(kPrintWithJSHTML); - LoadHTML(kPrintWithJSHTML); - VerifyPagesPrinted(false); - - // Pretend user will print. (but printing is blocked.) - render_thread_.set_print_dialog_user_response(true); - LoadHTML(kPrintWithJSHTML); - VerifyPagesPrinted(false); - - // Unblock script initiated printing and verify printing works. - PrintWebViewHelper::Get(view_)->ResetScriptedPrintCount(); - render_thread_.printer()->ResetPrinter(); - LoadHTML(kPrintWithJSHTML); - VerifyPageCount(1); - VerifyPagesPrinted(true); -} - -#if defined(OS_WIN) || defined(OS_MACOSX) -// TODO(estade): I don't think this test is worth porting to Linux. We will have -// to rip out and replace most of the IPC code if we ever plan to improve -// printing, and the comment below by sverrir suggests that it doesn't do much -// for us anyway. -TEST_F(RenderViewTest, PrintWithIframe) { - // Document that populates an iframe. - const char html[] = - "<html><body>Lorem Ipsum:" - "<iframe name=\"sub1\" id=\"sub1\"></iframe><script>" - " document.write(frames['sub1'].name);" - " frames['sub1'].document.write(" - " '<p>Cras tempus ante eu felis semper luctus!</p>');" - "</script></body></html>"; - - LoadHTML(html); - - // Find the frame and set it as the focused one. This should mean that that - // the printout should only contain the contents of that frame. - WebFrame* sub1_frame = - view_->webview()->findFrameByName(WebString::fromUTF8("sub1")); - ASSERT_TRUE(sub1_frame); - view_->webview()->setFocusedFrame(sub1_frame); - ASSERT_NE(view_->webview()->focusedFrame(), - view_->webview()->mainFrame()); - - // Initiate printing. - PrintWebViewHelper::Get(view_)->OnPrintPages(); - - // Verify output through MockPrinter. - const MockPrinter* printer(render_thread_.printer()); - ASSERT_EQ(1, printer->GetPrintedPages()); - const printing::Image& image1(printer->GetPrintedPage(0)->image()); - - // TODO(sverrir): Figure out a way to improve this test to actually print - // only the content of the iframe. Currently image1 will contain the full - // page. - EXPECT_NE(0, image1.size().width()); - EXPECT_NE(0, image1.size().height()); -} -#endif - -// Tests if we can print a page and verify its results. -// This test prints HTML pages into a pseudo printer and check their outputs, -// i.e. a simplified version of the PrintingLayoutTextTest UI test. -namespace { -// Test cases used in this test. -struct TestPageData { - const char* page; - size_t printed_pages; - int width; - int height; - const char* checksum; - const wchar_t* file; -}; - -const TestPageData kTestPages[] = { - {"<html>" - "<head>" - "<meta" - " http-equiv=\"Content-Type\"" - " content=\"text/html; charset=utf-8\"/>" - "<title>Test 1</title>" - "</head>" - "<body style=\"background-color: white;\">" - "<p style=\"font-family: arial;\">Hello World!</p>" - "</body>", -#if defined(OS_MACOSX) - // Mac printing code compensates for the WebKit scale factor while generating - // the metafile, so we expect smaller pages. - 1, 540, 720, -#else - 1, 675, 900, -#endif - NULL, - NULL, - }, -}; -} // namespace - -// TODO(estade): need to port MockPrinter to get this on Linux. This involves -// hooking up Cairo to read a pdf stream, or accessing the cairo surface in the -// metafile directly. -#if defined(OS_WIN) || defined(OS_MACOSX) -TEST_F(RenderViewTest, PrintLayoutTest) { - bool baseline = false; - - EXPECT_TRUE(render_thread_.printer() != NULL); - for (size_t i = 0; i < arraysize(kTestPages); ++i) { - // Load an HTML page and print it. - LoadHTML(kTestPages[i].page); - PrintWebViewHelper::Get(view_)->OnPrintPages(); - - // MockRenderThread::Send() just calls MockRenderThread::OnMsgReceived(). - // So, all IPC messages sent in the above RenderView::OnPrintPages() call - // has been handled by the MockPrinter object, i.e. this printing job - // has been already finished. - // So, we can start checking the output pages of this printing job. - // Retrieve the number of pages actually printed. - size_t pages = render_thread_.printer()->GetPrintedPages(); - EXPECT_EQ(kTestPages[i].printed_pages, pages); - - // Retrieve the width and height of the output page. - int width = render_thread_.printer()->GetWidth(0); - int height = render_thread_.printer()->GetHeight(0); - - // Check with margin for error. This has been failing with a one pixel - // offset on our buildbot. - const int kErrorMargin = 5; // 5% - EXPECT_GT(kTestPages[i].width * (100 + kErrorMargin) / 100, width); - EXPECT_LT(kTestPages[i].width * (100 - kErrorMargin) / 100, width); - EXPECT_GT(kTestPages[i].height * (100 + kErrorMargin) / 100, height); - EXPECT_LT(kTestPages[i].height* (100 - kErrorMargin) / 100, height); - - // Retrieve the checksum of the bitmap data from the pseudo printer and - // compare it with the expected result. - std::string bitmap_actual; - EXPECT_TRUE(render_thread_.printer()->GetBitmapChecksum(0, &bitmap_actual)); - if (kTestPages[i].checksum) - EXPECT_EQ(kTestPages[i].checksum, bitmap_actual); - - if (baseline) { - // Save the source data and the bitmap data into temporary files to - // create base-line results. - FilePath source_path; - file_util::CreateTemporaryFile(&source_path); - render_thread_.printer()->SaveSource(0, source_path); - - FilePath bitmap_path; - file_util::CreateTemporaryFile(&bitmap_path); - render_thread_.printer()->SaveBitmap(0, bitmap_path); - } - } -} -#endif - // Test that we can receive correct DOM events when we send input events // through the RenderWidget::OnHandleInputEvent() function. TEST_F(RenderViewTest, OnHandleKeyboardEvent) { @@ -1027,213 +827,3 @@ TEST_F(RenderViewTest, UpdateTargetURLWithInvalidURL) { view_->setMouseOverURL(WebKit::WebURL(invalid_gurl)); EXPECT_EQ(invalid_gurl, view_->target_url_); } - -TEST_F(RenderViewTest, SendForms) { - // Don't want any delay for form state sync changes. This will still post a - // message so updates will get coalesced, but as soon as we spin the message - // loop, it will generate an update. - view_->set_send_content_state_immediately(true); - - LoadHTML("<form method=\"POST\">" - " <input type=\"text\" id=\"firstname\"/>" - " <input type=\"text\" id=\"middlename\" autoComplete=\"off\"/>" - " <input type=\"hidden\" id=\"lastname\"/>" - " <select id=\"state\"/>" - " <option>?</option>" - " <option>California</option>" - " <option>Texas</option>" - " </select>" - "</form>"); - - // Verify that "FormsSeen" sends the expected number of fields. - ProcessPendingMessages(); - const IPC::Message* message = render_thread_.sink().GetFirstMessageMatching( - AutofillHostMsg_FormsSeen::ID); - ASSERT_NE(static_cast<IPC::Message*>(NULL), message); - AutofillHostMsg_FormsSeen::Param params; - AutofillHostMsg_FormsSeen::Read(message, ¶ms); - const std::vector<FormData>& forms = params.a; - ASSERT_EQ(1UL, forms.size()); - ASSERT_EQ(3UL, forms[0].fields.size()); - EXPECT_TRUE(forms[0].fields[0].StrictlyEqualsHack( - FormField(string16(), - ASCIIToUTF16("firstname"), - string16(), - ASCIIToUTF16("text"), - WebInputElement::defaultMaxLength(), - false))) << forms[0].fields[0]; - EXPECT_TRUE(forms[0].fields[1].StrictlyEqualsHack( - FormField(string16(), - ASCIIToUTF16("middlename"), - string16(), - ASCIIToUTF16("text"), - WebInputElement::defaultMaxLength(), - false))) << forms[0].fields[1]; - EXPECT_TRUE(forms[0].fields[2].StrictlyEqualsHack( - FormField(string16(), - ASCIIToUTF16("state"), - ASCIIToUTF16("?"), - ASCIIToUTF16("select-one"), - 0, - false))) << forms[0].fields[2]; - - // Verify that |didAcceptAutoFillSuggestion()| sends the expected number of - // fields. - WebFrame* web_frame = GetMainFrame(); - WebDocument document = web_frame->document(); - WebInputElement firstname = - document.getElementById("firstname").to<WebInputElement>(); - - // Accept suggestion that contains a label. Labeled items indicate Autofill - // as opposed to Autocomplete. We're testing this distinction below with - // the |AutofillHostMsg_FillAutofillFormData::ID| message. - autofill_agent_->didAcceptAutoFillSuggestion( - firstname, - WebKit::WebString::fromUTF8("Johnny"), - WebKit::WebString::fromUTF8("Home"), - 1, - -1); - - ProcessPendingMessages(); - const IPC::Message* message2 = render_thread_.sink().GetUniqueMessageMatching( - AutofillHostMsg_FillAutofillFormData::ID); - ASSERT_NE(static_cast<IPC::Message*>(NULL), message2); - AutofillHostMsg_FillAutofillFormData::Param params2; - AutofillHostMsg_FillAutofillFormData::Read(message2, ¶ms2); - const FormData& form2 = params2.b; - ASSERT_EQ(3UL, form2.fields.size()); - EXPECT_TRUE(form2.fields[0].StrictlyEqualsHack( - FormField(string16(), - ASCIIToUTF16("firstname"), - string16(), - ASCIIToUTF16("text"), - WebInputElement::defaultMaxLength(), - false))) << form2.fields[0]; - EXPECT_TRUE(form2.fields[1].StrictlyEqualsHack( - FormField(string16(), - ASCIIToUTF16("middlename"), - string16(), - ASCIIToUTF16("text"), - WebInputElement::defaultMaxLength(), - false))) << form2.fields[1]; - EXPECT_TRUE(form2.fields[2].StrictlyEqualsHack( - FormField(string16(), - ASCIIToUTF16("state"), - ASCIIToUTF16("?"), - ASCIIToUTF16("select-one"), - 0, - false))) << form2.fields[2]; -} - -TEST_F(RenderViewTest, FillFormElement) { - // Don't want any delay for form state sync changes. This will still post a - // message so updates will get coalesced, but as soon as we spin the message - // loop, it will generate an update. - view_->set_send_content_state_immediately(true); - - LoadHTML("<form method=\"POST\">" - " <input type=\"text\" id=\"firstname\"/>" - " <input type=\"text\" id=\"middlename\"/>" - "</form>"); - - // Verify that "FormsSeen" isn't sent, as there are too few fields. - ProcessPendingMessages(); - const IPC::Message* message = render_thread_.sink().GetFirstMessageMatching( - AutofillHostMsg_FormsSeen::ID); - ASSERT_EQ(static_cast<IPC::Message*>(NULL), message); - - // Verify that |didAcceptAutoFillSuggestion()| sets the value of the expected - // field. - WebFrame* web_frame = GetMainFrame(); - WebDocument document = web_frame->document(); - WebInputElement firstname = - document.getElementById("firstname").to<WebInputElement>(); - WebInputElement middlename = - document.getElementById("middlename").to<WebInputElement>(); - middlename.setAutofilled(true); - - // Accept a suggestion in a form that has been auto-filled. This triggers - // the direct filling of the firstname element with value parameter. - autofill_agent_->didAcceptAutoFillSuggestion(firstname, - WebString::fromUTF8("David"), - WebString(), - 0, - 0); - - ProcessPendingMessages(); - const IPC::Message* message2 = render_thread_.sink().GetUniqueMessageMatching( - AutofillHostMsg_FillAutofillFormData::ID); - - // No message should be sent in this case. |firstname| is filled directly. - ASSERT_EQ(static_cast<IPC::Message*>(NULL), message2); - EXPECT_EQ(firstname.value(), WebKit::WebString::fromUTF8("David")); -} - -// Tests that we send the right translatable for a page and that we respect the -// "no translate" meta-tag. -TEST_F(RenderViewTest, TranslatablePage) { - // Suppress the normal delay that occurs when the page is loaded before which - // the renderer sends the page contents to the browser. - view_->set_send_content_state_immediately(true); - - LoadHTML("<html><body>A random page with random content.</body></html>"); - ProcessPendingMessages(); - const IPC::Message* message = render_thread_.sink().GetUniqueMessageMatching( - ViewHostMsg_TranslateLanguageDetermined::ID); - ASSERT_NE(static_cast<IPC::Message*>(NULL), message); - ViewHostMsg_TranslateLanguageDetermined::Param params; - ViewHostMsg_TranslateLanguageDetermined::Read(message, ¶ms); - EXPECT_TRUE(params.b); // Translatable should be true. - render_thread_.sink().ClearMessages(); - - // Now the page specifies the META tag to prevent translation. - LoadHTML("<html><head><meta name=\"google\" value=\"notranslate\"></head>" - "<body>A random page with random content.</body></html>"); - ProcessPendingMessages(); - message = render_thread_.sink().GetUniqueMessageMatching( - ViewHostMsg_TranslateLanguageDetermined::ID); - ASSERT_NE(static_cast<IPC::Message*>(NULL), message); - ViewHostMsg_TranslateLanguageDetermined::Read(message, ¶ms); - EXPECT_FALSE(params.b); // Translatable should be false. - render_thread_.sink().ClearMessages(); - - // Try the alternate version of the META tag (content instead of value). - LoadHTML("<html><head><meta name=\"google\" content=\"notranslate\"></head>" - "<body>A random page with random content.</body></html>"); - ProcessPendingMessages(); - message = render_thread_.sink().GetUniqueMessageMatching( - ViewHostMsg_TranslateLanguageDetermined::ID); - ASSERT_NE(static_cast<IPC::Message*>(NULL), message); - ViewHostMsg_TranslateLanguageDetermined::Read(message, ¶ms); - EXPECT_FALSE(params.b); // Translatable should be false. -} - -// Tests that the language meta tag takes precedence over the CLD when reporting -// the page's language. -TEST_F(RenderViewTest, LanguageMetaTag) { - // Suppress the normal delay that occurs when the page is loaded before which - // the renderer sends the page contents to the browser. - view_->set_send_content_state_immediately(true); - - LoadHTML("<html><head><meta http-equiv=\"content-language\" content=\"es\">" - "</head><body>A random page with random content.</body></html>"); - ProcessPendingMessages(); - const IPC::Message* message = render_thread_.sink().GetUniqueMessageMatching( - ViewHostMsg_TranslateLanguageDetermined::ID); - ASSERT_NE(static_cast<IPC::Message*>(NULL), message); - ViewHostMsg_TranslateLanguageDetermined::Param params; - ViewHostMsg_TranslateLanguageDetermined::Read(message, ¶ms); - EXPECT_EQ("es", params.a); - render_thread_.sink().ClearMessages(); - - // Makes sure we support multiple languages specified. - LoadHTML("<html><head><meta http-equiv=\"content-language\" " - "content=\" fr , es,en \">" - "</head><body>A random page with random content.</body></html>"); - ProcessPendingMessages(); - message = render_thread_.sink().GetUniqueMessageMatching( - ViewHostMsg_TranslateLanguageDetermined::ID); - ASSERT_NE(static_cast<IPC::Message*>(NULL), message); - ViewHostMsg_TranslateLanguageDetermined::Read(message, ¶ms); - EXPECT_EQ("fr", params.a); -} diff --git a/content/renderer/render_view_browsertest_mac.mm b/content/renderer/render_view_browsertest_mac.mm index 56fe589..174a02e 100644 --- a/content/renderer/render_view_browsertest_mac.mm +++ b/content/renderer/render_view_browsertest_mac.mm @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/string_util.h" #include "base/string16.h" -#include "chrome/common/render_messages.h" #include "chrome/test/render_view_test.h" #include "content/common/native_web_keyboard_event.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/content/renderer/render_view_observer.h b/content/renderer/render_view_observer.h index a1ddafd..cdb0b51 100644 --- a/content/renderer/render_view_observer.h +++ b/content/renderer/render_view_observer.h @@ -34,6 +34,7 @@ class RenderViewObserver : public IPC::Channel::Listener, // These match the WebKit API notifications virtual void DidStartLoading() {} virtual void DidStopLoading() {} + virtual void DidChangeIcons(WebKit::WebFrame* frame) {} virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) {} virtual void DidFailLoad(WebKit::WebFrame* frame, const WebKit::WebURLError& error) {} @@ -43,6 +44,7 @@ class RenderViewObserver : public IPC::Channel::Listener, const WebKit::WebURLError& error) {} virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame, bool is_new_navigation) {} + virtual void DidClearWindowObject(WebKit::WebFrame* frame) {} virtual void WillPerformClientRedirect( WebKit::WebFrame* frame, const WebKit::WebURL& from, const WebKit::WebURL& to, double interval, double fire_time) {} diff --git a/content/renderer/render_widget_unittest.cc b/content/renderer/render_widget_unittest.cc deleted file mode 100644 index 0998c6a..0000000 --- a/content/renderer/render_widget_unittest.cc +++ /dev/null @@ -1,61 +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 "testing/gtest/include/gtest/gtest.h" - -#include "base/memory/ref_counted.h" -#include "chrome/renderer/mock_render_process.h" -#include "chrome/renderer/mock_render_thread.h" -#include "content/renderer/render_thread.h" -#include "content/renderer/render_widget.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" - -namespace { - -const int32 kRouteId = 5; -const int32 kOpenerId = 7; - -class RenderWidgetTest : public testing::Test { - public: - - protected: - MessageLoop msg_loop_; - MockRenderThread render_thread_; - - // The widget, each test should verify this is non-NULL before continuing. - scoped_refptr<RenderWidget> widget_; - - private: - // testing::Test - virtual void SetUp() { - mock_process_.reset(new MockRenderProcess); - render_thread_.set_routing_id(kRouteId); - widget_ = RenderWidget::Create(kOpenerId, &render_thread_, - WebKit::WebPopupTypeNone); - ASSERT_TRUE(widget_); - } - virtual void TearDown() { - widget_ = NULL; - mock_process_.reset(); - } - - scoped_ptr<MockRenderProcess> mock_process_; -}; - -TEST_F(RenderWidgetTest, CreateAndCloseWidget) { - // After the RenderWidget it must have sent a message to the render thread - // that sets the opener id. - EXPECT_EQ(kOpenerId, render_thread_.opener_id()); - ASSERT_TRUE(render_thread_.has_widget()); - - // Now simulate a close of the Widget. - render_thread_.SendCloseMessage(); - EXPECT_FALSE(render_thread_.has_widget()); - - // Run the loop so the release task from the renderwidget executes. - msg_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask()); - msg_loop_.Run(); -} - -} // namespace diff --git a/content/worker/worker_uitest.cc b/content/worker/worker_uitest.cc index f3b2c7c..73e20ac 100644 --- a/content/worker/worker_uitest.cc +++ b/content/worker/worker_uitest.cc @@ -7,12 +7,12 @@ #include "base/test/test_timeouts.h" #include "base/threading/platform_thread.h" #include "chrome/app/chrome_command_ids.h" -#include "chrome/common/url_constants.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/ui/ui_layout_test.h" #include "chrome/test/ui_test_utils.h" #include "content/browser/worker_host/worker_service.h" +#include "content/common/url_constants.h" #include "net/test/test_server.h" namespace { |