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

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: Created 4 years, 1 month 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 "chrome/browser/extensions/api/preference/preference_api.h"
8 #include "components/history/core/browser/history_service.h" 9 #include "components/history/core/browser/history_service.h"
9 #include "components/search_engines/template_url_service.h" 10 #include "components/search_engines/template_url_service.h"
10 #include "extensions/common/constants.h" 11 #include "extensions/common/constants.h"
11 12
12 ChromeTemplateURLServiceClient::ChromeTemplateURLServiceClient( 13 ChromeTemplateURLServiceClient::ChromeTemplateURLServiceClient(
13 history::HistoryService* history_service) 14 history::HistoryService* history_service,
15 extensions::PreferenceAPI* pref_api)
14 : owner_(NULL), 16 : owner_(NULL),
15 history_service_observer_(this), 17 history_service_observer_(this),
16 history_service_(history_service) { 18 history_service_(history_service),
19 pref_api_(pref_api) {
17 // TODO(sky): bug 1166191. The keywords should be moved into the history 20 // 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 21 // 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 22 // backend can handle automatically adding the search terms as the user
20 // navigates. 23 // navigates.
21 if (history_service_) 24 if (history_service_)
22 history_service_observer_.Add(history_service_); 25 history_service_observer_.Add(history_service_);
23 } 26 }
24 27
25 ChromeTemplateURLServiceClient::~ChromeTemplateURLServiceClient() { 28 ChromeTemplateURLServiceClient::~ChromeTemplateURLServiceClient() {
26 } 29 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 DCHECK_EQ(history_service_, history_service); 80 DCHECK_EQ(history_service_, history_service);
78 if (!owner_) 81 if (!owner_)
79 return; 82 return;
80 83
81 TemplateURLService::URLVisitedDetails visited_details; 84 TemplateURLService::URLVisitedDetails visited_details;
82 visited_details.url = row.url(); 85 visited_details.url = row.url();
83 visited_details.is_keyword_transition = 86 visited_details.is_keyword_transition =
84 ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_KEYWORD); 87 ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_KEYWORD);
85 owner_->OnHistoryURLVisited(visited_details); 88 owner_->OnHistoryURLVisited(visited_details);
86 } 89 }
90
91 void ChromeTemplateURLServiceClient::SetExtensionControlledPref(
92 const std::string extension_id, const std::string pref_name,
93 std::unique_ptr<base::Value> pref_value) {
94 if (!pref_api_)
95 return;
96 pref_api_->SetExtensionControlledPref(extension_id,
97 pref_name,
98 extensions::kExtensionPrefsScopeRegular,
99 pref_value.release());
100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698