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

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

Issue 2354413004: Delete from Sync the artificial search engines created by the omnibox extensions. (Closed)
Patch Set: IsOmniboxExtensionURL Created 4 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chrome_template_url_service_client.h" 5 #include "chrome/browser/search_engines/chrome_template_url_service_client.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "components/history/core/browser/history_service.h" 8 #include "components/history/core/browser/history_service.h"
9 #include "components/search_engines/template_url_service.h" 9 #include "components/search_engines/template_url_service.h"
10 #include "extensions/common/constants.h" 10 #include "extensions/common/constants.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 void ChromeTemplateURLServiceClient::AddKeywordGeneratedVisit(const GURL& url) { 58 void ChromeTemplateURLServiceClient::AddKeywordGeneratedVisit(const GURL& url) {
59 if (history_service_) 59 if (history_service_)
60 history_service_->AddPage(url, base::Time::Now(), NULL, 0, GURL(), 60 history_service_->AddPage(url, base::Time::Now(), NULL, 0, GURL(),
61 history::RedirectList(), 61 history::RedirectList(),
62 ui::PAGE_TRANSITION_KEYWORD_GENERATED, 62 ui::PAGE_TRANSITION_KEYWORD_GENERATED,
63 history::SOURCE_BROWSED, false); 63 history::SOURCE_BROWSED, false);
64 } 64 }
65 65
66 void ChromeTemplateURLServiceClient::RestoreExtensionInfoIfNecessary( 66 bool ChromeTemplateURLServiceClient::IsOmniboxExtensionURL(
67 TemplateURL* template_url) { 67 const std::string& url) {
68 const TemplateURLData& data = template_url->data(); 68 return GURL(url).SchemeIs(extensions::kExtensionScheme);
69 GURL url(data.url());
70 if (url.SchemeIs(extensions::kExtensionScheme)) {
71 const std::string& extension_id = url.host();
72 template_url->set_extension_info(
73 base::MakeUnique<TemplateURL::AssociatedExtensionInfo>(extension_id));
74 template_url->set_type(TemplateURL::OMNIBOX_API_EXTENSION);
75 }
76 } 69 }
77 70
78 void ChromeTemplateURLServiceClient::OnURLVisited( 71 void ChromeTemplateURLServiceClient::OnURLVisited(
79 history::HistoryService* history_service, 72 history::HistoryService* history_service,
80 ui::PageTransition transition, 73 ui::PageTransition transition,
81 const history::URLRow& row, 74 const history::URLRow& row,
82 const history::RedirectList& redirects, 75 const history::RedirectList& redirects,
83 base::Time visit_time) { 76 base::Time visit_time) {
84 DCHECK_EQ(history_service_, history_service); 77 DCHECK_EQ(history_service_, history_service);
85 if (!owner_) 78 if (!owner_)
86 return; 79 return;
87 80
88 TemplateURLService::URLVisitedDetails visited_details; 81 TemplateURLService::URLVisitedDetails visited_details;
89 visited_details.url = row.url(); 82 visited_details.url = row.url();
90 visited_details.is_keyword_transition = 83 visited_details.is_keyword_transition =
91 ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_KEYWORD); 84 ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_KEYWORD);
92 owner_->OnHistoryURLVisited(visited_details); 85 owner_->OnHistoryURLVisited(visited_details);
93 } 86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698