summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xchrome/renderer/render_view.cc106
-rw-r--r--chrome/renderer/render_view.h593
2 files changed, 363 insertions, 336 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 85921a0..c9e89c52 100755
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -215,6 +215,8 @@ using WebKit::WebWindowFeatures;
//-----------------------------------------------------------------------------
+typedef std::map<WebKit::WebView*, RenderView*> ViewMap;
+
// define to write the time necessary for thumbnail/DOM text retrieval,
// respectively, into the system debug log
// #define TIME_TEXT_RETRIEVAL
@@ -348,6 +350,37 @@ static bool CrossesExtensionExtents(WebFrame* frame, const GURL& new_url) {
return (old_extension != new_extension);
}
+// Returns the ISO 639_1 language code of the specified |text|, or 'unknown'
+// if it failed.
+//
+// Note this only works on Windows at this time. It always returns 'unknown'
+// on other platforms.
+static std::string DetermineTextLanguage(const std::wstring& text) {
+ // Text with less than 100 bytes will probably not provide good results.
+ // Report it as unknown language.
+ if (text.length() < 100)
+ return RenderView::kUnknownLanguageCode;
+
+ std::string language = RenderView::kUnknownLanguageCode;
+ int num_languages = 0;
+ bool is_reliable = false;
+ string16 input = WideToUTF16(text);
+ Language cld_language =
+ DetectLanguageOfUnicodeText(NULL, input.c_str(), true, &is_reliable,
+ &num_languages, NULL);
+ if (is_reliable && cld_language != NUM_LANGUAGES &&
+ cld_language != UNKNOWN_LANGUAGE && cld_language != TG_UNKNOWN_LANGUAGE) {
+ // We should not use LanguageCode_ISO_639_1 because it does not cover all
+ // the languages CLD can detect. As a result, it'll return the invalid
+ // language code for tradtional Chinese among others.
+ // |LanguageCodeWithDialect| will go through ISO 639-1, ISO-639-2 and
+ // 'other' tables to do the 'right' thing. In addition, it'll return zh-CN
+ // for Simplified Chinese.
+ language = LanguageCodeWithDialects(cld_language);
+ }
+ return language;
+}
+
///////////////////////////////////////////////////////////////////////////////
int32 RenderView::next_page_id_ = 1;
@@ -366,44 +399,42 @@ RenderView::RenderView(RenderThreadBase* render_thread,
const WebPreferences& webkit_preferences,
int64 session_storage_namespace_id)
: RenderWidget(render_thread, WebKit::WebPopupTypeNone),
+ webkit_preferences_(webkit_preferences),
+ send_content_state_immediately_(false),
enabled_bindings_(0),
- target_url_status_(TARGET_NONE),
+ send_preferred_size_changes_(false),
+ script_can_close_(true),
is_loading_(false),
navigation_gesture_(NavigationGestureUnknown),
+ opened_by_user_gesture_(true),
+ opener_suppressed_(false),
page_id_(-1),
last_page_id_sent_to_browser_(-1),
last_indexed_page_id_(-1),
- opened_by_user_gesture_(true),
- opener_suppressed_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
- devtools_agent_(NULL),
- devtools_client_(NULL),
+ last_top_level_navigation_page_id_(-1),
history_list_offset_(-1),
history_list_length_(0),
has_unload_listener_(false),
- decrement_shared_popup_at_destruction_(false),
- autofill_query_id_(0),
- script_can_close_(true),
- spelling_panel_visible_(false),
- send_content_state_immediately_(false),
- send_preferred_size_changes_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- notification_provider_(new NotificationProvider(this))),
- view_type_(ViewType::INVALID),
- browser_window_id_(-1),
- last_top_level_navigation_page_id_(-1),
#if defined(OS_MACOSX)
has_document_tag_(false),
#endif
document_tag_(0),
- webkit_preferences_(webkit_preferences),
- session_storage_namespace_id_(session_storage_namespace_id),
- ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)),
- ALLOW_THIS_IN_INITIALIZER_LIST(translate_helper_(this)),
cross_origin_access_count_(0),
same_origin_access_count_(0),
+ target_url_status_(TARGET_NONE),
+ spelling_panel_visible_(false),
+ view_type_(ViewType::INVALID),
+ browser_window_id_(-1),
+ autofill_query_id_(0),
+ autofill_action_(AUTOFILL_NONE),
ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)),
- autofill_action_(AUTOFILL_NONE) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(translate_helper_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(
+ notification_provider_(new NotificationProvider(this))),
+ session_storage_namespace_id_(session_storage_namespace_id),
+ decrement_shared_popup_at_destruction_(false) {
ClearBlockedContentSettings();
}
@@ -1650,6 +1681,10 @@ void RenderView::printPage(WebFrame* frame) {
Print(frame, true);
}
+WebKit::WebNotificationPresenter* RenderView::notificationPresenter() {
+ return notification_provider_.get();
+}
+
void RenderView::didStartLoading() {
if (is_loading_) {
DLOG(WARNING) << "didStartLoading called while loading";
@@ -3555,33 +3590,6 @@ void RenderView::OnFindReplyAck() {
}
}
-// static
-std::string RenderView::DetermineTextLanguage(const std::wstring& text) {
- // Text with less than 100 bytes will probably not provide good results.
- // Report it as unknown language.
- if (text.length() < 100)
- return kUnknownLanguageCode;
-
- std::string language = kUnknownLanguageCode;
- int num_languages = 0;
- bool is_reliable = false;
- string16 input = WideToUTF16(text);
- Language cld_language =
- DetectLanguageOfUnicodeText(NULL, input.c_str(), true, &is_reliable,
- &num_languages, NULL);
- if (is_reliable && cld_language != NUM_LANGUAGES &&
- cld_language != UNKNOWN_LANGUAGE && cld_language != TG_UNKNOWN_LANGUAGE) {
- // We should not use LanguageCode_ISO_639_1 because it does not cover all
- // the languages CLD can detect. As a result, it'll return the invalid
- // language code for tradtional Chinese among others.
- // |LanguageCodeWithDialect| will go through ISO 639-1, ISO-639-2 and
- // 'other' tables to do the 'right' thing. In addition, it'll return zh-CN
- // for Simplified Chinese.
- language = LanguageCodeWithDialects(cld_language);
- }
- return language;
-}
-
bool RenderView::AllowContentType(ContentSettingsType settings_type) {
// CONTENT_SETTING_ASK is only valid for cookies.
return current_content_settings_.settings[settings_type] !=
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 84586e2..4a06534 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -196,9 +196,6 @@ class RenderView : public RenderWidget,
return webkit_preferences_;
}
- // Whether content state (such as form state and scroll position) should be
- // sent to the browser immediately. This is normally false, but set to true
- // by some tests.
void set_send_content_state_immediately(bool value) {
send_content_state_immediately_ = value;
}
@@ -319,11 +316,10 @@ class RenderView : public RenderWidget,
unsigned quota);
virtual void didAddMessageToConsole(
const WebKit::WebConsoleMessage& message,
- const WebKit::WebString& source_name, unsigned source_line);
+ const WebKit::WebString& source_name,
+ unsigned source_line);
virtual void printPage(WebKit::WebFrame* frame);
- virtual WebKit::WebNotificationPresenter* notificationPresenter() {
- return notification_provider_.get();
- }
+ virtual WebKit::WebNotificationPresenter* notificationPresenter();
virtual void didStartLoading();
virtual void didStopLoading();
virtual bool isSmartInsertDeleteEnabled();
@@ -333,7 +329,8 @@ class RenderView : public RenderWidget,
virtual void didExecuteCommand(const WebKit::WebString& command_name);
virtual bool handleCurrentKeyboardEvent();
virtual void spellCheck(const WebKit::WebString& text,
- int& offset, int& length);
+ int& offset,
+ int& length);
virtual WebKit::WebString autoCorrectWord(
const WebKit::WebString& misspelled_word);
virtual void showSpellingUI(bool show);
@@ -389,9 +386,6 @@ class RenderView : public RenderWidget,
const WebKit::WebString& value,
const WebKit::WebString& label);
virtual void didClearAutoFillSelection(const WebKit::WebNode& node);
- virtual WebKit::WebNotificationPresenter* GetNotificationPresenter() {
- return notification_provider_.get();
- }
virtual WebKit::WebGeolocationService* geolocationService();
// WebKit::WebFrameClient implementation -------------------------------------
@@ -777,7 +771,8 @@ class RenderView : public RenderWidget,
void OnSetAltErrorPageURL(const GURL& gurl);
void OnSetBackground(const SkBitmap& background);
void OnSetContentSettingsForLoadingURL(
- const GURL& url, const ContentSettings& content_settings);
+ const GURL& url,
+ const ContentSettings& content_settings);
void OnSetDOMUIProperty(const std::string& name, const std::string& value);
void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
void OnSetInitialFocus(bool reverse);
@@ -810,29 +805,38 @@ class RenderView : public RenderWidget,
// Adding a new message handler? Please add it in alphabetical order above
// and put it in the same position in the .cc file.
- // --------------------------------------------------------------------------
+ // Misc private functions ----------------------------------------------------
+
+ // Helper method that returns if the user wants to block content of type
+ // |content_type|.
+ bool AllowContentType(ContentSettingsType settings_type);
+
+ void AltErrorPageFinished(WebKit::WebFrame* frame,
+ 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);
- // 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.
- void InsertCSS(const std::wstring& frame_xpath,
- const std::string& css,
- const std::string& id);
+ // Check whether the preferred size has changed. This is called periodically
+ // by preferred_size_change_timer_.
+ void CheckPreferredSize();
+
+ // Resets the |content_blocked_| array.
+ void ClearBlockedContentSettings();
// Creates DevToolsClient and sets up JavaScript bindings for developer tools
// UI that is going to be hosted by this RenderView.
void CreateDevToolsClient();
- // Locates a sub frame with given xpath
- WebKit::WebFrame* GetChildFrame(const std::wstring& frame_xpath) const;
+ // Sends an IPC notification that the specified content type was blocked.
+ void DidBlockContentType(ContentSettingsType settings_type);
- // Get all child frames of parent_frame, returned by frames_vector.
- bool GetAllChildFrames(WebKit::WebFrame* parent_frame,
- std::vector<WebKit::WebFrame* >* frames_vector) const;
+ // This callback is triggered when DownloadImage completes, either
+ // succesfully or with a failure. See DownloadImage for more details.
+ void DidDownloadImage(webkit_glue::ImageResourceFetcher* fetcher,
+ const SkBitmap& image);
// Requests to download an image. When done, the RenderView is
// notified by way of DidDownloadImage. Returns true if the request was
@@ -842,38 +846,74 @@ class RenderView : public RenderWidget,
// image doesn't have a frame at the specified size, the first is returned.
bool DownloadImage(int id, const GURL& image_url, int image_size);
- // This callback is triggered when DownloadImage completes, either
- // succesfully or with a failure. See DownloadImage for more details.
- void DidDownloadImage(webkit_glue::ImageResourceFetcher* fetcher,
- const SkBitmap& image);
+ void DumpLoadHistograms() const;
- // Check whether the preferred size has changed. This is called periodically
- // by preferred_size_change_timer_.
- void CheckPreferredSize();
+ // Initializes the document_tag_ member if necessary.
+ void EnsureDocumentTag();
- // Alternate error page helpers.
- GURL GetAlternateErrorPageURL(
- const GURL& failed_url, ErrorPageType error_type);
- bool MaybeLoadAlternateErrorPage(
- WebKit::WebFrame* frame, const WebKit::WebURLError& error, bool replace);
- std::string GetAltHTMLForTemplate(
- const DictionaryValue& error_strings, int template_resource_id) const;
- void AltErrorPageFinished(
- WebKit::WebFrame* frame, const WebKit::WebURLError& original_error,
- const std::string& html);
+ // Backend for the IPC Message ExecuteCode in addition to being used
+ // internally by other RenderView functions.
+ void ExecuteCodeImpl(WebKit::WebFrame* frame,
+ const ViewMsg_ExecuteCode_Params& params);
+
+ // Get all child frames of parent_frame, returned by frames_vector.
+ bool GetAllChildFrames(WebKit::WebFrame* parent_frame,
+ std::vector<WebKit::WebFrame* >* frames_vector) const;
+
+ GURL GetAlternateErrorPageURL(const GURL& failed_url,
+ ErrorPageType error_type);
+
+ std::string GetAltHTMLForTemplate(const DictionaryValue& error_strings,
+ int template_resource_id) const;
+
+ // Locates a sub frame with given xpath
+ WebKit::WebFrame* GetChildFrame(const std::wstring& frame_xpath) const;
+
+ // Should only be called if this object wraps a PluginDocument.
+ webkit_glue::WebPluginDelegate* GetDelegateForPluginDocument();
// Decodes a data: URL image or returns an empty image in case of failure.
SkBitmap ImageFromDataUrl(const GURL&) const;
- void DumpLoadHistograms() const;
+ // Inject toolstrip CSS for extension moles and toolstrips.
+ void InjectToolstripCSS();
+
+ // 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.
+ void InsertCSS(const std::wstring& frame_xpath,
+ const std::string& css,
+ const std::string& id);
+
+ // Returns false unless this is a top-level navigation that crosses origins.
+ bool IsNonLocalTopLevelNavigation(const GURL& url,
+ 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);
// Logs the navigation state to the console.
void LogNavigationState(const NavigationState* state,
const WebKit::WebDataSource* ds) const;
- // Dispatches the current navigation state to the browser. Called on a
- // periodic timer so we don't send too many messages.
- void SyncNavigationState();
+ bool MaybeLoadAlternateErrorPage(WebKit::WebFrame* frame,
+ const WebKit::WebURLError& error,
+ bool replace);
+
+ void Print(WebKit::WebFrame* frame, bool script_initiated);
+
+ // Queries the AutoFillManager for form data for the form containing |node|.
+ // |value| is the current text in the field, and |label| is the selected
+ // profile label. |action| specifies whether to Fill or Preview the values
+ // returned from the AutoFillManager.
+ void QueryAutoFillFormData(const WebKit::WebNode& node,
+ const WebKit::WebString& value,
+ const WebKit::WebString& label,
+ AutoFillAction action);
// Scans the given frame for forms and sends them up to the browser.
void SendForms(WebKit::WebFrame* frame);
@@ -882,7 +922,12 @@ class RenderView : public RenderWidget,
// If |only_visible| is true, only forms visible in the layout are sent
void SendPasswordForms(WebKit::WebFrame* frame, bool only_visible);
- void Print(WebKit::WebFrame* frame, bool script_initiated);
+ // Starts nav_state_sync_timer_ if it isn't already running.
+ void StartNavStateSyncTimerIfNecessary();
+
+ // Dispatches the current navigation state to the browser. Called on a
+ // periodic timer so we don't send too many messages.
+ void SyncNavigationState();
#if defined(OS_LINUX)
void UpdateFontRenderingFromRendererPrefs();
@@ -890,111 +935,77 @@ class RenderView : public RenderWidget,
void UpdateFontRenderingFromRendererPrefs() {}
#endif
- // Inject toolstrip CSS for extension moles and toolstrips.
- void InjectToolstripCSS();
-
- // Initializes the document_tag_ member if necessary.
- void EnsureDocumentTag();
-
// Update the target url and tell the browser that the target URL has changed.
// If |url| is empty, show |fallback_url|.
void UpdateTargetURL(const GURL& url, const GURL& fallback_url);
- // Starts nav_state_sync_timer_ if it isn't already running.
- void StartNavStateSyncTimerIfNecessary();
-
- // Returns the ISO 639_1 language code of the specified |text|, or 'unknown'
- // if it failed.
- // Note this only works on Windows at this time. It always returns 'unknown'
- // on other platforms.
- static std::string DetermineTextLanguage(const std::wstring& text);
-
- // Helper method that returns if the user wants to block content of type
- // |content_type|.
- bool AllowContentType(ContentSettingsType settings_type);
-
- // Sends an IPC notification that the specified content type was blocked.
- void DidBlockContentType(ContentSettingsType settings_type);
-
- // Resets the |content_blocked_| array.
- void ClearBlockedContentSettings();
-
- // Should only be called if this object wraps a PluginDocument.
- webkit_glue::WebPluginDelegate* GetDelegateForPluginDocument();
+ // ---------------------------------------------------------------------------
+ // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
+ // it in the same order in the .cc file as it was in the header.
+ // ---------------------------------------------------------------------------
- // Returns false unless this is a top-level navigation that
- // crosses origins.
- bool IsNonLocalTopLevelNavigation(const GURL& url,
- WebKit::WebFrame* frame,
- WebKit::WebNavigationType type);
+ // Settings ------------------------------------------------------------------
- // Queries the AutoFillManager for form data for the form containing |node|.
- // |value| is the current text in the field, and |label| is the selected
- // profile label. |action| specifies whether to Fill or Preview the values
- // returned from the AutoFillManager.
- void QueryAutoFillFormData(const WebKit::WebNode& node,
- const WebKit::WebString& value,
- const WebKit::WebString& label,
- AutoFillAction action);
+ WebPreferences webkit_preferences_;
+ RendererPreferences renderer_preferences_;
- void LoadNavigationErrorPage(WebKit::WebFrame* frame,
- const WebKit::WebURLRequest& failed_request,
- const WebKit::WebURLError& error,
- const std::string& html,
- bool replace);
+ HostContentSettings host_content_settings_;
+ HostZoomLevels host_zoom_levels_;
- // Backend for the IPC Message ExecuteCode in addition to being used
- // internally by other RenderView functions.
- void ExecuteCodeImpl(WebKit::WebFrame* frame,
- const ViewMsg_ExecuteCode_Params& params);
+ // Whether content state (such as form state and scroll position) should be
+ // sent to the browser immediately. This is normally false, but set to true
+ // by some tests.
+ bool send_content_state_immediately_;
- // ---------------------------------------------------------------------------
+ // Stores if loading of images, scripts, and plugins is allowed.
+ ContentSettings current_content_settings_;
// Bitwise-ORed set of extra bindings that have been enabled. See
// BindingsPolicy for details.
int enabled_bindings_;
- // DOM Automation Controller CppBoundClass.
- DomAutomationController dom_automation_controller_;
+ // The alternate error page URL, if one exists.
+ GURL alternate_error_page_url_;
- // Chrome page<->browser messaging CppBoundClass.
- DOMUIBindings dom_ui_bindings_;
+ // If true, we send IPC messages when |preferred_size_| changes.
+ bool send_preferred_size_changes_;
- // External host exposed through automation controller.
- ExternalHostBindings external_host_bindings_;
+ // If non-empty, and |send_preferred_size_changes_| is true, disable drawing
+ // scroll bars on windows smaller than this size. Used for windows that the
+ // browser resizes to the size of the content, such as browser action popups.
+ // If a render view is set to the minimum size of its content, webkit may add
+ // scroll bars. This makes sense for fixed sized windows, but it does not
+ // make sense when the size of the view was chosen to fit the content.
+ // This setting ensures that no scroll bars are drawn. The size limit exists
+ // because if the view grows beyond a size known to the browser, scroll bars
+ // should be drawn.
+ gfx::Size disable_scrollbars_size_limit_;
- // The last gotten main frame's encoding.
- std::string last_encoding_name_;
+ // 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_;
- // The URL we show the user in the status bar. We use this to
- // determine if we want to send a new one (we do not need to send
- // duplicates). It will be equal to either |mouse_over_url_| or |focus_url_|,
- // depending on which was updated last.
- GURL target_url_;
- // The URL the user's mouse is hovering over.
- GURL mouse_over_url_;
- // The URL that has keyboard focus.
- GURL focus_url_;
+ // Loading state -------------------------------------------------------------
- // The state of our target_url transmissions. When we receive a request to
- // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK
- // comes back - if a new request comes in before the ACK, we store the new
- // URL in pending_target_url_ and set the status to TARGET_PENDING. If an
- // ACK comes back and we are in TARGET_PENDING, we send the stored URL and
- // revert to TARGET_INFLIGHT.
- //
- // We don't need a queue of URLs to send, as only the latest is useful.
- enum {
- TARGET_NONE,
- TARGET_INFLIGHT, // We have a request in-flight, waiting for an ACK
- TARGET_PENDING // INFLIGHT + we have a URL waiting to be sent
- } target_url_status_;
+ // True if the top level frame is currently being loaded.
+ bool is_loading_;
- // The next target URL we want to send to the browser.
- GURL pending_target_url_;
+ // The gesture that initiated the current navigation.
+ NavigationGesture navigation_gesture_;
- // Are we loading our top level frame
- bool is_loading_;
+ // Used for popups.
+ bool opened_by_user_gesture_;
+ GURL creator_url_;
+
+ // Whether this RenderView was created by a frame that was suppressing its
+ // opener. If so, we may want to load pages in a separate process. See
+ // decidePolicyForNavigation for details.
+ bool opener_suppressed_;
// If we are handling a top-level client-side redirect, this tracks the URL
// of the page that initiated it. Specifically, when a load is committed this
@@ -1002,15 +1013,28 @@ class RenderView : public RenderWidget,
// It is empty if there is no top-level client-side redirect.
GURL completed_client_redirect_src_;
- // The gesture that initiated the current navigation.
- NavigationGesture navigation_gesture_;
+ // Stores if images, scripts, and plugins have actually been blocked.
+ bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES];
- // Unique id to identify the current page between browser and renderer.
+ // Holds state pertaining to a navigation that we initiated. This is held by
+ // the WebDataSource::ExtraData attribute. We use pending_navigation_state_
+ // as a temporary holder for the state until the WebDataSource corresponding
+ // to the new navigation is created. See DidCreateDataSource.
+ scoped_ptr<NavigationState> pending_navigation_state_;
+
+ // Timer used to delay the updating of nav state (see SyncNavigationState).
+ base::OneShotTimer<RenderView> nav_state_sync_timer_;
+
+ // Page IDs ------------------------------------------------------------------
//
- // Note that this is NOT updated for every main frame navigation, only for
- // "regular" navigations that go into session history. In particular, client
- // redirects, like the page cycler uses (document.location.href="foo") do not
- // count as regular navigations and do not increment the page id.
+ // Page IDs allow the browser to identify pages in each renderer process for
+ // keeping back/forward history in sync.
+
+ // ID of the current page. Note that this is NOT updated for every main
+ // frame navigation, only for "regular" navigations that go into session
+ // history. In particular, client redirects, like the page cycler uses
+ // (document.location.href="foo") do not count as regular navigations and do
+ // not increment the page id.
int32 page_id_;
// Indicates the ID of the last page that we sent a FrameNavigate to the
@@ -1024,73 +1048,93 @@ class RenderView : public RenderWidget,
// same page twice in a row.
int32 last_indexed_page_id_;
+ // page id for the last navigation sent to the browser.
+ int32 last_top_level_navigation_page_id_;
+
// The next available page ID to use. This ensures that the page IDs are
// globally unique in the renderer.
static int32 next_page_id_;
- // Used for popups.
- bool opened_by_user_gesture_;
- GURL creator_url_;
+ // Page info -----------------------------------------------------------------
- // The alternate error page URL, if one exists.
- GURL alternate_error_page_url_;
+ // The last gotten main frame's encoding.
+ std::string last_encoding_name_;
- // Whether this RenderView was created by a frame that was suppressing its
- // opener. If so, we may want to load pages in a separate process. See
- // decidePolicyForNavigation for details.
- bool opener_suppressed_;
+ int history_list_offset_;
+ int history_list_length_;
- ScopedRunnableMethodFactory<RenderView> method_factory_;
+ // True if the page has any frame-level unload or beforeunload listeners.
+ bool has_unload_listener_;
- // Timer used to delay the updating of nav state (see SyncNavigationState).
- base::OneShotTimer<RenderView> nav_state_sync_timer_;
+#if defined(OS_MACOSX)
+ // True if the current RenderView has been assigned a document tag.
+ bool has_document_tag_;
+#endif
- // Remember the first uninstalled plugin, so that we can ask the plugin
- // to install itself when user clicks on the info bar.
- base::WeakPtr<webkit_glue::WebPluginDelegate> first_default_plugin_;
+ int document_tag_;
- // If the browser hasn't sent us an ACK for the last FindReply we sent
- // to it, then we need to queue up the message (keeping only the most
- // recent message if new ones come in).
- scoped_ptr<IPC::Message> queued_find_reply_message_;
+ // Site isolation metrics flags. These are per-page-load counts, reset to 0
+ // in OnClosePage.
+ int cross_origin_access_count_;
+ int same_origin_access_count_;
- // Provides access to this renderer from the remote Inspector UI.
- scoped_ptr<DevToolsAgent> devtools_agent_;
+ // UI state ------------------------------------------------------------------
- // DevToolsClient for renderer hosting developer tools UI. It's NULL for other
- // render views.
- scoped_ptr<DevToolsClient> devtools_client_;
+ // The state of our target_url transmissions. When we receive a request to
+ // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK
+ // comes back - if a new request comes in before the ACK, we store the new
+ // URL in pending_target_url_ and set the status to TARGET_PENDING. If an
+ // ACK comes back and we are in TARGET_PENDING, we send the stored URL and
+ // revert to TARGET_INFLIGHT.
+ //
+ // We don't need a queue of URLs to send, as only the latest is useful.
+ enum {
+ TARGET_NONE,
+ TARGET_INFLIGHT, // We have a request in-flight, waiting for an ACK
+ TARGET_PENDING // INFLIGHT + we have a URL waiting to be sent
+ } target_url_status_;
- // The current and pending file chooser completion objects. If the queue is
- // nonempty, the first item represents the currently running file chooser
- // callback, and the remaining elements are the other file chooser completion
- // still waiting to be run (in order).
- struct PendingFileChooser;
- std::deque< linked_ptr<PendingFileChooser> > file_chooser_completions_;
+ // The URL we show the user in the status bar. We use this to determine if we
+ // want to send a new one (we do not need to send duplicates). It will be
+ // equal to either |mouse_over_url_| or |focus_url_|, depending on which was
+ // updated last.
+ GURL target_url_;
- int history_list_offset_;
- int history_list_length_;
+ // The URL the user's mouse is hovering over.
+ GURL mouse_over_url_;
- // True if the page has any frame-level unload or beforeunload listeners.
- bool has_unload_listener_;
+ // The URL that has keyboard focus.
+ GURL focus_url_;
- // The total number of unrequested popups that exist and can be followed back
- // to a common opener. This count is shared among all RenderViews created
- // with createView(). All popups are treated as unrequested until
- // specifically instructed otherwise by the Browser process.
- scoped_refptr<SharedRenderViewCounter> shared_popup_counter_;
+ // The next target URL we want to send to the browser.
+ GURL pending_target_url_;
- // Whether this is a top level window (instead of a popup). Top level windows
- // shouldn't count against their own |shared_popup_counter_|.
- bool decrement_shared_popup_at_destruction_;
+ // True if the browser is showing the spelling panel for us.
+ bool spelling_panel_visible_;
- // Handles accessibility requests into the renderer side, as well as
- // maintains the cache and other features of the accessibility tree.
- scoped_ptr<WebKit::WebAccessibilityCache> accessibility_;
+ // The text selection the last time DidChangeSelection got called.
+ std::string last_selection_;
- // Resource message queue. Used to queue up resource IPCs if we need
- // to wait for an ACK from the browser before proceeding.
- std::queue<IPC::Message*> queued_resource_messages_;
+ // View ----------------------------------------------------------------------
+
+ // Type of view attached with RenderView, it could be INVALID, TAB_CONTENTS,
+ // EXTENSION_TOOLSTRIP, EXTENSION_BACKGROUND_PAGE, DEV_TOOLS_UI.
+ 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_;
+
+ // Nasty hack. WebKit does not send us events when the preferred size changes,
+ // so we must poll it. See also:
+ // https://bugs.webkit.org/show_bug.cgi?id=32807.
+ base::RepeatingTimer<RenderView> preferred_size_change_timer_;
+
+ // Autofill ------------------------------------------------------------------
// The id of the last request sent for form field autofill. Used to ignore
// out of date responses.
@@ -1100,148 +1144,123 @@ class RenderView : public RenderWidget,
// autofill.
WebKit::WebNode autofill_query_node_;
- // 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_;
+ // The action to take when receiving AutoFill data from the AutoFillManager.
+ AutoFillAction autofill_action_;
- // True if the browser is showing the spelling panel for us.
- bool spelling_panel_visible_;
+ // Plugins -------------------------------------------------------------------
- // See description above setter.
- bool send_content_state_immediately_;
+ // Remember the first uninstalled plugin, so that we can ask the plugin
+ // to install itself when user clicks on the info bar.
+ base::WeakPtr<webkit_glue::WebPluginDelegate> first_default_plugin_;
- scoped_refptr<AudioMessageFilter> audio_message_filter_;
+ PepperPluginDelegateImpl pepper_delegate_;
- // The currently selected text. This is currently only updated on Linux, where
- // it's for the selection clipboard.
- std::string selection_text_;
+#if defined(OS_MACOSX)
+ // All the currently active plugin delegates for this RenderView; kept so that
+ // we can enumerate them to send updates about things like window location
+ // or tab focus and visibily. These are non-owning references.
+ std::set<WebPluginDelegateProxy*> plugin_delegates_;
+#endif
- // 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_;
+ // A list of all pepper plugins that we've created that haven't been
+ // destroyed yet.
+ std::set<WebPluginDelegatePepper*> current_pepper_plugins_;
- // If true, we send IPC messages when |preferred_size_| changes.
- bool send_preferred_size_changes_;
+ // Helper objects ------------------------------------------------------------
- // Nasty hack. WebKit does not send us events when the preferred size changes,
- // so we must poll it. See also:
- // https://bugs.webkit.org/show_bug.cgi?id=32807.
- base::RepeatingTimer<RenderView> preferred_size_change_timer_;
+ FormManager form_manager_;
- // If non-empty, and |send_preferred_size_changes_| is true, disable drawing
- // scroll bars on windows smaller than this size. Used for windows that the
- // browser resizes to the size of the content, such as browser action popups.
- // If a render view is set to the minimum size of its content, webkit may add
- // scroll bars. This makes sense for fixed sized windows, but it does not
- // make sense when the size of the view was chosen to fit the content.
- // This setting ensures that no scroll bars are drawn. The size limit exists
- // because if the view grows beyond a size known to the browser, scroll bars
- // should be drawn.
- gfx::Size disable_scrollbars_size_limit_;
+ ScopedRunnableMethodFactory<RenderView> method_factory_;
- // The text selection the last time DidChangeSelection got called.
- std::string last_selection_;
+ // Responsible for translating the page contents to other languages.
+ TranslateHelper translate_helper_;
+
+ RendererWebCookieJarImpl cookie_jar_;
+
+ // Provides access to this renderer from the remote Inspector UI.
+ scoped_ptr<DevToolsAgent> devtools_agent_;
+
+ // DevToolsClient for renderer hosting developer tools UI. It's NULL for other
+ // render views.
+ scoped_ptr<DevToolsClient> devtools_client_;
// Holds a reference to the service which provides desktop notifications.
scoped_ptr<NotificationProvider> notification_provider_;
- // Holds state pertaining to a navigation that we initiated. This is held by
- // the WebDataSource::ExtraData attribute. We use pending_navigation_state_
- // as a temporary holder for the state until the WebDataSource corresponding
- // to the new navigation is created. See DidCreateDataSource.
- scoped_ptr<NavigationState> pending_navigation_state_;
-
// PrintWebViewHelper handles printing. Note that this object is constructed
// when printing for the first time but only destroyed with the RenderView.
scoped_ptr<PrintWebViewHelper> print_helper_;
- RendererPreferences renderer_preferences_;
-
- // Type of view attached with RenderView, it could be INVALID, TAB_CONTENTS,
- // EXTENSION_TOOLSTRIP, EXTENSION_BACKGROUND_PAGE, DEV_TOOLS_UI.
- ViewType::Type view_type_;
-
- // Id number of browser window which RenderView is attached to.
- int browser_window_id_;
+ scoped_refptr<AudioMessageFilter> audio_message_filter_;
- std::queue<linked_ptr<ViewMsg_ExecuteCode_Params> >
- pending_code_execution_queue_;
+ // The geolocation dispatcher attached to this view, lazily initialized.
+ scoped_ptr<GeolocationDispatcher> geolocation_dispatcher_;
- // page id for the last navigation sent to the browser.
- int32 last_top_level_navigation_page_id_;
+ // Handles accessibility requests into the renderer side, as well as
+ // maintains the cache and other features of the accessibility tree.
+ scoped_ptr<WebKit::WebAccessibilityCache> accessibility_;
-#if defined(OS_MACOSX)
- // True if the current RenderView has been assigned a document tag.
- bool has_document_tag_;
-#endif
+ // Misc ----------------------------------------------------------------------
- // Document tag for this RenderView.
- int document_tag_;
+ // The current and pending file chooser completion objects. If the queue is
+ // nonempty, the first item represents the currently running file chooser
+ // callback, and the remaining elements are the other file chooser completion
+ // still waiting to be run (in order).
+ struct PendingFileChooser;
+ std::deque< linked_ptr<PendingFileChooser> > file_chooser_completions_;
- // The settings this render view initialized WebKit with.
- WebPreferences webkit_preferences_;
+ // Resource message queue. Used to queue up resource IPCs if we need
+ // to wait for an ACK from the browser before proceeding.
+ std::queue<IPC::Message*> queued_resource_messages_;
- // Stores edit commands associated to the next key event.
- // Shall be cleared as soon as the next key event is processed.
- EditCommands edit_commands_;
+ std::queue<linked_ptr<ViewMsg_ExecuteCode_Params> >
+ pending_code_execution_queue_;
// ImageResourceFetchers schedule via DownloadImage.
typedef std::set<webkit_glue::ImageResourceFetcher*> ImageResourceFetcherSet;
ImageResourceFetcherSet image_fetchers_;
- typedef std::map<WebKit::WebView*, RenderView*> ViewMap;
-
- HostContentSettings host_content_settings_;
- HostZoomLevels host_zoom_levels_;
-
- // Stores if loading of images, scripts, and plugins is allowed.
- ContentSettings current_content_settings_;
-
- // Stores if images, scripts, and plugins have actually been blocked.
- bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES];
-
// 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.
int64 session_storage_namespace_id_;
- // A list of all pepper plugins that we've created that haven't been
- // destroyed yet.
- std::set<WebPluginDelegatePepper*> current_pepper_plugins_;
-
- // The FormManager for this RenderView.
- FormManager form_manager_;
+ // The total number of unrequested popups that exist and can be followed back
+ // to a common opener. This count is shared among all RenderViews created
+ // with createView(). All popups are treated as unrequested until
+ // specifically instructed otherwise by the Browser process.
+ scoped_refptr<SharedRenderViewCounter> shared_popup_counter_;
-#if defined(OS_MACOSX)
- // All the currently active plugin delegates for this RenderView; kept so that
- // we can enumerate them to send updates about things like window location
- // or tab focus and visibily. These are non-owning references.
- std::set<WebPluginDelegateProxy*> plugin_delegates_;
-#endif
+ // Whether this is a top level window (instead of a popup). Top level windows
+ // shouldn't count against their own |shared_popup_counter_|.
+ bool decrement_shared_popup_at_destruction_;
- // The geolocation dispatcher attached to this view, lazily initialized.
- scoped_ptr<GeolocationDispatcher> geolocation_dispatcher_;
+ // If the browser hasn't sent us an ACK for the last FindReply we sent
+ // to it, then we need to queue up the message (keeping only the most
+ // recent message if new ones come in).
+ scoped_ptr<IPC::Message> queued_find_reply_message_;
- RendererWebCookieJarImpl cookie_jar_;
+ // Stores edit commands associated to the next key event.
+ // Shall be cleared as soon as the next key event is processed.
+ EditCommands edit_commands_;
- // The object responsible for translating the page contents to other
- // languages.
- TranslateHelper translate_helper_;
+ // Allows JS to access DOM automation. The JS object is only exposed when the
+ // DOM automation bindings are enabled.
+ DomAutomationController dom_automation_controller_;
- // Site isolation metrics flags. These are per-page-load counts, reset to 0
- // in OnClosePage.
- int cross_origin_access_count_;
- int same_origin_access_count_;
+ // Allows DOM UI pages (new tab page, etc.) to talk to the browser. The JS
+ // object is only exposed when DOM UI bindings are enabled.
+ DOMUIBindings dom_ui_bindings_;
- PepperPluginDelegateImpl pepper_delegate_;
+ // External host exposed through automation controller.
+ ExternalHostBindings external_host_bindings_;
- // The action to take when receiving AutoFill data from the AutoFillManager.
- AutoFillAction autofill_action_;
+ // ---------------------------------------------------------------------------
+ // ADDING NEW DATA? Please see if it fits appropriately in one of the above
+ // sections rather than throwing it randomly at the end. If you're adding a
+ // bunch of stuff, you should probably create a helper class and put your
+ // data and methods on that to avoid bloating RenderView more.
+ // ---------------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(RenderView);
};