Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: chrome/browser/search_engines/template_url.h

Issue 10033017: More misc. cleanups to minimize future refactoring diffs. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 struct TemplateURLData { 244 struct TemplateURLData {
245 TemplateURLData(); 245 TemplateURLData();
246 ~TemplateURLData(); 246 ~TemplateURLData();
247 247
248 // A short description of the template. This is the name we show to the user 248 // A short description of the template. This is the name we show to the user
249 // in various places that use TemplateURLs. For example, the location bar 249 // in various places that use TemplateURLs. For example, the location bar
250 // shows this when the user selects a substituting match. 250 // shows this when the user selects a substituting match.
251 string16 short_name; 251 string16 short_name;
252 252
253 // The shortcut for this TemplateURL. May be empty. 253 // The shortcut for this TemplateURL. May be empty.
254 void SetKeyword(const string16& keyword) const; 254 void SetKeyword(const string16& keyword);
255 const string16& keyword(const TemplateURL* t_url) const; 255 const string16& keyword(const TemplateURL* t_url) const;
256 // TODO(pkasting): This should only be necessary until we eliminate keyword 256 // TODO(pkasting): This should only be necessary until we eliminate keyword
257 // autogeneration. 257 // autogeneration.
258 const string16& raw_keyword() const { return keyword_; } 258 const string16& raw_keyword() const { return keyword_; }
259 259
260 // Whether to autogenerate a keyword in TemplateURL::GetKeyword(). Most 260 // Whether to autogenerate a keyword in TemplateURL::GetKeyword(). Most
261 // consumers should not need this. 261 // consumers should not need this.
262 // NOTE: Calling SetKeyword() turns this back off. Manual and automatic 262 // NOTE: Calling SetKeyword() turns this back off. Manual and automatic
263 // keywords are mutually exclusive. 263 // keywords are mutually exclusive.
264 void SetAutogenerateKeyword(bool autogenerate_keyword) const; 264 void SetAutogenerateKeyword(bool autogenerate_keyword);
265 bool autogenerate_keyword() const { return autogenerate_keyword_; } 265 bool autogenerate_keyword() const { return autogenerate_keyword_; }
266 266
267 // Ensures that the keyword is generated. Most consumers should not need this 267 // Ensures that the keyword is generated. Most consumers should not need this
268 // because it is done automatically. Use this method on the UI thread, so 268 // because it is done automatically. Use this method on the UI thread, so
269 // the keyword may be accessed on another thread. 269 // the keyword may be accessed on another thread.
270 void EnsureKeyword(const TemplateURL* t_url) const; 270 void EnsureKeyword(const TemplateURL* t_url) const;
271 271
272 // The raw URL for the TemplateURL, which may not be valid as-is (e.g. because 272 // The raw URL for the TemplateURL, which may not be valid as-is (e.g. because
273 // it requires substitutions first). 273 // it requires substitutions first).
274 void SetURL(const std::string& url); 274 void SetURL(const std::string& url);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 std::string sync_guid; 335 std::string sync_guid;
336 336
337 private: 337 private:
338 // Private so we can enforce using the setters. 338 // Private so we can enforce using the setters.
339 // TODO(pkasting): For now these setters are not critical, but later we will 339 // TODO(pkasting): For now these setters are not critical, but later we will
340 // begin using them to ensure that these fields are non-empty. 340 // begin using them to ensure that these fields are non-empty.
341 mutable string16 keyword_; 341 mutable string16 keyword_;
342 std::string url_; 342 std::string url_;
343 343
344 // TODO(pkasting): These fields will go away soon. 344 // TODO(pkasting): These fields will go away soon.
345 mutable bool autogenerate_keyword_; 345 bool autogenerate_keyword_;
346 // True if the keyword was generated. This is used to avoid multiple attempts 346 // True if the keyword was generated. This is used to avoid multiple attempts
347 // if generating a keyword failed. 347 // if generating a keyword failed.
348 mutable bool keyword_generated_; 348 mutable bool keyword_generated_;
349 }; 349 };
350 350
351 351
352 // TemplateURL ---------------------------------------------------------------- 352 // TemplateURL ----------------------------------------------------------------
353 353
354 // A TemplateURL represents a single "search engine", defined primarily as a 354 // A TemplateURL represents a single "search engine", defined primarily as a
355 // subset of the Open Search Description Document 355 // subset of the Open Search Description Document
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 void EnsureKeyword() const { data_.EnsureKeyword(this); } 388 void EnsureKeyword() const { data_.EnsureKeyword(this); }
389 389
390 const std::string& url() const { return data_.url(); } 390 const std::string& url() const { return data_.url(); }
391 const std::string& suggestions_url() const { return data_.suggestions_url; } 391 const std::string& suggestions_url() const { return data_.suggestions_url; }
392 const std::string& instant_url() const { return data_.instant_url; } 392 const std::string& instant_url() const { return data_.instant_url; }
393 const GURL& favicon_url() const { return data_.favicon_url; } 393 const GURL& favicon_url() const { return data_.favicon_url; }
394 394
395 const GURL& originating_url() const { return data_.originating_url; } 395 const GURL& originating_url() const { return data_.originating_url; }
396 396
397 bool show_in_default_list() const { return data_.show_in_default_list; } 397 bool show_in_default_list() const { return data_.show_in_default_list; }
398
399 // Returns true if show_in_default_list() is true and this TemplateURL has a 398 // Returns true if show_in_default_list() is true and this TemplateURL has a
400 // TemplateURLRef that supports replacement. 399 // TemplateURLRef that supports replacement.
401 bool ShowInDefaultList() const; 400 bool ShowInDefaultList() const;
402 401
403 bool safe_for_autoreplace() const { return data_.safe_for_autoreplace; } 402 bool safe_for_autoreplace() const { return data_.safe_for_autoreplace; }
404 403
405 const std::vector<std::string>& input_encodings() const { 404 const std::vector<std::string>& input_encodings() const {
406 return data_.input_encodings; 405 return data_.input_encodings;
407 } 406 }
408 407
(...skipping 26 matching lines...) Expand all
435 std::string GetExtensionId() const; 434 std::string GetExtensionId() const;
436 bool IsExtensionKeyword() const; 435 bool IsExtensionKeyword() const;
437 436
438 private: 437 private:
439 friend class TemplateURLService; 438 friend class TemplateURLService;
440 439
441 void SetURL(const std::string& url); 440 void SetURL(const std::string& url);
442 void SetPrepopulateId(int id); 441 void SetPrepopulateId(int id);
443 442
444 // Invalidates cached values on this object and its child TemplateURLRefs. 443 // Invalidates cached values on this object and its child TemplateURLRefs.
445 void InvalidateCachedValues() const; 444 void InvalidateCachedValues();
446 445
447 TemplateURLData data_; 446 TemplateURLData data_;
448 TemplateURLRef url_ref_; 447 TemplateURLRef url_ref_;
449 TemplateURLRef suggestions_url_ref_; 448 TemplateURLRef suggestions_url_ref_;
450 TemplateURLRef instant_url_ref_; 449 TemplateURLRef instant_url_ref_;
451 450
452 // TODO(sky): Add date last parsed OSD file. 451 // TODO(sky): Add date last parsed OSD file.
453 }; 452 };
454 453
455 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ 454 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698