| 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 #include <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 explicit TemplateURLIsSame(const TemplateURL* other) : other_(other) { | 46 explicit TemplateURLIsSame(const TemplateURL* other) : other_(other) { |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Returns true if both |other| and |url| are NULL or have same field values. | 49 // Returns true if both |other| and |url| are NULL or have same field values. |
| 50 bool operator()(const TemplateURL* url) { | 50 bool operator()(const TemplateURL* url) { |
| 51 if (url == other_ ) | 51 if (url == other_ ) |
| 52 return true; | 52 return true; |
| 53 if (!url || !other_) | 53 if (!url || !other_) |
| 54 return false; | 54 return false; |
| 55 return url->short_name() == other_->short_name() && | 55 return url->short_name() == other_->short_name() && |
| 56 AreKeywordsSame(url, other_) && | 56 url->HasSameKeywordAs(*other_) && |
| 57 url->url() == other_->url() && | 57 url->url() == other_->url() && |
| 58 url->suggestions_url() == other_->suggestions_url() && | 58 url->suggestions_url() == other_->suggestions_url() && |
| 59 url->instant_url() == other_->instant_url() && | 59 url->instant_url() == other_->instant_url() && |
| 60 url->safe_for_autoreplace() == other_->safe_for_autoreplace() && | 60 url->safe_for_autoreplace() == other_->safe_for_autoreplace() && |
| 61 url->favicon_url() == other_->favicon_url() && | 61 url->favicon_url() == other_->favicon_url() && |
| 62 url->show_in_default_list() == other_->show_in_default_list() && | 62 url->show_in_default_list() == other_->show_in_default_list() && |
| 63 url->input_encodings() == other_->input_encodings() && | 63 url->input_encodings() == other_->input_encodings() && |
| 64 url->prepopulate_id() == other_->prepopulate_id(); | 64 url->prepopulate_id() == other_->prepopulate_id(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 // Returns true if both |url1| and |url2| have autogenerated keywords | |
| 69 // or if their keywords are identical. | |
| 70 bool AreKeywordsSame(const TemplateURL* url1, const TemplateURL* url2) { | |
| 71 return (url1->autogenerate_keyword() && url2->autogenerate_keyword()) || | |
| 72 url1->keyword() == url2->keyword(); | |
| 73 } | |
| 74 | |
| 75 const TemplateURL* other_; | 68 const TemplateURL* other_; |
| 76 }; | 69 }; |
| 77 | 70 |
| 78 } // namespace | 71 } // namespace |
| 79 | 72 |
| 80 // Default search engine change tracked by Protector. | 73 // Default search engine change tracked by Protector. |
| 81 class DefaultSearchProviderChange : public BaseSettingChange, | 74 class DefaultSearchProviderChange : public BaseSettingChange, |
| 82 public TemplateURLServiceObserver, | 75 public TemplateURLServiceObserver, |
| 83 public content::NotificationObserver { | 76 public content::NotificationObserver { |
| 84 public: | 77 public: |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 DCHECK(url_service); | 424 DCHECK(url_service); |
| 432 return url_service; | 425 return url_service; |
| 433 } | 426 } |
| 434 | 427 |
| 435 BaseSettingChange* CreateDefaultSearchProviderChange(TemplateURL* actual, | 428 BaseSettingChange* CreateDefaultSearchProviderChange(TemplateURL* actual, |
| 436 TemplateURL* backup) { | 429 TemplateURL* backup) { |
| 437 return new DefaultSearchProviderChange(actual, backup); | 430 return new DefaultSearchProviderChange(actual, backup); |
| 438 } | 431 } |
| 439 | 432 |
| 440 } // namespace protector | 433 } // namespace protector |
| OLD | NEW |