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

Side by Side Diff: chrome/browser/search_engines/template_url_service.cc

Issue 9379008: Add origin-based deletion to BrowsingDataRemover (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing to ToT. Created 8 years, 10 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 #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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 NotifyObservers(); 318 NotifyObservers();
319 } 319 }
320 320
321 void TemplateURLService::Remove(const TemplateURL* template_url) { 321 void TemplateURLService::Remove(const TemplateURL* template_url) {
322 RemoveNoNotify(template_url); 322 RemoveNoNotify(template_url);
323 NotifyObservers(); 323 NotifyObservers();
324 } 324 }
325 325
326 void TemplateURLService::RemoveAutoGeneratedBetween(base::Time created_after, 326 void TemplateURLService::RemoveAutoGeneratedBetween(base::Time created_after,
327 base::Time created_before) { 327 base::Time created_before) {
328 RemoveAutoGeneratedForOriginBetween(created_after, created_before, GURL());
329 }
330
331 void TemplateURLService::RemoveAutoGeneratedSince(base::Time created_after) {
332 RemoveAutoGeneratedForOriginBetween(created_after, base::Time(), GURL());
333 }
334
335 void TemplateURLService::RemoveAutoGeneratedForOriginBetween(
336 base::Time created_after,
337 base::Time created_before,
338 const GURL& origin) {
339 GURL o(origin.GetOrigin());
328 bool should_notify = false; 340 bool should_notify = false;
329 for (size_t i = 0; i < template_urls_.size();) { 341 for (size_t i = 0; i < template_urls_.size();) {
330 if (template_urls_[i]->date_created() >= created_after && 342 if (template_urls_[i]->date_created() >= created_after &&
331 (created_before.is_null() || 343 (created_before.is_null() ||
332 template_urls_[i]->date_created() < created_before) && 344 template_urls_[i]->date_created() < created_before) &&
333 CanReplace(template_urls_[i])) { 345 CanReplace(template_urls_[i]) &&
346 (o.is_empty() ||
347 GenerateSearchURL(template_urls_[i]).GetOrigin() == o)) {
334 RemoveNoNotify(template_urls_[i]); 348 RemoveNoNotify(template_urls_[i]);
335 should_notify = true; 349 should_notify = true;
336 } else { 350 } else {
337 ++i; 351 ++i;
338 } 352 }
339 } 353 }
340 if (should_notify) 354 if (should_notify)
341 NotifyObservers(); 355 NotifyObservers();
342 } 356 }
343 357
344 void TemplateURLService::RemoveAutoGeneratedSince(base::Time created_after) {
345 RemoveAutoGeneratedBetween(created_after, base::Time());
346 }
347 358
348 void TemplateURLService::RegisterExtensionKeyword(const Extension* extension) { 359 void TemplateURLService::RegisterExtensionKeyword(const Extension* extension) {
349 // TODO(mpcomplete): disable the keyword when the extension is disabled. 360 // TODO(mpcomplete): disable the keyword when the extension is disabled.
350 if (extension->omnibox_keyword().empty()) 361 if (extension->omnibox_keyword().empty())
351 return; 362 return;
352 363
353 Load(); 364 Load();
354 if (!loaded_) { 365 if (!loaded_) {
355 pending_extension_ids_.push_back(extension->id()); 366 pending_extension_ids_.push_back(extension->id());
356 return; 367 return;
(...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 dst->set_input_encodings(input_encodings); 1909 dst->set_input_encodings(input_encodings);
1899 dst->set_show_in_default_list(specifics.show_in_default_list()); 1910 dst->set_show_in_default_list(specifics.show_in_default_list());
1900 dst->SetSuggestionsURL(specifics.suggestions_url(), 0, 0); 1911 dst->SetSuggestionsURL(specifics.suggestions_url(), 0, 0);
1901 dst->SetPrepopulateId(specifics.prepopulate_id()); 1912 dst->SetPrepopulateId(specifics.prepopulate_id());
1902 dst->set_autogenerate_keyword(specifics.autogenerate_keyword()); 1913 dst->set_autogenerate_keyword(specifics.autogenerate_keyword());
1903 dst->SetInstantURL(specifics.instant_url(), 0, 0); 1914 dst->SetInstantURL(specifics.instant_url(), 0, 0);
1904 dst->set_last_modified( 1915 dst->set_last_modified(
1905 base::Time::FromInternalValue(specifics.last_modified())); 1916 base::Time::FromInternalValue(specifics.last_modified()));
1906 dst->set_sync_guid(specifics.sync_guid()); 1917 dst->set_sync_guid(specifics.sync_guid());
1907 } 1918 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698