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

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

Issue 2479113002: Make extensions DSE persistent in browser prefs (Closed)
Patch Set: Tests updated(rewritten) after review Created 4 years 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/default_search_manager.h"
9 #include "components/search_engines/template_url_service.h" 10 #include "components/search_engines/template_url_service.h"
11 #include "extensions/browser/extension_pref_value_map.h"
10 #include "extensions/common/constants.h" 12 #include "extensions/common/constants.h"
11 13
12 ChromeTemplateURLServiceClient::ChromeTemplateURLServiceClient( 14 ChromeTemplateURLServiceClient::ChromeTemplateURLServiceClient(
13 history::HistoryService* history_service) 15 history::HistoryService* history_service,
16 ExtensionPrefValueMap* extension_prefs_value_map)
14 : owner_(NULL), 17 : owner_(NULL),
15 history_service_observer_(this), 18 history_service_observer_(this),
16 history_service_(history_service) { 19 history_service_(history_service),
20 extension_prefs_value_map_(extension_prefs_value_map) {
17 // TODO(sky): bug 1166191. The keywords should be moved into the history 21 // TODO(sky): bug 1166191. The keywords should be moved into the history
18 // db, which will mean we no longer need this notification and the history 22 // db, which will mean we no longer need this notification and the history
19 // backend can handle automatically adding the search terms as the user 23 // backend can handle automatically adding the search terms as the user
20 // navigates. 24 // navigates.
21 if (history_service_) 25 if (history_service_)
22 history_service_observer_.Add(history_service_); 26 history_service_observer_.Add(history_service_);
23 } 27 }
24 28
25 ChromeTemplateURLServiceClient::~ChromeTemplateURLServiceClient() { 29 ChromeTemplateURLServiceClient::~ChromeTemplateURLServiceClient() {
26 } 30 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 history::RedirectList(), 65 history::RedirectList(),
62 ui::PAGE_TRANSITION_KEYWORD_GENERATED, 66 ui::PAGE_TRANSITION_KEYWORD_GENERATED,
63 history::SOURCE_BROWSED, false); 67 history::SOURCE_BROWSED, false);
64 } 68 }
65 69
66 bool ChromeTemplateURLServiceClient::IsOmniboxExtensionURL( 70 bool ChromeTemplateURLServiceClient::IsOmniboxExtensionURL(
67 const std::string& url) { 71 const std::string& url) {
68 return GURL(url).SchemeIs(extensions::kExtensionScheme); 72 return GURL(url).SchemeIs(extensions::kExtensionScheme);
69 } 73 }
70 74
75 std::string ChromeTemplateURLServiceClient::GetExtensionControllingDSEPref() {
76 if (!extension_prefs_value_map_)
77 return std::string(); // Can be null during testing.
78 return extension_prefs_value_map_->GetExtensionControllingPref(
79 DefaultSearchManager::kDefaultSearchProviderDataPrefName);
80 }
81
71 void ChromeTemplateURLServiceClient::OnURLVisited( 82 void ChromeTemplateURLServiceClient::OnURLVisited(
72 history::HistoryService* history_service, 83 history::HistoryService* history_service,
73 ui::PageTransition transition, 84 ui::PageTransition transition,
74 const history::URLRow& row, 85 const history::URLRow& row,
75 const history::RedirectList& redirects, 86 const history::RedirectList& redirects,
76 base::Time visit_time) { 87 base::Time visit_time) {
77 DCHECK_EQ(history_service_, history_service); 88 DCHECK_EQ(history_service_, history_service);
78 if (!owner_) 89 if (!owner_)
79 return; 90 return;
80 91
81 TemplateURLService::URLVisitedDetails visited_details; 92 TemplateURLService::URLVisitedDetails visited_details;
82 visited_details.url = row.url(); 93 visited_details.url = row.url();
83 visited_details.is_keyword_transition = 94 visited_details.is_keyword_transition =
84 ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_KEYWORD); 95 ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_KEYWORD);
85 owner_->OnHistoryURLVisited(visited_details); 96 owner_->OnHistoryURLVisited(visited_details);
86 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698