Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_ANDROID_ADDRESS_DETECTOR_H_ | 5 #ifndef CONTENT_COMMON_ADDRESS_PARSER_H_ |
| 6 #define CONTENT_RENDERER_ANDROID_ADDRESS_DETECTOR_H_ | 6 #define CONTENT_COMMON_ADDRESS_PARSER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/string_tokenizer.h" | 11 #include "base/string_tokenizer.h" |
| 13 #include "content/renderer/android/content_detector.h" | |
| 14 | 12 |
| 15 class AddressDetectorTest; | 13 class AddressParserTest; |
| 16 | 14 |
| 17 namespace content { | 15 namespace content { |
| 18 | 16 |
| 19 // Finds a geographical address (currently US only) in the given text string. | 17 // Finds a geographical address (currently US only) in the given text string. |
| 20 class AddressDetector : public ContentDetector { | 18 class AddressParser { |
|
piman
2012/05/29 19:53:26
So, this class has no field or non-static method,
Leandro GraciĆ” Gil
2012/05/30 18:19:56
Done.
| |
| 21 public: | 19 public: |
| 22 AddressDetector(); | 20 |
| 23 virtual ~AddressDetector(); | 21 // Find the first address in some chunk of text. If an address is found in |
| 22 // |text| true is returned and the address is copied into |address|. | |
| 23 // Otherwise, false is returned. | |
| 24 static bool FindAddress(const string16& text, string16* address); | |
| 25 | |
| 26 // Find the first address in some chunk of test. |begin| is the starting | |
| 27 // position to search from, |end| is the position to search to. |start_pos| | |
| 28 // and |end_pos| are set to the starting and ending position of the address, | |
| 29 // if found. | |
| 30 static bool FindContent(const string16::const_iterator& begin, | |
| 31 const string16::const_iterator& end, | |
| 32 size_t* start_pos, | |
| 33 size_t* end_pos); | |
| 24 | 34 |
| 25 private: | 35 private: |
| 26 friend class ::AddressDetectorTest; | 36 friend class ::AddressParserTest; |
| 27 | 37 |
| 28 // Implementation of ContentDetector. | 38 AddressParser(); |
| 29 virtual bool FindContent(const string16::const_iterator& begin, | |
| 30 const string16::const_iterator& end, | |
| 31 size_t* start_pos, | |
| 32 size_t* end_pos, | |
| 33 std::string* content_text) OVERRIDE; | |
| 34 virtual GURL GetIntentURL(const std::string& content_text) OVERRIDE; | |
| 35 virtual size_t GetMaximumContentLength() OVERRIDE; | |
| 36 | |
| 37 std::string GetContentText(const string16& text); | |
| 38 | 39 |
| 39 // Internal structs and classes. Required to be visible by the unit tests. | 40 // Internal structs and classes. Required to be visible by the unit tests. |
| 40 struct Word { | 41 struct Word { |
| 41 string16::const_iterator begin; | 42 string16::const_iterator begin; |
| 42 string16::const_iterator end; | 43 string16::const_iterator end; |
| 43 | 44 |
| 44 Word() {} | 45 Word() {} |
| 45 Word(const string16::const_iterator& begin, | 46 Word(const string16::const_iterator& begin, |
| 46 const string16::const_iterator& end); | 47 const string16::const_iterator& end); |
| 47 }; | 48 }; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 static bool FindStateStartingInWord(WordList* words, | 88 static bool FindStateStartingInWord(WordList* words, |
| 88 size_t state_first_word, | 89 size_t state_first_word, |
| 89 size_t* state_last_word, | 90 size_t* state_last_word, |
| 90 String16Tokenizer* tokenizer, | 91 String16Tokenizer* tokenizer, |
| 91 size_t* state_index); | 92 size_t* state_index); |
| 92 | 93 |
| 93 static bool IsValidLocationName(const Word& word); | 94 static bool IsValidLocationName(const Word& word); |
| 94 static bool IsZipValid(const Word& word, size_t state_index); | 95 static bool IsZipValid(const Word& word, size_t state_index); |
| 95 static bool IsZipValidForState(const Word& word, size_t state_index); | 96 static bool IsZipValidForState(const Word& word, size_t state_index); |
| 96 | 97 |
| 97 DISALLOW_COPY_AND_ASSIGN(AddressDetector); | 98 DISALLOW_COPY_AND_ASSIGN(AddressParser); |
| 98 }; | 99 }; |
| 99 | 100 |
| 100 } // namespace content | 101 } // namespace content |
| 101 | 102 |
| 102 #endif // CONTENT_RENDERER_ANDROID_ADDRESS_DETECTOR_H_ | 103 #endif // CONTENT_COMMON_ADDRESS_PARSER_H_ |
| OLD | NEW |