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

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

Issue 6758031: Implement a simple Extension App Omnibox provider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/autocomplete.h" 5 #include "chrome/browser/autocomplete/autocomplete.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/i18n/number_formatting.h" 11 #include "base/i18n/number_formatting.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/string_number_conversions.h" 13 #include "base/string_number_conversions.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" 16 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h"
17 #include "chrome/browser/autocomplete/autocomplete_match.h" 17 #include "chrome/browser/autocomplete/autocomplete_match.h"
18 #include "chrome/browser/autocomplete/builtin_provider.h" 18 #include "chrome/browser/autocomplete/builtin_provider.h"
19 #include "chrome/browser/autocomplete/extension_app_provider.h"
19 #include "chrome/browser/autocomplete/history_contents_provider.h" 20 #include "chrome/browser/autocomplete/history_contents_provider.h"
20 #include "chrome/browser/autocomplete/history_quick_provider.h" 21 #include "chrome/browser/autocomplete/history_quick_provider.h"
21 #include "chrome/browser/autocomplete/history_url_provider.h" 22 #include "chrome/browser/autocomplete/history_url_provider.h"
22 #include "chrome/browser/autocomplete/keyword_provider.h" 23 #include "chrome/browser/autocomplete/keyword_provider.h"
23 #include "chrome/browser/autocomplete/search_provider.h" 24 #include "chrome/browser/autocomplete/search_provider.h"
24 #include "chrome/browser/bookmarks/bookmark_model.h" 25 #include "chrome/browser/bookmarks/bookmark_model.h"
25 #include "chrome/browser/external_protocol_handler.h" 26 #include "chrome/browser/external_protocol_handler.h"
26 #include "chrome/browser/net/url_fixer_upper.h" 27 #include "chrome/browser/net/url_fixer_upper.h"
27 #include "chrome/browser/prefs/pref_service.h" 28 #include "chrome/browser/prefs/pref_service.h"
28 #include "chrome/browser/profiles/profile.h" 29 #include "chrome/browser/profiles/profile.h"
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 switches::kEnableHistoryQuickProvider) && 792 switches::kEnableHistoryQuickProvider) &&
792 !CommandLine::ForCurrentProcess()->HasSwitch( 793 !CommandLine::ForCurrentProcess()->HasSwitch(
793 switches::kDisableHistoryQuickProvider)) 794 switches::kDisableHistoryQuickProvider))
794 providers_.push_back(new HistoryQuickProvider(this, profile)); 795 providers_.push_back(new HistoryQuickProvider(this, profile));
795 if (!CommandLine::ForCurrentProcess()->HasSwitch( 796 if (!CommandLine::ForCurrentProcess()->HasSwitch(
796 switches::kDisableHistoryURLProvider)) 797 switches::kDisableHistoryURLProvider))
797 providers_.push_back(new HistoryURLProvider(this, profile)); 798 providers_.push_back(new HistoryURLProvider(this, profile));
798 providers_.push_back(new KeywordProvider(this, profile)); 799 providers_.push_back(new KeywordProvider(this, profile));
799 providers_.push_back(new HistoryContentsProvider(this, profile)); 800 providers_.push_back(new HistoryContentsProvider(this, profile));
800 providers_.push_back(new BuiltinProvider(this, profile)); 801 providers_.push_back(new BuiltinProvider(this, profile));
802 providers_.push_back(new ExtensionAppProvider(this, profile));
801 for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i) 803 for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i)
802 (*i)->AddRef(); 804 (*i)->AddRef();
803 } 805 }
804 806
805 AutocompleteController::~AutocompleteController() { 807 AutocompleteController::~AutocompleteController() {
806 // The providers may have tasks outstanding that hold refs to them. We need 808 // The providers may have tasks outstanding that hold refs to them. We need
807 // to ensure they won't call us back if they outlive us. (Practically, 809 // to ensure they won't call us back if they outlive us. (Practically,
808 // calling Stop() should also cancel those tasks and make it so that we hold 810 // calling Stop() should also cancel those tasks and make it so that we hold
809 // the only refs.) We also don't want to bother notifying anyone of our 811 // the only refs.) We also don't want to bother notifying anyone of our
810 // result changes here, because the notification observer is in the midst of 812 // result changes here, because the notification observer is in the midst of
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 } 983 }
982 } 984 }
983 done_ = true; 985 done_ = true;
984 } 986 }
985 987
986 void AutocompleteController::StartExpireTimer() { 988 void AutocompleteController::StartExpireTimer() {
987 if (result_.HasCopiedMatches()) 989 if (result_.HasCopiedMatches())
988 expire_timer_.Start(base::TimeDelta::FromMilliseconds(kExpireTimeMS), 990 expire_timer_.Start(base::TimeDelta::FromMilliseconds(kExpireTimeMS),
989 this, &AutocompleteController::ExpireCopiedEntries); 991 this, &AutocompleteController::ExpireCopiedEntries);
990 } 992 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698