1 // Copyright (c) 2011 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 CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ 6 #define CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ 7 #pragma once 8 9 #include <string> 10 11 #include "base/basictypes.h" 12 #include "base/string16.h" 13 14 // All data needed by TemplateURLRef::ReplaceSearchTerms which typically may 15 // only be accessed on the UI thread. 16 class SearchTermsData { 17 public: 18 SearchTermsData(); 19 virtual ~SearchTermsData(); 20 21 // Returns the value for the GOOGLE_BASE_SUGGEST_URL term. 22 std::string GoogleBaseSuggestURLValue() const; 23 24 // Returns the value to use for replacements of type GOOGLE_BASE_URL. 25 virtual std::string GoogleBaseURLValue() const = 0; 26 27 // Returns the locale used by the application. 28 virtual std::string GetApplicationLocale() const = 0; 29 30 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) 31 // Returns the value for the Chrome Omnibox rlz. 32 virtual string16 GetRlzParameterValue() const = 0; 33 #endif 34 35 private: 36 DISALLOW_COPY_AND_ASSIGN(SearchTermsData); 37 }; 38 39 // Implementation of SearchTermsData that is only usable on the UI thread. 40 class UIThreadSearchTermsData : public SearchTermsData { 41 public: 42 UIThreadSearchTermsData(); 43 44 // Implementation of SearchTermsData. 45 virtual std::string GoogleBaseURLValue() const; 46 virtual std::string GetApplicationLocale() const; 47 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) 48 virtual string16 GetRlzParameterValue() const; 49 #endif 50 51 // Used by tests to set the value for the Google base url. This takes 52 // ownership of the given std::string. 53 static void SetGoogleBaseURL(std::string* google_base_url); 54 55 private: 56 static std::string* google_base_url_; 57 58 DISALLOW_COPY_AND_ASSIGN(UIThreadSearchTermsData); 59 }; 60 61 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ 62