diff options
author | mariakhomenko@chromium.org <mariakhomenko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 07:48:53 +0000 |
---|---|---|
committer | mariakhomenko@chromium.org <mariakhomenko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 07:48:53 +0000 |
commit | c6ce08078b24a4ef2b0fd86c40001ad87b9c2b8c (patch) | |
tree | c0a63bebd88bcfb8866b69958aa2c7394e1b1f71 | |
parent | 2dc40fdb4cfa1f40ba4f85d3035cf791a139ab1c (diff) | |
download | chromium_src-c6ce08078b24a4ef2b0fd86c40001ad87b9c2b8c.zip chromium_src-c6ce08078b24a4ef2b0fd86c40001ad87b9c2b8c.tar.gz chromium_src-c6ce08078b24a4ef2b0fd86c40001ad87b9c2b8c.tar.bz2 |
Creates a flag to enable/disable spellchecker.
Add a flag to remove spell-checking inside form fields on Chrome.
Disable the flag for android -- we cannot interact with the spellchecker,
so it doesn't make sense to have it.
This saves us ~300K memory on startup.
BUG=264837
Review URL: https://chromiumcodereview.appspot.com/20794002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214621 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | build/common.gypi | 8 | ||||
-rw-r--r-- | chrome/browser/chrome_content_browser_client.cc | 7 | ||||
-rw-r--r-- | chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc | 11 | ||||
-rw-r--r-- | chrome/browser/sync/profile_sync_components_factory_impl.cc | 9 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 5 | ||||
-rw-r--r-- | chrome/chrome_renderer.gypi | 5 | ||||
-rw-r--r-- | chrome/chrome_tests_unit.gypi | 6 | ||||
-rw-r--r-- | chrome/renderer/chrome_content_renderer_client.cc | 19 | ||||
-rw-r--r-- | chrome/renderer/chrome_content_renderer_client.h | 6 | ||||
-rw-r--r-- | chrome/test/base/chrome_render_view_test.cc | 2 |
10 files changed, 71 insertions, 7 deletions
diff --git a/build/common.gypi b/build/common.gypi index 33a3726..6b98fc0 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -340,6 +340,9 @@ # Enable printing support and UI. 'enable_printing%': 1, + # Enable spell checker. + 'enable_spellcheck%': 1, + # Webrtc compilation is enabled by default. Set to 0 to disable. 'enable_webrtc%': 1, @@ -511,6 +514,7 @@ 'enable_extensions%': 0, 'enable_google_now%': 0, 'enable_printing%': 0, + 'enable_spellcheck%': 0, 'enable_themes%': 0, 'proprietary_codecs%': 1, 'remoting%': 0, @@ -817,6 +821,7 @@ 'test_isolation_fail_on_missing': '<(test_isolation_fail_on_missing)', 'enable_automation%': '<(enable_automation)', 'enable_printing%': '<(enable_printing)', + 'enable_spellcheck%': '<(enable_spellcheck)', 'enable_google_now%': '<(enable_google_now)', 'enable_captive_portal_detection%': '<(enable_captive_portal_detection)', 'disable_ftp_support%': '<(disable_ftp_support)', @@ -2240,6 +2245,9 @@ ['enable_printing==1', { 'defines': ['ENABLE_PRINTING=1'], }], + ['enable_spellcheck==1', { + 'defines': ['ENABLE_SPELLCHECK=1'], + }], ['enable_captive_portal_detection==1', { 'defines': ['ENABLE_CAPTIVE_PORTAL_DETECTION=1'], }], diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index dedcc70..993babd 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -76,7 +76,6 @@ #include "chrome/browser/search_engines/search_provider_install_state_message_filter.h" #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" #include "chrome/browser/speech/tts_message_filter.h" -#include "chrome/browser/spellchecker/spellcheck_message_filter.h" #include "chrome/browser/ssl/ssl_add_certificate.h" #include "chrome/browser/ssl/ssl_blocking_page.h" #include "chrome/browser/ssl/ssl_tab_helper.h" @@ -228,6 +227,10 @@ #include "chrome/browser/chrome_browser_main_extra_parts_x11.h" #endif +#if defined(ENABLE_SPELLCHECK) +#include "chrome/browser/spellchecker/spellcheck_message_filter.h" +#endif + using WebKit::WebWindowFeatures; using base::FileDescriptor; using content::AccessTokenStore; @@ -887,7 +890,9 @@ void ChromeContentBrowserClient::RenderProcessHostCreated( #endif host->GetChannel()->AddFilter( new SearchProviderInstallStateMessageFilter(id, profile)); +#if defined(ENABLE_SPELLCHECK) host->GetChannel()->AddFilter(new SpellCheckMessageFilter(id)); +#endif #if defined(OS_MACOSX) host->GetChannel()->AddFilter(new SpellCheckMessageFilterMac(id)); #endif diff --git a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc index 8b594e9..f27b868 100644 --- a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc +++ b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc @@ -46,7 +46,6 @@ #include "chrome/browser/extensions/api/serial/serial_connection.h" #include "chrome/browser/extensions/api/session_restore/session_restore_api.h" #include "chrome/browser/extensions/api/socket/socket.h" -#include "chrome/browser/extensions/api/spellcheck/spellcheck_api.h" #include "chrome/browser/extensions/api/streams_private/streams_private_api.h" #include "chrome/browser/extensions/api/system_info/system_info_api.h" #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry_factory.h" @@ -86,7 +85,6 @@ #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/token_service_factory.h" #include "chrome/browser/speech/extension_api/tts_extension_api.h" -#include "chrome/browser/spellchecker/spellcheck_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/thumbnails/thumbnail_service_factory.h" @@ -136,6 +134,11 @@ #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h" #endif +#if defined(ENABLE_SPELLCHECK) +#include "chrome/browser/extensions/api/spellcheck/spellcheck_api.h" +#include "chrome/browser/spellchecker/spellcheck_factory.h" +#endif + namespace chrome { void AddProfilesExtraParts(ChromeBrowserMainParts* main_parts) { @@ -237,7 +240,9 @@ EnsureBrowserContextKeyedServiceFactoriesBuilt() { extensions::ProcessesAPI::GetFactoryInstance(); extensions::PushMessagingAPI::GetFactoryInstance(); extensions::SessionRestoreAPI::GetFactoryInstance(); +#if defined(ENABLE_SPELLCHECK) extensions::SpellcheckAPI::GetFactoryInstance(); +#endif extensions::StreamsPrivateAPI::GetFactoryInstance(); extensions::SystemInfoAPI::GetFactoryInstance(); extensions::SuggestedLinksRegistryFactory::GetInstance(); @@ -299,7 +304,9 @@ EnsureBrowserContextKeyedServiceFactoriesBuilt() { #endif ShortcutsBackendFactory::GetInstance(); SigninManagerFactory::GetInstance(); +#if defined(ENABLE_SPELLCHECK) SpellcheckServiceFactory::GetInstance(); +#endif ThumbnailServiceFactory::GetInstance(); TabRestoreServiceFactory::GetInstance(); TemplateURLFetcherFactory::GetInstance(); diff --git a/chrome/browser/sync/profile_sync_components_factory_impl.cc b/chrome/browser/sync/profile_sync_components_factory_impl.cc index 0c9c47b..0ce7f9f 100644 --- a/chrome/browser/sync/profile_sync_components_factory_impl.cc +++ b/chrome/browser/sync/profile_sync_components_factory_impl.cc @@ -21,8 +21,6 @@ #include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager_factory.h" -#include "chrome/browser/spellchecker/spellcheck_factory.h" -#include "chrome/browser/spellchecker/spellcheck_service.h" #include "chrome/browser/sync/glue/autofill_data_type_controller.h" #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h" #include "chrome/browser/sync/glue/bookmark_change_processor.h" @@ -76,6 +74,11 @@ #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h" #endif +#if defined(ENABLE_SPELLCHECK) +#include "chrome/browser/spellchecker/spellcheck_factory.h" +#include "chrome/browser/spellchecker/spellcheck_service.h" +#endif + using browser_sync::AutofillDataTypeController; using browser_sync::AutofillProfileDataTypeController; using browser_sync::BookmarkChangeProcessor; @@ -377,9 +380,11 @@ base::WeakPtr<syncer::SyncableService> ProfileSyncComponentsFactoryImpl:: : base::WeakPtr<syncer::SyncableService>(); } #endif +#if defined(ENABLE_SPELLCHECK) case syncer::DICTIONARY: return SpellcheckServiceFactory::GetForProfile(profile_)-> GetCustomDictionary()->AsWeakPtr(); +#endif case syncer::FAVICON_IMAGES: case syncer::FAVICON_TRACKING: { browser_sync::SessionModelAssociator* model_associator = diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 75a9e84..6c4bf6a 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2507,6 +2507,11 @@ ['exclude', '^browser/task_manager/'], ], }], + ['enable_spellcheck==0', { + 'sources/': [ + ['exclude', '^browser/spellchecker/'], + ], + }], ['disable_nacl==0', { 'sources': [ 'browser/nacl_host/nacl_broker_host_win.cc', diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi index 75955e7..5c9caf5 100644 --- a/chrome/chrome_renderer.gypi +++ b/chrome/chrome_renderer.gypi @@ -373,6 +373,11 @@ 'renderer/media/webrtc_logging_message_filter.h', ], }], + ['enable_spellcheck==0', { + 'sources/': [ + ['exclude', '^render/spellchecker/'] + ] + }], ['OS=="mac"', { 'dependencies': [ '../third_party/mach_override/mach_override.gyp:mach_override', diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index de7dc2d..34866f0 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -1972,6 +1972,12 @@ ['exclude', '^browser/background/'], ], }], + ['enable_spellcheck==0', { + 'sources/': [ + ['exclude', '^browser/spellchecker/'], + ['exclude', '^renderer/spellchecker/'], + ], + }], ['enable_one_click_signin==0', { 'sources!': [ 'browser/ui/cocoa/one_click_signin_bubble_controller_unittest.mm', diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index faf742d..e4d480a 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -62,8 +62,6 @@ #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" #include "chrome/renderer/searchbox/searchbox.h" #include "chrome/renderer/searchbox/searchbox_extension.h" -#include "chrome/renderer/spellchecker/spellcheck.h" -#include "chrome/renderer/spellchecker/spellcheck_provider.h" #include "chrome/renderer/tts_dispatcher.h" #include "chrome/renderer/validation_message_agent.h" #include "components/autofill/content/renderer/autofill_agent.h" @@ -105,6 +103,11 @@ #include "chrome/renderer/media/webrtc_logging_message_filter.h" #endif +#if defined(ENABLE_SPELLCHECK) +#include "chrome/renderer/spellchecker/spellcheck.h" +#include "chrome/renderer/spellchecker/spellcheck_provider.h" +#endif + using autofill::AutofillAgent; using autofill::PasswordAutofillAgent; using autofill::PasswordGenerationManager; @@ -161,6 +164,7 @@ static void AppendParams(const std::vector<string16>& additional_names, existing_values->swap(values); } +#if defined(ENABLE_SPELLCHECK) class SpellCheckReplacer : public content::RenderViewVisitor { public: explicit SpellCheckReplacer(SpellCheck* spellcheck) @@ -178,6 +182,7 @@ bool SpellCheckReplacer::Visit(content::RenderView* render_view) { provider->set_spellcheck(spellcheck_); return true; } +#endif // For certain sandboxed Pepper plugins, use the JavaScript Content Settings. bool ShouldUseJavaScriptSettingForPlugin(const WebPluginInfo& plugin) { @@ -232,7 +237,9 @@ void ChromeContentRendererClient::RenderThreadStarted() { extension_dispatcher_.get())); prescient_networking_dispatcher_.reset(new PrescientNetworkingDispatcher()); net_predictor_.reset(new RendererNetPredictor()); +#if defined(ENABLE_SPELLCHECK) spellcheck_.reset(new SpellCheck()); +#endif visited_link_slave_.reset(new visitedlink::VisitedLinkSlave()); #if defined(FULL_SAFE_BROWSING) phishing_classifier_.reset(safe_browsing::PhishingClassifierFilter::Create()); @@ -250,7 +257,9 @@ void ChromeContentRendererClient::RenderThreadStarted() { #if defined(FULL_SAFE_BROWSING) thread->AddObserver(phishing_classifier_.get()); #endif +#if defined(ENABLE_SPELLCHECK) thread->AddObserver(spellcheck_.get()); +#endif thread->AddObserver(visited_link_slave_.get()); thread->AddObserver(prerender_dispatcher_.get()); @@ -353,7 +362,9 @@ void ChromeContentRendererClient::RenderViewCreated( #if defined(ENABLE_PRINTING) new printing::PrintWebViewHelper(render_view); #endif +#if defined(ENABLE_SPELLCHECK) new SpellCheckProvider(render_view, spellcheck_.get()); +#endif new prerender::PrerendererClient(render_view); #if defined(FULL_SAFE_BROWSING) safe_browsing::MalwareDOMDetails::Create(render_view); @@ -1163,6 +1174,7 @@ bool ChromeContentRendererClient::CrossesExtensionExtents( extensions, old_url, new_url, should_consider_workaround); } +#if defined(ENABLE_SPELLCHECK) void ChromeContentRendererClient::SetSpellcheck(SpellCheck* spellcheck) { RenderThread* thread = RenderThread::Get(); if (spellcheck_.get() && thread) @@ -1173,10 +1185,13 @@ void ChromeContentRendererClient::SetSpellcheck(SpellCheck* spellcheck) { if (thread) thread->AddObserver(spellcheck_.get()); } +#endif void ChromeContentRendererClient::OnPurgeMemory() { +#if defined(ENABLE_SPELLCHECK) DVLOG(1) << "Resetting spellcheck in renderer client"; SetSpellcheck(new SpellCheck()); +#endif } bool ChromeContentRendererClient::IsAdblockInstalled() { diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h index 44f2774..b3d4d4f 100644 --- a/chrome/renderer/chrome_content_renderer_client.h +++ b/chrome/renderer/chrome_content_renderer_client.h @@ -21,8 +21,10 @@ class ChromeRenderProcessObserver; class ExtensionSet; class PrescientNetworkingDispatcher; class RendererNetPredictor; +#if defined(ENABLE_SPELLCHECK) class SpellCheck; class SpellCheckProvider; +#endif struct ChromeViewHostMsg_GetPluginInfo_Output; @@ -139,9 +141,11 @@ class ChromeContentRendererClient : public content::ContentRendererClient { // For testing. void SetExtensionDispatcher(extensions::Dispatcher* extension_dispatcher); +#if defined(ENABLE_SPELLCHECK) // Sets a new |spellcheck|. Used for low-mem restart and testing only. // Takes ownership of |spellcheck|. void SetSpellcheck(SpellCheck* spellcheck); +#endif // Called in low-memory conditions to dump the memory used by the spellchecker // and start over. @@ -189,7 +193,9 @@ class ChromeContentRendererClient : public content::ContentRendererClient { permissions_policy_delegate_; scoped_ptr<PrescientNetworkingDispatcher> prescient_networking_dispatcher_; scoped_ptr<RendererNetPredictor> net_predictor_; +#if defined(ENABLE_SPELLCHECK) scoped_ptr<SpellCheck> spellcheck_; +#endif scoped_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_; scoped_ptr<safe_browsing::PhishingClassifierFilter> phishing_classifier_; scoped_ptr<prerender::PrerenderDispatcher> prerender_dispatcher_; diff --git a/chrome/test/base/chrome_render_view_test.cc b/chrome/test/base/chrome_render_view_test.cc index 665590a..9838dee 100644 --- a/chrome/test/base/chrome_render_view_test.cc +++ b/chrome/test/base/chrome_render_view_test.cc @@ -56,7 +56,9 @@ void ChromeRenderViewTest::SetUp() { content::SetRendererClientForTesting(&chrome_content_renderer_client_); extension_dispatcher_ = new extensions::Dispatcher(); chrome_content_renderer_client_.SetExtensionDispatcher(extension_dispatcher_); +#if defined(ENABLE_SPELLCHECK) chrome_content_renderer_client_.SetSpellcheck(new SpellCheck()); +#endif content::RenderViewTest::SetUp(); |