Commit 94676744 authored by rdevlin.cronin's avatar rdevlin.cronin Committed by Commit bot

[Extensions] Convert some ChromeSyncExtensionFunctions

SyncExtensionFunctions, AsyncExtensionFunctions,
ChromeSyncExtensionFunctions, and ChromeAsyncExtensionFunctions are
deprecated.

Remove ChromeSyncExtensionFunctions from:
- launcher_search_provider
- hotword_private
- i18n
- identity
- omnibox

BUG=634140

Review-Url: https://codereview.chromium.org/2344653002
Cr-Commit-Position: refs/heads/master@{#418733}
parent 9cedf753
...@@ -18,7 +18,8 @@ LauncherSearchProviderSetSearchResultsFunction:: ...@@ -18,7 +18,8 @@ LauncherSearchProviderSetSearchResultsFunction::
~LauncherSearchProviderSetSearchResultsFunction() { ~LauncherSearchProviderSetSearchResultsFunction() {
} }
bool LauncherSearchProviderSetSearchResultsFunction::RunSync() { ExtensionFunction::ResponseAction
LauncherSearchProviderSetSearchResultsFunction::Run() {
using chromeos::launcher_search_provider::ErrorReporter; using chromeos::launcher_search_provider::ErrorReporter;
using chromeos::launcher_search_provider::Service; using chromeos::launcher_search_provider::Service;
using extensions::api::launcher_search_provider::SetSearchResults::Params; using extensions::api::launcher_search_provider::SetSearchResults::Params;
...@@ -28,11 +29,11 @@ bool LauncherSearchProviderSetSearchResultsFunction::RunSync() { ...@@ -28,11 +29,11 @@ bool LauncherSearchProviderSetSearchResultsFunction::RunSync() {
std::unique_ptr<ErrorReporter> error_reporter( std::unique_ptr<ErrorReporter> error_reporter(
new ErrorReporter(render_frame_host())); new ErrorReporter(render_frame_host()));
Service* const service = Service::Get(GetProfile()); Service* const service = Service::Get(browser_context());
service->SetSearchResults(extension(), std::move(error_reporter), service->SetSearchResults(extension(), std::move(error_reporter),
params->query_id, params->results); params->query_id, params->results);
return true; return RespondNow(NoArguments());
} }
} // namespace extensions } // namespace extensions
...@@ -5,19 +5,19 @@ ...@@ -5,19 +5,19 @@
#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_LAUNCHER_SEARCH_PROVIDER_H_ #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_LAUNCHER_SEARCH_PROVIDER_H_
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_LAUNCHER_SEARCH_PROVIDER_H_ #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_LAUNCHER_SEARCH_PROVIDER_H_
#include "chrome/browser/extensions/chrome_extension_function.h" #include "extensions/browser/extension_function.h"
namespace extensions { namespace extensions {
// Implements chrome.launcherSearchProvider.setSearchResults method. // Implements chrome.launcherSearchProvider.setSearchResults method.
class LauncherSearchProviderSetSearchResultsFunction class LauncherSearchProviderSetSearchResultsFunction
: public ChromeSyncExtensionFunction { : public UIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("launcherSearchProvider.setSearchResults", DECLARE_EXTENSION_FUNCTION("launcherSearchProvider.setSearchResults",
LAUNCHERSEARCHPROVIDER_SETSEARCHRESULTS) LAUNCHERSEARCHPROVIDER_SETSEARCHRESULTS)
protected: protected:
~LauncherSearchProviderSetSearchResultsFunction() override; ~LauncherSearchProviderSetSearchResultsFunction() override;
bool RunSync() override; ResponseAction Run() override;
}; };
} // namespace extensions } // namespace extensions
......
...@@ -60,8 +60,7 @@ class HotwordPrivateEventService : public BrowserContextKeyedAPI { ...@@ -60,8 +60,7 @@ class HotwordPrivateEventService : public BrowserContextKeyedAPI {
PrefChangeRegistrar pref_change_registrar_; PrefChangeRegistrar pref_change_registrar_;
}; };
class HotwordPrivateSetEnabledFunction : public UIThreadExtensionFunction {
class HotwordPrivateSetEnabledFunction : public ChromeSyncExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("hotwordPrivate.setEnabled", DECLARE_EXTENSION_FUNCTION("hotwordPrivate.setEnabled",
HOTWORDPRIVATE_SETENABLED) HOTWORDPRIVATE_SETENABLED)
...@@ -70,11 +69,11 @@ class HotwordPrivateSetEnabledFunction : public ChromeSyncExtensionFunction { ...@@ -70,11 +69,11 @@ class HotwordPrivateSetEnabledFunction : public ChromeSyncExtensionFunction {
~HotwordPrivateSetEnabledFunction() override {} ~HotwordPrivateSetEnabledFunction() override {}
// ExtensionFunction: // ExtensionFunction:
bool RunSync() override; ResponseAction Run() override;
}; };
class HotwordPrivateSetAudioLoggingEnabledFunction class HotwordPrivateSetAudioLoggingEnabledFunction
: public ChromeSyncExtensionFunction { : public UIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("hotwordPrivate.setAudioLoggingEnabled", DECLARE_EXTENSION_FUNCTION("hotwordPrivate.setAudioLoggingEnabled",
HOTWORDPRIVATE_SETAUDIOLOGGINGENABLED) HOTWORDPRIVATE_SETAUDIOLOGGINGENABLED)
...@@ -83,11 +82,11 @@ class HotwordPrivateSetAudioLoggingEnabledFunction ...@@ -83,11 +82,11 @@ class HotwordPrivateSetAudioLoggingEnabledFunction
~HotwordPrivateSetAudioLoggingEnabledFunction() override {} ~HotwordPrivateSetAudioLoggingEnabledFunction() override {}
// ExtensionFunction: // ExtensionFunction:
bool RunSync() override; ResponseAction Run() override;
}; };
class HotwordPrivateSetHotwordAlwaysOnSearchEnabledFunction class HotwordPrivateSetHotwordAlwaysOnSearchEnabledFunction
: public ChromeSyncExtensionFunction { : public UIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("hotwordPrivate.setHotwordAlwaysOnSearchEnabled", DECLARE_EXTENSION_FUNCTION("hotwordPrivate.setHotwordAlwaysOnSearchEnabled",
HOTWORDPRIVATE_SETHOTWORDALWAYSONSEARCHENABLED) HOTWORDPRIVATE_SETHOTWORDALWAYSONSEARCHENABLED)
...@@ -96,10 +95,10 @@ class HotwordPrivateSetHotwordAlwaysOnSearchEnabledFunction ...@@ -96,10 +95,10 @@ class HotwordPrivateSetHotwordAlwaysOnSearchEnabledFunction
~HotwordPrivateSetHotwordAlwaysOnSearchEnabledFunction() override {} ~HotwordPrivateSetHotwordAlwaysOnSearchEnabledFunction() override {}
// ExtensionFunction: // ExtensionFunction:
bool RunSync() override; ResponseAction Run() override;
}; };
class HotwordPrivateGetStatusFunction : public ChromeSyncExtensionFunction { class HotwordPrivateGetStatusFunction : public UIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("hotwordPrivate.getStatus", DECLARE_EXTENSION_FUNCTION("hotwordPrivate.getStatus",
HOTWORDPRIVATE_GETSTATUS) HOTWORDPRIVATE_GETSTATUS)
...@@ -108,11 +107,11 @@ class HotwordPrivateGetStatusFunction : public ChromeSyncExtensionFunction { ...@@ -108,11 +107,11 @@ class HotwordPrivateGetStatusFunction : public ChromeSyncExtensionFunction {
~HotwordPrivateGetStatusFunction() override {} ~HotwordPrivateGetStatusFunction() override {}
// ExtensionFunction: // ExtensionFunction:
bool RunSync() override; ResponseAction Run() override;
}; };
class HotwordPrivateSetHotwordSessionStateFunction class HotwordPrivateSetHotwordSessionStateFunction
: public ChromeSyncExtensionFunction { : public UIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("hotwordPrivate.setHotwordSessionState", DECLARE_EXTENSION_FUNCTION("hotwordPrivate.setHotwordSessionState",
HOTWORDPRIVATE_SETHOTWORDSESSIONSTATE); HOTWORDPRIVATE_SETHOTWORDSESSIONSTATE);
...@@ -121,11 +120,11 @@ class HotwordPrivateSetHotwordSessionStateFunction ...@@ -121,11 +120,11 @@ class HotwordPrivateSetHotwordSessionStateFunction
~HotwordPrivateSetHotwordSessionStateFunction() override {} ~HotwordPrivateSetHotwordSessionStateFunction() override {}
// ExtensionFunction: // ExtensionFunction:
bool RunSync() override; ResponseAction Run() override;
}; };
class HotwordPrivateNotifyHotwordRecognitionFunction class HotwordPrivateNotifyHotwordRecognitionFunction
: public ChromeSyncExtensionFunction { : public UIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("hotwordPrivate.notifyHotwordRecognition", DECLARE_EXTENSION_FUNCTION("hotwordPrivate.notifyHotwordRecognition",
HOTWORDPRIVATE_NOTIFYHOTWORDRECOGNITION); HOTWORDPRIVATE_NOTIFYHOTWORDRECOGNITION);
...@@ -134,11 +133,10 @@ class HotwordPrivateNotifyHotwordRecognitionFunction ...@@ -134,11 +133,10 @@ class HotwordPrivateNotifyHotwordRecognitionFunction
~HotwordPrivateNotifyHotwordRecognitionFunction() override {} ~HotwordPrivateNotifyHotwordRecognitionFunction() override {}
// ExtensionFunction: // ExtensionFunction:
bool RunSync() override; ResponseAction Run() override;
}; };
class HotwordPrivateGetLaunchStateFunction : class HotwordPrivateGetLaunchStateFunction : public UIThreadExtensionFunction {
public ChromeSyncExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("hotwordPrivate.getLaunchState", DECLARE_EXTENSION_FUNCTION("hotwordPrivate.getLaunchState",
HOTWORDPRIVATE_GETLAUNCHSTATE) HOTWORDPRIVATE_GETLAUNCHSTATE)
...@@ -147,11 +145,10 @@ class HotwordPrivateGetLaunchStateFunction : ...@@ -147,11 +145,10 @@ class HotwordPrivateGetLaunchStateFunction :
~HotwordPrivateGetLaunchStateFunction() override {} ~HotwordPrivateGetLaunchStateFunction() override {}
// ExtensionFunction: // ExtensionFunction:
bool RunSync() override; ResponseAction Run() override;
}; };
class HotwordPrivateStartTrainingFunction : class HotwordPrivateStartTrainingFunction : public UIThreadExtensionFunction {
public ChromeSyncExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("hotwordPrivate.startTraining", DECLARE_EXTENSION_FUNCTION("hotwordPrivate.startTraining",
HOTWORDPRIVATE_STARTTRAINING) HOTWORDPRIVATE_STARTTRAINING)
...@@ -160,11 +157,11 @@ class HotwordPrivateStartTrainingFunction : ...@@ -160,11 +157,11 @@ class HotwordPrivateStartTrainingFunction :
~HotwordPrivateStartTrainingFunction() override {} ~HotwordPrivateStartTrainingFunction() override {}
// ExtensionFunction: // ExtensionFunction:
bool RunSync() override; ResponseAction Run() override;
}; };
class HotwordPrivateFinalizeSpeakerModelFunction : class HotwordPrivateFinalizeSpeakerModelFunction
public ChromeSyncExtensionFunction { : public UIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("hotwordPrivate.finalizeSpeakerModel", DECLARE_EXTENSION_FUNCTION("hotwordPrivate.finalizeSpeakerModel",
HOTWORDPRIVATE_FINALIZESPEAKERMODEL) HOTWORDPRIVATE_FINALIZESPEAKERMODEL)
...@@ -173,11 +170,11 @@ class HotwordPrivateFinalizeSpeakerModelFunction : ...@@ -173,11 +170,11 @@ class HotwordPrivateFinalizeSpeakerModelFunction :
~HotwordPrivateFinalizeSpeakerModelFunction() override {} ~HotwordPrivateFinalizeSpeakerModelFunction() override {}
// ExtensionFunction: // ExtensionFunction:
bool RunSync() override; ResponseAction Run() override;
}; };
class HotwordPrivateNotifySpeakerModelSavedFunction : class HotwordPrivateNotifySpeakerModelSavedFunction
public ChromeSyncExtensionFunction { : public UIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("hotwordPrivate.notifySpeakerModelSaved", DECLARE_EXTENSION_FUNCTION("hotwordPrivate.notifySpeakerModelSaved",
HOTWORDPRIVATE_NOTIFYSPEAKERMODELSAVED) HOTWORDPRIVATE_NOTIFYSPEAKERMODELSAVED)
...@@ -186,11 +183,10 @@ class HotwordPrivateNotifySpeakerModelSavedFunction : ...@@ -186,11 +183,10 @@ class HotwordPrivateNotifySpeakerModelSavedFunction :
~HotwordPrivateNotifySpeakerModelSavedFunction() override {} ~HotwordPrivateNotifySpeakerModelSavedFunction() override {}
// ExtensionFunction: // ExtensionFunction:
bool RunSync() override; ResponseAction Run() override;
}; };
class HotwordPrivateStopTrainingFunction : class HotwordPrivateStopTrainingFunction : public UIThreadExtensionFunction {
public ChromeSyncExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("hotwordPrivate.stopTraining", DECLARE_EXTENSION_FUNCTION("hotwordPrivate.stopTraining",
HOTWORDPRIVATE_STOPTRAINING) HOTWORDPRIVATE_STOPTRAINING)
...@@ -199,11 +195,11 @@ class HotwordPrivateStopTrainingFunction : ...@@ -199,11 +195,11 @@ class HotwordPrivateStopTrainingFunction :
~HotwordPrivateStopTrainingFunction() override {} ~HotwordPrivateStopTrainingFunction() override {}
// ExtensionFunction: // ExtensionFunction:
bool RunSync() override; ResponseAction Run() override;
}; };
class HotwordPrivateGetLocalizedStringsFunction class HotwordPrivateGetLocalizedStringsFunction
: public ChromeSyncExtensionFunction { : public UIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("hotwordPrivate.getLocalizedStrings", DECLARE_EXTENSION_FUNCTION("hotwordPrivate.getLocalizedStrings",
HOTWORDPRIVATE_GETLOCALIZEDSTRINGS) HOTWORDPRIVATE_GETLOCALIZEDSTRINGS)
...@@ -212,7 +208,7 @@ class HotwordPrivateGetLocalizedStringsFunction ...@@ -212,7 +208,7 @@ class HotwordPrivateGetLocalizedStringsFunction
~HotwordPrivateGetLocalizedStringsFunction() override {} ~HotwordPrivateGetLocalizedStringsFunction() override {}
// ExtensionFunction: // ExtensionFunction:
bool RunSync() override; ResponseAction Run() override;
}; };
class HotwordPrivateSetAudioHistoryEnabledFunction class HotwordPrivateSetAudioHistoryEnabledFunction
...@@ -245,8 +241,8 @@ class HotwordPrivateGetAudioHistoryEnabledFunction ...@@ -245,8 +241,8 @@ class HotwordPrivateGetAudioHistoryEnabledFunction
void SetResultAndSendResponse(bool success, bool new_enabled_value); void SetResultAndSendResponse(bool success, bool new_enabled_value);
}; };
class HotwordPrivateSpeakerModelExistsResultFunction : class HotwordPrivateSpeakerModelExistsResultFunction
public ChromeSyncExtensionFunction { : public UIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("hotwordPrivate.speakerModelExistsResult", DECLARE_EXTENSION_FUNCTION("hotwordPrivate.speakerModelExistsResult",
HOTWORDPRIVATE_SPEAKERMODELEXISTSRESULT) HOTWORDPRIVATE_SPEAKERMODELEXISTSRESULT)
...@@ -255,7 +251,7 @@ class HotwordPrivateSpeakerModelExistsResultFunction : ...@@ -255,7 +251,7 @@ class HotwordPrivateSpeakerModelExistsResultFunction :
~HotwordPrivateSpeakerModelExistsResultFunction() override {} ~HotwordPrivateSpeakerModelExistsResultFunction() override {}
// ExtensionFunction: // ExtensionFunction:
bool RunSync() override; ResponseAction Run() override;
}; };
} // namespace extensions } // namespace extensions
......
...@@ -27,9 +27,10 @@ static const char kEmptyAcceptLanguagesError[] = "accept-languages is empty."; ...@@ -27,9 +27,10 @@ static const char kEmptyAcceptLanguagesError[] = "accept-languages is empty.";
} }
bool I18nGetAcceptLanguagesFunction::RunSync() { ExtensionFunction::ResponseAction I18nGetAcceptLanguagesFunction::Run() {
std::string accept_languages = std::string accept_languages = Profile::FromBrowserContext(browser_context())
GetProfile()->GetPrefs()->GetString(prefs::kAcceptLanguages); ->GetPrefs()
->GetString(prefs::kAcceptLanguages);
// Currently, there are 2 ways to set browser's accept-languages: through UI // Currently, there are 2 ways to set browser's accept-languages: through UI
// or directly modify the preference file. The accept-languages set through // or directly modify the preference file. The accept-languages set through
// UI is guranteed to be valid, and the accept-languages string returned from // UI is guranteed to be valid, and the accept-languages string returned from
...@@ -40,23 +41,19 @@ bool I18nGetAcceptLanguagesFunction::RunSync() { ...@@ -40,23 +41,19 @@ bool I18nGetAcceptLanguagesFunction::RunSync() {
// of the language code) on accept-languages set through editing preference // of the language code) on accept-languages set through editing preference
// file directly. So, here, we're adding extra checks to be resistant to // file directly. So, here, we're adding extra checks to be resistant to
// crashes caused by data corruption. // crashes caused by data corruption.
if (accept_languages.empty()) { if (accept_languages.empty())
error_ = kEmptyAcceptLanguagesError; return RespondNow(Error(kEmptyAcceptLanguagesError));
return false;
}
std::vector<std::string> languages = base::SplitString( std::vector<std::string> languages = base::SplitString(
accept_languages, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); accept_languages, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
languages.erase(std::remove(languages.begin(), languages.end(), ""), languages.erase(std::remove(languages.begin(), languages.end(), ""),
languages.end()); languages.end());
if (languages.empty()) { if (languages.empty())
error_ = kEmptyAcceptLanguagesError; return RespondNow(Error(kEmptyAcceptLanguagesError));
return false;
}
results_ = GetAcceptLanguages::Results::Create(languages); return RespondNow(
return true; ArgumentList(GetAcceptLanguages::Results::Create(languages)));
} }
} // namespace extensions } // namespace extensions
...@@ -5,16 +5,13 @@ ...@@ -5,16 +5,13 @@
#ifndef CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_ #ifndef CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_
#define CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_ #define CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_
#include "chrome/browser/extensions/chrome_extension_function.h" #include "extensions/browser/extension_function.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
class Profile;
namespace extensions { namespace extensions {
class I18nGetAcceptLanguagesFunction : public ChromeSyncExtensionFunction { class I18nGetAcceptLanguagesFunction : public UIThreadExtensionFunction {
~I18nGetAcceptLanguagesFunction() override {} ~I18nGetAcceptLanguagesFunction() override {}
bool RunSync() override; ResponseAction Run() override;
DECLARE_EXTENSION_FUNCTION("i18n.getAcceptLanguages", I18N_GETACCEPTLANGUAGES) DECLARE_EXTENSION_FUNCTION("i18n.getAcceptLanguages", I18N_GETACCEPTLANGUAGES)
}; };
......
...@@ -928,18 +928,17 @@ IdentityRemoveCachedAuthTokenFunction:: ...@@ -928,18 +928,17 @@ IdentityRemoveCachedAuthTokenFunction::
~IdentityRemoveCachedAuthTokenFunction() { ~IdentityRemoveCachedAuthTokenFunction() {
} }
bool IdentityRemoveCachedAuthTokenFunction::RunSync() { ExtensionFunction::ResponseAction IdentityRemoveCachedAuthTokenFunction::Run() {
if (GetProfile()->IsOffTheRecord()) { if (Profile::FromBrowserContext(browser_context())->IsOffTheRecord())
error_ = identity_constants::kOffTheRecord; return RespondNow(Error(identity_constants::kOffTheRecord));
return false;
}
std::unique_ptr<identity::RemoveCachedAuthToken::Params> params( std::unique_ptr<identity::RemoveCachedAuthToken::Params> params(
identity::RemoveCachedAuthToken::Params::Create(*args_)); identity::RemoveCachedAuthToken::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get()); EXTENSION_FUNCTION_VALIDATE(params.get());
IdentityAPI::GetFactoryInstance()->Get(GetProfile())->EraseCachedToken( IdentityAPI::GetFactoryInstance()
extension()->id(), params->details.token); ->Get(browser_context())
return true; ->EraseCachedToken(extension()->id(), params->details.token);
return RespondNow(NoArguments());
} }
IdentityLaunchWebAuthFlowFunction::IdentityLaunchWebAuthFlowFunction() {} IdentityLaunchWebAuthFlowFunction::IdentityLaunchWebAuthFlowFunction() {}
......
...@@ -318,8 +318,7 @@ class IdentityGetProfileUserInfoFunction ...@@ -318,8 +318,7 @@ class IdentityGetProfileUserInfoFunction
ExtensionFunction::ResponseAction Run() override; ExtensionFunction::ResponseAction Run() override;
}; };
class IdentityRemoveCachedAuthTokenFunction class IdentityRemoveCachedAuthTokenFunction : public UIThreadExtensionFunction {
: public ChromeSyncExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("identity.removeCachedAuthToken", DECLARE_EXTENSION_FUNCTION("identity.removeCachedAuthToken",
EXPERIMENTAL_IDENTITY_REMOVECACHEDAUTHTOKEN) EXPERIMENTAL_IDENTITY_REMOVECACHEDAUTHTOKEN)
...@@ -328,8 +327,8 @@ class IdentityRemoveCachedAuthTokenFunction ...@@ -328,8 +327,8 @@ class IdentityRemoveCachedAuthTokenFunction
protected: protected:
~IdentityRemoveCachedAuthTokenFunction() override; ~IdentityRemoveCachedAuthTokenFunction() override;
// SyncExtensionFunction implementation: // ExtensionFunction:
bool RunSync() override; ResponseAction Run() override;
}; };
class IdentityLaunchWebAuthFlowFunction : public ChromeAsyncExtensionFunction, class IdentityLaunchWebAuthFlowFunction : public ChromeAsyncExtensionFunction,
......
...@@ -284,33 +284,35 @@ void BrowserContextKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies() { ...@@ -284,33 +284,35 @@ void BrowserContextKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies() {
DependsOn(TemplateURLServiceFactory::GetInstance()); DependsOn(TemplateURLServiceFactory::GetInstance());
} }
bool OmniboxSendSuggestionsFunction::RunSync() { ExtensionFunction::ResponseAction OmniboxSendSuggestionsFunction::Run() {
std::unique_ptr<SendSuggestions::Params> params( std::unique_ptr<SendSuggestions::Params> params(
SendSuggestions::Params::Create(*args_)); SendSuggestions::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params); EXTENSION_FUNCTION_VALIDATE(params);
content::NotificationService::current()->Notify( content::NotificationService::current()->Notify(
extensions::NOTIFICATION_EXTENSION_OMNIBOX_SUGGESTIONS_READY, extensions::NOTIFICATION_EXTENSION_OMNIBOX_SUGGESTIONS_READY,
content::Source<Profile>(GetProfile()->GetOriginalProfile()), content::Source<Profile>(
Profile::FromBrowserContext(browser_context())->GetOriginalProfile()),
content::Details<SendSuggestions::Params>(params.get())); content::Details<SendSuggestions::Params>(params.get()));
return true; return RespondNow(NoArguments());
} }
bool OmniboxSetDefaultSuggestionFunction::RunSync() { ExtensionFunction::ResponseAction OmniboxSetDefaultSuggestionFunction::Run() {
std::unique_ptr<SetDefaultSuggestion::Params> params( std::unique_ptr<SetDefaultSuggestion::Params> params(
SetDefaultSuggestion::Params::Create(*args_)); SetDefaultSuggestion::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params); EXTENSION_FUNCTION_VALIDATE(params);
if (SetOmniboxDefaultSuggestion( Profile* profile = Profile::FromBrowserContext(browser_context());
GetProfile(), extension_id(), params->suggestion)) { if (SetOmniboxDefaultSuggestion(profile, extension_id(),
params->suggestion)) {
content::NotificationService::current()->Notify( content::NotificationService::current()->Notify(
extensions::NOTIFICATION_EXTENSION_OMNIBOX_DEFAULT_SUGGESTION_CHANGED, extensions::NOTIFICATION_EXTENSION_OMNIBOX_DEFAULT_SUGGESTION_CHANGED,
content::Source<Profile>(GetProfile()->GetOriginalProfile()), content::Source<Profile>(profile->GetOriginalProfile()),
content::NotificationService::NoDetails()); content::NotificationService::NoDetails());
} }
return true; return RespondNow(NoArguments());
} }
// This function converts style information populated by the JSON schema // This function converts style information populated by the JSON schema
......
...@@ -73,7 +73,7 @@ class ExtensionOmniboxEventRouter { ...@@ -73,7 +73,7 @@ class ExtensionOmniboxEventRouter {
DISALLOW_COPY_AND_ASSIGN(ExtensionOmniboxEventRouter); DISALLOW_COPY_AND_ASSIGN(ExtensionOmniboxEventRouter);
}; };
class OmniboxSendSuggestionsFunction : public ChromeSyncExtensionFunction { class OmniboxSendSuggestionsFunction : public UIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("omnibox.sendSuggestions", OMNIBOX_SENDSUGGESTIONS) DECLARE_EXTENSION_FUNCTION("omnibox.sendSuggestions", OMNIBOX_SENDSUGGESTIONS)
...@@ -81,7 +81,7 @@ class OmniboxSendSuggestionsFunction : public ChromeSyncExtensionFunction { ...@@ -81,7 +81,7 @@ class OmniboxSendSuggestionsFunction : public ChromeSyncExtensionFunction {
~OmniboxSendSuggestionsFunction() override {} ~OmniboxSendSuggestionsFunction() override {}
// ExtensionFunction: // ExtensionFunction:
bool RunSync() override; ResponseAction Run() override;
}; };
class OmniboxAPI : public BrowserContextKeyedAPI, class OmniboxAPI : public BrowserContextKeyedAPI,
...@@ -150,7 +150,7 @@ class OmniboxAPI : public BrowserContextKeyedAPI, ...@@ -150,7 +150,7 @@ class OmniboxAPI : public BrowserContextKeyedAPI,
template <> template <>
void BrowserContextKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies(); void BrowserContextKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies();
class OmniboxSetDefaultSuggestionFunction : public ChromeSyncExtensionFunction { class OmniboxSetDefaultSuggestionFunction : public UIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("omnibox.setDefaultSuggestion", DECLARE_EXTENSION_FUNCTION("omnibox.setDefaultSuggestion",
OMNIBOX_SETDEFAULTSUGGESTION) OMNIBOX_SETDEFAULTSUGGESTION)
...@@ -159,7 +159,7 @@ class OmniboxSetDefaultSuggestionFunction : public ChromeSyncExtensionFunction { ...@@ -159,7 +159,7 @@ class OmniboxSetDefaultSuggestionFunction : public ChromeSyncExtensionFunction {
~OmniboxSetDefaultSuggestionFunction() override {} ~OmniboxSetDefaultSuggestionFunction() override {}
// ExtensionFunction: // ExtensionFunction:
bool RunSync() override; ResponseAction Run() override;
}; };
// If the extension has set a custom default suggestion via // If the extension has set a custom default suggestion via
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment