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

Side by Side Diff: chrome/browser/autocomplete/shortcuts_backend.cc

Issue 425303002: Move extension notifications to extensions/browser/notification_types.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (extension-notifications) rebase Created 6 years, 4 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/autocomplete/shortcuts_backend.h" 5 #include "chrome/browser/autocomplete/shortcuts_backend.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 12 matching lines...) Expand all
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/search_engines/template_url_service_factory.h" 24 #include "chrome/browser/search_engines/template_url_service_factory.h"
25 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" 25 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
26 #include "chrome/common/chrome_constants.h" 26 #include "chrome/common/chrome_constants.h"
27 #include "components/autocomplete/autocomplete_input.h" 27 #include "components/autocomplete/autocomplete_input.h"
28 #include "components/autocomplete/autocomplete_match.h" 28 #include "components/autocomplete/autocomplete_match.h"
29 #include "components/autocomplete/autocomplete_match_type.h" 29 #include "components/autocomplete/autocomplete_match_type.h"
30 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
31 #include "content/public/browser/notification_details.h" 31 #include "content/public/browser/notification_details.h"
32 #include "content/public/browser/notification_source.h" 32 #include "content/public/browser/notification_source.h"
33 #include "extensions/browser/notification_types.h"
33 #include "extensions/common/extension.h" 34 #include "extensions/common/extension.h"
34 35
35 using content::BrowserThread; 36 using content::BrowserThread;
36 37
37 namespace { 38 namespace {
38 39
39 // Takes Match classification vector and removes all matched positions, 40 // Takes Match classification vector and removes all matched positions,
40 // compacting repetitions if necessary. 41 // compacting repetitions if necessary.
41 std::string StripMatchMarkers(const ACMatchClassifications& matches) { 42 std::string StripMatchMarkers(const ACMatchClassifications& matches) {
42 ACMatchClassifications unmatched; 43 ACMatchClassifications unmatched;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 : profile_(profile), 77 : profile_(profile),
77 current_state_(NOT_INITIALIZED), 78 current_state_(NOT_INITIALIZED),
78 no_db_access_(suppress_db) { 79 no_db_access_(suppress_db) {
79 if (!suppress_db) { 80 if (!suppress_db) {
80 db_ = new history::ShortcutsDatabase( 81 db_ = new history::ShortcutsDatabase(
81 profile->GetPath().Append(chrome::kShortcutsDatabaseName)); 82 profile->GetPath().Append(chrome::kShortcutsDatabaseName));
82 } 83 }
83 // |profile| can be NULL in tests. 84 // |profile| can be NULL in tests.
84 if (profile) { 85 if (profile) {
85 notification_registrar_.Add( 86 notification_registrar_.Add(
86 this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, 87 this,
88 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
87 content::Source<Profile>(profile)); 89 content::Source<Profile>(profile));
88 notification_registrar_.Add( 90 notification_registrar_.Add(
89 this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, 91 this, chrome::NOTIFICATION_HISTORY_URLS_DELETED,
90 content::Source<Profile>(profile)); 92 content::Source<Profile>(profile));
91 } 93 }
92 } 94 }
93 95
94 bool ShortcutsBackend::Init() { 96 bool ShortcutsBackend::Init() {
95 if (current_state_ != NOT_INITIALIZED) 97 if (current_state_ != NOT_INITIALIZED)
96 return false; 98 return false;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 BrowserThread::CurrentlyOn(BrowserThread::UI)); 170 BrowserThread::CurrentlyOn(BrowserThread::UI));
169 notification_registrar_.RemoveAll(); 171 notification_registrar_.RemoveAll();
170 } 172 }
171 173
172 void ShortcutsBackend::Observe(int type, 174 void ShortcutsBackend::Observe(int type,
173 const content::NotificationSource& source, 175 const content::NotificationSource& source,
174 const content::NotificationDetails& details) { 176 const content::NotificationDetails& details) {
175 if (!initialized()) 177 if (!initialized())
176 return; 178 return;
177 179
178 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED) { 180 if (type == extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED) {
179 // When an extension is unloaded, we want to remove any Shortcuts associated 181 // When an extension is unloaded, we want to remove any Shortcuts associated
180 // with it. 182 // with it.
181 DeleteShortcutsWithURL(content::Details<extensions::UnloadedExtensionInfo>( 183 DeleteShortcutsWithURL(content::Details<extensions::UnloadedExtensionInfo>(
182 details)->extension->url(), false); 184 details)->extension->url(), false);
183 return; 185 return;
184 } 186 }
185 187
186 DCHECK_EQ(chrome::NOTIFICATION_HISTORY_URLS_DELETED, type); 188 DCHECK_EQ(chrome::NOTIFICATION_HISTORY_URLS_DELETED, type);
187 const history::URLsDeletedDetails* deleted_details = 189 const history::URLsDeletedDetails* deleted_details =
188 content::Details<const history::URLsDeletedDetails>(details).ptr(); 190 content::Details<const history::URLsDeletedDetails>(details).ptr();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 guid_map_.clear(); 321 guid_map_.clear();
320 FOR_EACH_OBSERVER(ShortcutsBackendObserver, observer_list_, 322 FOR_EACH_OBSERVER(ShortcutsBackendObserver, observer_list_,
321 OnShortcutsChanged()); 323 OnShortcutsChanged());
322 return no_db_access_ || 324 return no_db_access_ ||
323 BrowserThread::PostTask( 325 BrowserThread::PostTask(
324 BrowserThread::DB, FROM_HERE, 326 BrowserThread::DB, FROM_HERE,
325 base::Bind(base::IgnoreResult( 327 base::Bind(base::IgnoreResult(
326 &history::ShortcutsDatabase::DeleteAllShortcuts), 328 &history::ShortcutsDatabase::DeleteAllShortcuts),
327 db_.get())); 329 db_.get()));
328 } 330 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698