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 "chrome/browser/search_engines/template_url_service.h" | 5 #include "chrome/browser/search_engines/template_url_service.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 void TemplateURLService::Add(TemplateURL* template_url) { | 310 void TemplateURLService::Add(TemplateURL* template_url) { |
311 AddNoNotify(template_url); | 311 AddNoNotify(template_url); |
312 NotifyObservers(); | 312 NotifyObservers(); |
313 } | 313 } |
314 | 314 |
315 void TemplateURLService::Remove(const TemplateURL* template_url) { | 315 void TemplateURLService::Remove(const TemplateURL* template_url) { |
316 RemoveNoNotify(template_url); | 316 RemoveNoNotify(template_url); |
317 NotifyObservers(); | 317 NotifyObservers(); |
318 } | 318 } |
319 | 319 |
| 320 void TemplateURLService::RemoveAutoGeneratedSince(base::Time created_after) { |
| 321 RemoveAutoGeneratedBetween(created_after, base::Time()); |
| 322 } |
| 323 |
320 void TemplateURLService::RemoveAutoGeneratedBetween(base::Time created_after, | 324 void TemplateURLService::RemoveAutoGeneratedBetween(base::Time created_after, |
321 base::Time created_before) { | 325 base::Time created_before) { |
| 326 RemoveAutoGeneratedForOriginBetween(GURL(), created_after, created_before); |
| 327 } |
| 328 |
| 329 void TemplateURLService::RemoveAutoGeneratedForOriginBetween( |
| 330 const GURL& origin, |
| 331 base::Time created_after, |
| 332 base::Time created_before) { |
| 333 GURL o(origin.GetOrigin()); |
322 bool should_notify = false; | 334 bool should_notify = false; |
323 for (size_t i = 0; i < template_urls_.size();) { | 335 for (size_t i = 0; i < template_urls_.size();) { |
324 if (template_urls_[i]->date_created() >= created_after && | 336 if (template_urls_[i]->date_created() >= created_after && |
325 (created_before.is_null() || | 337 (created_before.is_null() || |
326 template_urls_[i]->date_created() < created_before) && | 338 template_urls_[i]->date_created() < created_before) && |
327 CanReplace(template_urls_[i])) { | 339 CanReplace(template_urls_[i]) && |
| 340 (o.is_empty() || |
| 341 GenerateSearchURL(template_urls_[i]).GetOrigin() == o)) { |
328 RemoveNoNotify(template_urls_[i]); | 342 RemoveNoNotify(template_urls_[i]); |
329 should_notify = true; | 343 should_notify = true; |
330 } else { | 344 } else { |
331 ++i; | 345 ++i; |
332 } | 346 } |
333 } | 347 } |
334 if (should_notify) | 348 if (should_notify) |
335 NotifyObservers(); | 349 NotifyObservers(); |
336 } | 350 } |
337 | 351 |
338 void TemplateURLService::RemoveAutoGeneratedSince(base::Time created_after) { | |
339 RemoveAutoGeneratedBetween(created_after, base::Time()); | |
340 } | |
341 | 352 |
342 void TemplateURLService::RegisterExtensionKeyword(const Extension* extension) { | 353 void TemplateURLService::RegisterExtensionKeyword(const Extension* extension) { |
343 // TODO(mpcomplete): disable the keyword when the extension is disabled. | 354 // TODO(mpcomplete): disable the keyword when the extension is disabled. |
344 if (extension->omnibox_keyword().empty()) | 355 if (extension->omnibox_keyword().empty()) |
345 return; | 356 return; |
346 | 357 |
347 Load(); | 358 Load(); |
348 if (!loaded_) { | 359 if (!loaded_) { |
349 pending_extension_ids_.push_back(extension->id()); | 360 pending_extension_ids_.push_back(extension->id()); |
350 return; | 361 return; |
(...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1892 dst->set_input_encodings(input_encodings); | 1903 dst->set_input_encodings(input_encodings); |
1893 dst->set_show_in_default_list(specifics.show_in_default_list()); | 1904 dst->set_show_in_default_list(specifics.show_in_default_list()); |
1894 dst->SetSuggestionsURL(specifics.suggestions_url(), 0, 0); | 1905 dst->SetSuggestionsURL(specifics.suggestions_url(), 0, 0); |
1895 dst->SetPrepopulateId(specifics.prepopulate_id()); | 1906 dst->SetPrepopulateId(specifics.prepopulate_id()); |
1896 dst->set_autogenerate_keyword(specifics.autogenerate_keyword()); | 1907 dst->set_autogenerate_keyword(specifics.autogenerate_keyword()); |
1897 dst->SetInstantURL(specifics.instant_url(), 0, 0); | 1908 dst->SetInstantURL(specifics.instant_url(), 0, 0); |
1898 dst->set_last_modified( | 1909 dst->set_last_modified( |
1899 base::Time::FromInternalValue(specifics.last_modified())); | 1910 base::Time::FromInternalValue(specifics.last_modified())); |
1900 dst->set_sync_guid(specifics.sync_guid()); | 1911 dst->set_sync_guid(specifics.sync_guid()); |
1901 } | 1912 } |
OLD | NEW |