Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_HYPHENATOR_HYPHENATOR_MESSAGE_FILTER_H_ | |
| 6 #define CONTENT_BROWSER_HYPHENATOR_HYPHENATOR_MESSAGE_FILTER_H_ | |
| 7 | |
| 8 #include "base/compiler_specific.h" | |
| 9 #include "base/file_path.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "base/platform_file.h" | |
| 12 #include "content/common/content_export.h" | |
| 13 #include "content/public/browser/browser_message_filter.h" | |
| 14 | |
| 15 namespace content { | |
| 16 class RenderProcessHost; | |
| 17 | |
| 18 // This class is a message filter that handles a HyphenatorHost message. When | |
| 19 // this class receives a HyphenatorHostMsg_OpenDictionary message, it opens the | |
| 20 // specified dictionary and sends its file handle. | |
| 21 class CONTENT_EXPORT HyphenatorMessageFilter | |
| 22 : public content::BrowserMessageFilter { | |
| 23 public: | |
| 24 explicit HyphenatorMessageFilter( | |
| 25 content::RenderProcessHost* render_process_host); | |
| 26 | |
| 27 // Changes the directory that includes dictionary files. This function | |
| 28 // provides a method that allows applications to change the directory | |
| 29 // containing hyphenation dictionaries. When a renderer requests a hyphnation | |
| 30 // dictionary, this class appends a file name (which consists of a locale, a | |
| 31 // version number, and an extension) and use it as a dictionary file. That is, | |
| 32 // This class opens the file "|dictionary_path_|/|locale|-1-0.dic". | |
|
tony
2012/08/22 19:05:50
Nit: This comment feels verbose. I would just kee
Hironori Bono
2012/08/27 06:57:28
Done. Thanks for noticing my redundant comments.
| |
| 33 void SetDictionaryBase(const FilePath& directory); | |
| 34 | |
| 35 // content::BrowserMessageFilter implementation. | |
| 36 virtual void OverrideThreadForMessage( | |
| 37 const IPC::Message& message, | |
| 38 content::BrowserThread::ID* thread) OVERRIDE; | |
| 39 virtual bool OnMessageReceived(const IPC::Message& message, | |
| 40 bool* message_was_ok) OVERRIDE; | |
| 41 | |
| 42 private: | |
| 43 friend class TestHyphenatorMessageFilter; | |
| 44 | |
| 45 virtual ~HyphenatorMessageFilter(); | |
| 46 | |
| 47 // Called when this object receives HyphenatorHostMsg_OpenDictionary messages. | |
| 48 virtual void OnOpenDictionary(const string16& locale); | |
| 49 | |
| 50 // Opens a hyphenation dictionary for the specified locale. When this locale | |
| 51 // is an empty string, this function uses US English ("en-US"). | |
| 52 void OpenDictionary(const string16& locale); | |
| 53 | |
| 54 // Sends the hyphenation dictionary file to a renderer in response to its | |
| 55 // request. If this class cannot open the specified dictionary file, this | |
| 56 // function sends an IPC::nvalidPlatformFileForTransit value to tell the | |
|
tony
2012/08/22 19:05:50
Nit: typo: nvalidPlatformFileForTransit -> Invalid
Hironori Bono
2012/08/27 06:57:28
Done. Thanks for noticing this typo.
| |
| 57 // renderer that a browser cannot open the file. | |
| 58 void SendDictionary(); | |
| 59 | |
| 60 // The RenderProcessHost object that owns this filter. This class uses this | |
| 61 // object to retrieve the process handle used for creating | |
| 62 // PlatformFileForTransit objects. | |
| 63 content::RenderProcessHost* render_process_host_; | |
| 64 | |
| 65 // The directory that includes dictionary files. The default value is the | |
| 66 // directory containing the executable file. | |
| 67 FilePath dictionary_base_; | |
| 68 | |
| 69 // A cached dictionary file. | |
| 70 base::PlatformFile dictionary_file_; | |
| 71 | |
| 72 base::WeakPtrFactory<HyphenatorMessageFilter> weak_factory_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(HyphenatorMessageFilter); | |
| 75 }; | |
| 76 | |
| 77 } // namespace content | |
| 78 | |
| 79 #endif // CONTENT_BROWSER_HYPHENATOR_HYPHENATOR_MESSAGE_FILTER_H_ | |
| OLD | NEW |