summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.h6
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.mm66
-rw-r--r--chrome/common/render_messages.h8
-rw-r--r--chrome/common/render_view_commands.h23
-rw-r--r--chrome/common/spellcheck_messages.h5
-rw-r--r--chrome/renderer/spellchecker/spellcheck_provider.cc19
-rw-r--r--content/browser/DEPS2
-rw-r--r--content/browser/renderer_host/render_view_host.cc40
-rw-r--r--content/browser/renderer_host/render_view_host.h13
9 files changed, 62 insertions, 120 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h
index 576ce97..dc06563 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h
@@ -296,6 +296,8 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView {
int gpu_host_id,
uint64 swap_buffers_count);
+ void ToggleSpellCheck(bool enabled, bool checked);
+
// These member variables should be private, but the associated ObjC class
// needs access to them and can't be made a friend.
@@ -337,6 +339,10 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView {
// Helper class for managing instances of accelerated plug-ins.
AcceleratedSurfaceContainerManagerMac plugin_container_manager_;
+ // Used for continuous spell checking.
+ bool spellcheck_enabled_;
+ bool spellcheck_checked_;
+
private:
// Returns whether this render view is a popup (autocomplete window).
bool IsPopup() const;
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
index e2eb64f..2b2d785 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
@@ -32,6 +32,7 @@
#include "content/browser/renderer_host/backing_store_mac.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_view_host.h"
+#include "content/browser/renderer_host/render_view_host_observer.h"
#include "content/browser/renderer_host/render_widget_host.h"
#include "content/common/edit_command.h"
#include "content/common/gpu/gpu_messages.h"
@@ -178,6 +179,35 @@ NSWindow* ApparentWindowForView(NSView* view) {
return enclosing_window;
}
+// Filters the message sent to RenderViewHost to know if spellchecking is
+// enabled or not for the currently focused element.
+class SpellCheckRenderViewObserver : public RenderViewHostObserver {
+ public:
+ SpellCheckRenderViewObserver(RenderViewHost* host,
+ RenderWidgetHostViewMac* view)
+ : RenderViewHostObserver(host),
+ view_(view) {
+ }
+
+ private:
+ // RenderViewHostObserver implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(SpellCheckRenderViewObserver, message)
+ IPC_MESSAGE_HANDLER(SpellCheckHostMsg_ToggleSpellCheck,
+ OnToggleSpellCheck)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+ }
+
+ void OnToggleSpellCheck(bool enabled, bool checked) {
+ view_->ToggleSpellCheck(enabled, checked);
+ }
+
+ RenderWidgetHostViewMac* view_;
+};
+
} // namespace
// AcceleratedPluginView ------------------------------------------------------
@@ -598,6 +628,8 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget)
about_to_validate_and_paint_(false),
call_set_needs_display_in_rect_pending_(false),
text_input_type_(WebKit::WebTextInputTypeNone),
+ spellcheck_enabled_(false),
+ spellcheck_checked_(false),
is_loading_(false),
is_hidden_(false),
shutdown_factory_(this),
@@ -615,6 +647,11 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget)
BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected();
render_widget_host_->EnableRendererAccessibility();
}
+
+ if (render_widget_host_->IsRenderView()) {
+ new SpellCheckRenderViewObserver(
+ static_cast<RenderViewHost*>(widget), this);
+ }
}
RenderWidgetHostViewMac::~RenderWidgetHostViewMac() {
@@ -1254,6 +1291,11 @@ void RenderWidgetHostViewMac::AcknowledgeSwapBuffers(
}
}
+void RenderWidgetHostViewMac::ToggleSpellCheck(bool enabled, bool checked) {
+ spellcheck_enabled_ = enabled;
+ spellcheck_checked_ = checked;
+}
+
void RenderWidgetHostViewMac::GpuRenderingStateDidChange() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (GetRenderWidgetHost()->is_accelerated_compositing_active()) {
@@ -2049,31 +2091,13 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) {
}
if (action == @selector(toggleContinuousSpellChecking:)) {
- RenderViewHost::CommandState state;
- state.is_enabled = false;
- state.checked_state = RENDER_VIEW_COMMAND_CHECKED_STATE_UNCHECKED;
- if (renderWidgetHostView_->render_widget_host_->IsRenderView()) {
- state = static_cast<RenderViewHost*>(
- renderWidgetHostView_->render_widget_host_)->
- GetStateForCommand(RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK);
- }
if ([(id)item respondsToSelector:@selector(setState:)]) {
NSCellStateValue checked_state =
- RENDER_VIEW_COMMAND_CHECKED_STATE_UNCHECKED;
- switch (state.checked_state) {
- case RENDER_VIEW_COMMAND_CHECKED_STATE_UNCHECKED:
- checked_state = NSOffState;
- break;
- case RENDER_VIEW_COMMAND_CHECKED_STATE_CHECKED:
- checked_state = NSOnState;
- break;
- case RENDER_VIEW_COMMAND_CHECKED_STATE_MIXED:
- checked_state = NSMixedState;
- break;
- }
+ renderWidgetHostView_->spellcheck_checked_ ?
+ NSOnState : NSOffState;
[(id)item setState:checked_state];
}
- return state.is_enabled;
+ return renderWidgetHostView_->spellcheck_enabled_;
}
return editCommand_helper_->IsMenuItemEnabled(action, self);
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 68c547c..50c0c1d 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -405,14 +405,6 @@ IPC_MESSAGE_ROUTED3(ViewHostMsg_SendSerializedHtmlData,
IPC_MESSAGE_CONTROL1(ViewHostMsg_ResourceTypeStats,
WebKit::WebCache::ResourceTypeStats)
-// Message sent from renderer to the browser to update the state of a command.
-// The |command| parameter is a RenderViewCommand. The |checked_state| parameter
-// is a CommandCheckedState.
-IPC_MESSAGE_ROUTED3(ViewHostMsg_CommandStateChanged,
- int /* command */,
- bool /* is_enabled */,
- int /* checked_state */)
-
// Notifies the browser of the language (ISO 639_1 code language, such as fr,
// en, zh...) of the current page.
diff --git a/chrome/common/render_view_commands.h b/chrome/common/render_view_commands.h
deleted file mode 100644
index 541e7ea..0000000
--- a/chrome/common/render_view_commands.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_COMMON_RENDER_VIEW_COMMANDS_H_
-#define CHROME_COMMON_RENDER_VIEW_COMMANDS_H_
-#pragma once
-
-// These identify commands that the renderer process enables or disables
-// in the browser process. For example, this is used on the Mac to keep
-// the spell check menu commands in sync with the renderer state.
-enum RenderViewCommand {
- RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK,
-};
-
-enum RenderViewCommandCheckedState {
- RENDER_VIEW_COMMAND_CHECKED_STATE_UNCHECKED,
- RENDER_VIEW_COMMAND_CHECKED_STATE_CHECKED,
- RENDER_VIEW_COMMAND_CHECKED_STATE_MIXED,
-};
-
-
-#endif // CHROME_COMMON_RENDER_VIEW_COMMANDS_H_
diff --git a/chrome/common/spellcheck_messages.h b/chrome/common/spellcheck_messages.h
index 34ccb5c..52ade79 100644
--- a/chrome/common/spellcheck_messages.h
+++ b/chrome/common/spellcheck_messages.h
@@ -94,3 +94,8 @@ IPC_MESSAGE_CONTROL4(SpellCheckHostMsg_PlatformRequestTextCheck,
int /* request identifier given by WebKit */,
int /* document tag */,
string16 /* sentence */)
+
+// Only used on Mac.
+IPC_MESSAGE_ROUTED2(SpellCheckHostMsg_ToggleSpellCheck,
+ bool /* enabled */,
+ bool /* checked */)
diff --git a/chrome/renderer/spellchecker/spellcheck_provider.cc b/chrome/renderer/spellchecker/spellcheck_provider.cc
index c2d2dbb..871ecfd 100644
--- a/chrome/renderer/spellchecker/spellcheck_provider.cc
+++ b/chrome/renderer/spellchecker/spellcheck_provider.cc
@@ -6,8 +6,6 @@
#include "base/command_line.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/render_view_commands.h"
-#include "chrome/common/render_messages.h"
#include "chrome/common/spellcheck_messages.h"
#include "chrome/renderer/spellchecker/spellcheck.h"
#include "content/renderer/render_view.h"
@@ -81,24 +79,19 @@ bool SpellCheckProvider::OnMessageReceived(const IPC::Message& message) {
}
void SpellCheckProvider::FocusedNodeChanged(const WebKit::WebNode& unused) {
- bool is_enabled = false;
+ bool enabled = false;
WebKit::WebNode node = render_view()->GetFocusedNode();
if (!node.isNull())
- is_enabled = render_view()->IsEditableNode(node);
+ enabled = render_view()->IsEditableNode(node);
- RenderViewCommandCheckedState checked_state =
- RENDER_VIEW_COMMAND_CHECKED_STATE_UNCHECKED;
- if (is_enabled && render_view()->webview()) {
+ bool checked = false;
+ if (enabled && render_view()->webview()) {
WebFrame* frame = render_view()->webview()->focusedFrame();
if (frame->isContinuousSpellCheckingEnabled())
- checked_state = RENDER_VIEW_COMMAND_CHECKED_STATE_CHECKED;
+ checked = true;
}
- Send(new ViewHostMsg_CommandStateChanged(
- routing_id(),
- RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK,
- is_enabled,
- checked_state));
+ Send(new SpellCheckHostMsg_ToggleSpellCheck(routing_id(), enabled, checked));
}
void SpellCheckProvider::spellCheck(
diff --git a/content/browser/DEPS b/content/browser/DEPS
index 606bf05..5a7dec8 100644
--- a/content/browser/DEPS
+++ b/content/browser/DEPS
@@ -132,8 +132,6 @@ include_rules = [
"+chrome/common/net/url_fetcher.h",
- "+chrome/common/render_view_commands.h",
-
"+chrome/common/sandbox_policy.h",
"+chrome/common/security_style.h",
diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc
index da09850..216cedb 100644
--- a/content/browser/renderer_host/render_view_host.cc
+++ b/content/browser/renderer_host/render_view_host.cc
@@ -358,22 +358,6 @@ int RenderViewHost::GetPendingRequestId() {
return pending_request_id_;
}
-RenderViewHost::CommandState RenderViewHost::GetStateForCommand(
- RenderViewCommand command) const {
- if (command != RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK)
- LOG(DFATAL) << "Unknown command " << command;
-
- std::map<RenderViewCommand, CommandState>::const_iterator it =
- command_states_.find(command);
- if (it == command_states_.end()) {
- CommandState state;
- state.is_enabled = false;
- state.checked_state = RENDER_VIEW_COMMAND_CHECKED_STATE_UNCHECKED;
- return state;
- }
- return it->second;
-}
-
void RenderViewHost::Stop() {
Send(new ViewMsg_Stop(routing_id()));
}
@@ -757,8 +741,6 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
#if defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup)
#endif
- IPC_MESSAGE_HANDLER(ViewHostMsg_CommandStateChanged,
- OnCommandStateChanged)
// Have the super handle all other messages.
IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg))
IPC_END_MESSAGE_MAP_EX()
@@ -1440,25 +1422,3 @@ void RenderViewHost::OnMsgShowPopup(
}
}
#endif
-
-void RenderViewHost::OnCommandStateChanged(int command,
- bool is_enabled,
- int checked_state) {
- if (command != RENDER_VIEW_COMMAND_TOGGLE_SPELL_CHECK) {
- LOG(DFATAL) << "Unknown command " << command;
- return;
- }
-
- if (checked_state != RENDER_VIEW_COMMAND_CHECKED_STATE_UNCHECKED &&
- checked_state != RENDER_VIEW_COMMAND_CHECKED_STATE_CHECKED &&
- checked_state != RENDER_VIEW_COMMAND_CHECKED_STATE_MIXED) {
- LOG(DFATAL) << "Invalid checked state " << checked_state;
- return;
- }
-
- CommandState state;
- state.is_enabled = is_enabled;
- state.checked_state =
- static_cast<RenderViewCommandCheckedState>(checked_state);
- command_states_[static_cast<RenderViewCommand>(command)] = state;
-}
diff --git a/content/browser/renderer_host/render_view_host.h b/content/browser/renderer_host/render_view_host.h
index 2936218..e383c14 100644
--- a/content/browser/renderer_host/render_view_host.h
+++ b/content/browser/renderer_host/render_view_host.h
@@ -14,7 +14,6 @@
#include "base/process_util.h"
#include "chrome/browser/ui/find_bar/find_bar_controller.h"
#include "chrome/common/content_settings_types.h"
-#include "chrome/common/render_view_commands.h"
#include "chrome/common/view_types.h"
#include "content/browser/renderer_host/render_widget_host.h"
#include "content/common/page_zoom.h"
@@ -202,12 +201,6 @@ class RenderViewHost : public RenderWidgetHost {
// hangs, in which case we need to swap to the pending RenderViewHost.
int GetPendingRequestId();
- struct CommandState {
- bool is_enabled;
- RenderViewCommandCheckedState checked_state;
- };
- CommandState GetStateForCommand(RenderViewCommand command) const;
-
// Stops the current load.
void Stop();
@@ -539,9 +532,6 @@ class RenderViewHost : public RenderWidgetHost {
int maximum_percent,
bool remember);
void OnScriptEvalResponse(int id, const ListValue& result);
- void OnCommandStateChanged(int command,
- bool is_enabled,
- int checked_state);
#if defined(OS_MACOSX)
void OnMsgShowPopup(const ViewHostMsg_ShowPopup_Params& params);
@@ -627,9 +617,6 @@ class RenderViewHost : public RenderWidgetHost {
// The termination status of the last render view that terminated.
base::TerminationStatus render_view_termination_status_;
- // The enabled/disabled states of various commands.
- std::map<RenderViewCommand, CommandState> command_states_;
-
// A list of observers that filter messages. Weak references.
ObserverList<RenderViewHostObserver> observers_;