diff options
author | gauravsh@chromium.org <gauravsh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-17 23:52:14 +0000 |
---|---|---|
committer | gauravsh@chromium.org <gauravsh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-17 23:52:14 +0000 |
commit | de73b58fa1362b91532bd70d57a8724bfd41beb8 (patch) | |
tree | df6d4295fd5e523ad5bc4fd8994aa595c248fb9c | |
parent | 662e9616e443a7f3470481123a18ad977b5d949c (diff) | |
download | chromium_src-de73b58fa1362b91532bd70d57a8724bfd41beb8.zip chromium_src-de73b58fa1362b91532bd70d57a8724bfd41beb8.tar.gz chromium_src-de73b58fa1362b91532bd70d57a8724bfd41beb8.tar.bz2 |
[Chrome OS ECHO]: Rename API and method names
In addition, get rid of one API method that is no longer used.
BUG=chromium-os:28507
TEST=existing (renamed) unit tests
Review URL: http://codereview.chromium.org/10086011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132700 0039d316-1c4b-4281-b951-d872f2087c98
24 files changed, 119 insertions, 312 deletions
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index 01827b2..354e98c8 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -169,7 +169,7 @@ <include name="IDR_NETWORK_MENU_CSS" file="resources\chromeos\network_menu.css" flattenhtml="true" type="BINDATA" /> <include name="IDR_NETWORK_MENU_JS" file="resources\chromeos\network_menu.js" flattenhtml="true" type="BINDATA" /> <include name="IDR_NOTIFICATION_ICON_LINK_HTML" file="resources\chromeos\notification_icon_link.html" type="BINDATA" /> - <include name="IDR_OFFERS_MANIFEST" file="resources\chromeos\offers\manifest.json" type="BINDATA" /> + <include name="IDR_ECHO_MANIFEST" file="resources\chromeos\echo\manifest.json" type="BINDATA" /> <include name="IDR_OFFLINE_LOAD_HTML" file="resources\chromeos\offline_load.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_OOBE_HTML" file="resources\chromeos\login\oobe.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_OS_CREDITS_HTML" file="resources\chromeos\about_os_credits.html" flattenhtml="true" type="BINDATA" /> diff --git a/chrome/browser/chromeos/extensions/echo_private_api.cc b/chrome/browser/chromeos/extensions/echo_private_api.cc new file mode 100644 index 0000000..a48c704 --- /dev/null +++ b/chrome/browser/chromeos/extensions/echo_private_api.cc @@ -0,0 +1,49 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/extensions/echo_private_api.h" + +#include <string> + +#include "base/compiler_specific.h" +#include "base/values.h" +#include "chrome/browser/chromeos/system/statistics_provider.h" +#include "chrome/common/extensions/extension.h" + +namespace { + +// For a given registration code type, returns the code value from the +// underlying system. Caller owns the returned pointer. +base::Value* GetValueForRegistrationCodeType(std::string& type) { + // Possible ECHO code type and corresponding key name in StatisticsProvider. + const std::string kCouponType = "COUPON_CODE"; + const std::string kCouponCodeKey = "ubind_attribute"; + const std::string kGroupType = "GROUP_CODE"; + const std::string kGroupCodeKey = "gbind_attribute"; + + chromeos::system::StatisticsProvider* provider = + chromeos::system::StatisticsProvider::GetInstance(); + std::string result; + if (type == kCouponType) + provider->GetMachineStatistic(kCouponCodeKey, &result); + else if (type == kGroupType) + provider->GetMachineStatistic(kGroupCodeKey, &result); + return Value::CreateStringValue(result); +} + +} // namespace + + +GetRegistrationCodeFunction::GetRegistrationCodeFunction() { +} + +GetRegistrationCodeFunction::~GetRegistrationCodeFunction() { +} + +bool GetRegistrationCodeFunction::RunImpl() { + std::string type; + EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &type)); + result_.reset(GetValueForRegistrationCodeType(type)); + return true; +} diff --git a/chrome/browser/chromeos/extensions/echo_private_api.h b/chrome/browser/chromeos/extensions/echo_private_api.h new file mode 100644 index 0000000..e947eb3 --- /dev/null +++ b/chrome/browser/chromeos/extensions/echo_private_api.h @@ -0,0 +1,22 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_ECHO_PRIVATE_API_H_ +#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_ECHO_PRIVATE_API_H_ + +#include "base/compiler_specific.h" +#include "chrome/browser/extensions/extension_function.h" + +class GetRegistrationCodeFunction : public SyncExtensionFunction { + public: + GetRegistrationCodeFunction(); + + protected: + virtual ~GetRegistrationCodeFunction(); + virtual bool RunImpl() OVERRIDE; + + private: + DECLARE_EXTENSION_FUNCTION_NAME("echoPrivate.getRegistrationCode"); +}; +#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_ECHO_PRIVATE_API_H_ diff --git a/chrome/browser/chromeos/extensions/offers_private_apitest.cc b/chrome/browser/chromeos/extensions/echo_private_apitest.cc index 93db498..25886d7 100644 --- a/chrome/browser/chromeos/extensions/offers_private_apitest.cc +++ b/chrome/browser/chromeos/extensions/echo_private_apitest.cc @@ -4,10 +4,10 @@ #include "chrome/browser/extensions/extension_apitest.h" -class ExtensionOffersPrivateApiTest : public ExtensionApiTest { +class ExtensionEchoPrivateApiTest : public ExtensionApiTest { }; -IN_PROC_BROWSER_TEST_F(ExtensionOffersPrivateApiTest, OffersTest) { - EXPECT_TRUE(RunComponentExtensionTest("offers/component_extension")) +IN_PROC_BROWSER_TEST_F(ExtensionEchoPrivateApiTest, EchoTest) { + EXPECT_TRUE(RunComponentExtensionTest("echo/component_extension")) << message_; } diff --git a/chrome/browser/chromeos/extensions/offers_private_api.cc b/chrome/browser/chromeos/extensions/offers_private_api.cc deleted file mode 100644 index 6b9a54c..0000000 --- a/chrome/browser/chromeos/extensions/offers_private_api.cc +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/extensions/offers_private_api.h" - -#include <string> - -#include "base/compiler_specific.h" -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "base/values.h" -#include "chrome/browser/chromeos/system/statistics_provider.h" -#include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" -#include "chrome/browser/extensions/extension_tab_util.h" -#include "chrome/browser/extensions/extension_window_controller.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/tab_contents/confirm_infobar_delegate.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/common/chrome_notification_types.h" -#include "chrome/common/extensions/extension.h" -#include "content/public/browser/notification_details.h" -#include "content/public/browser/notification_observer.h" -#include "content/public/browser/notification_registrar.h" -#include "content/public/browser/notification_source.h" -#include "content/public/browser/web_contents.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" - -namespace { - -// For a given coupon type, returns the coupon code value from the underlying -// system. -std::string GetValueForCouponType(std::string& type) { - // Possible ECHO code type and corresponding key name in StatisticsProvider. - const std::string kCouponType = "COUPON_CODE"; - const std::string kCouponCodeKey = "ubind_attribute"; - const std::string kGroupType = "GROUP_CODE"; - const std::string kGroupCodeKey = "gbind_attribute"; - - chromeos::system::StatisticsProvider* provider = - chromeos::system::StatisticsProvider::GetInstance(); - std::string result; - if (type == kCouponType) - provider->GetMachineStatistic(kCouponCodeKey, &result); - else if (type == kGroupType) - provider->GetMachineStatistic(kGroupCodeKey, &result); - return result; -} - -} // namespace - - -GetCouponCodeFunction::GetCouponCodeFunction() { -} - -GetCouponCodeFunction::~GetCouponCodeFunction() { -} - -bool GetCouponCodeFunction::RunImpl() { - std::string type; - EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &type)); - result_.reset(Value::CreateStringValue(GetValueForCouponType(type))); - return true; -} - -// Confirmation InfoBar displayed to ask user for consent for performing -// the ECHO protocol transaction. Used by GetUserConsentFunction. -class OffersConsentInfoBarDelegate - : public ConfirmInfoBarDelegate, - public content::NotificationObserver { - public: - OffersConsentInfoBarDelegate(Browser* browser, - InfoBarTabHelper* infobar_helper, - const GURL& url, - GetUserConsentFunction* consent_receiver); - private: - virtual ~OffersConsentInfoBarDelegate(); - - // ConfirmInfoBarDelegate: - virtual string16 GetMessageText() const OVERRIDE; - virtual int GetButtons() const OVERRIDE; - virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; - virtual bool Accept() OVERRIDE; - virtual bool Cancel() OVERRIDE; - virtual void InfoBarDismissed() OVERRIDE; - - // content::NotificationObserver: - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE; - - content::NotificationRegistrar registrar_; - Browser* browser_; - - // The extension host we are showing the InfoBar for. The delegate needs to - // own this since the InfoBar gets deleted and recreated when you switch tabs - // and come back (and we don't want the user's interaction with the InfoBar to - // get lost at that point). - scoped_ptr<ExtensionHost> extension_host_; - - scoped_refptr<GetUserConsentFunction> consent_receiver_; -}; - -OffersConsentInfoBarDelegate::OffersConsentInfoBarDelegate( - Browser* browser, - InfoBarTabHelper* infobar_helper, - const GURL& url, - GetUserConsentFunction* consent_receiver) - : ConfirmInfoBarDelegate(infobar_helper), - browser_(browser), - consent_receiver_(consent_receiver) { - ExtensionProcessManager* manager = - browser->profile()->GetExtensionProcessManager(); - extension_host_.reset(manager->CreateInfobarHost(url, browser)); - extension_host_->SetAssociatedWebContents(infobar_helper->web_contents()); - - registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, - content::Source<Profile>(browser->profile())); - registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, - content::Source<Profile>(browser->profile())); -} - -OffersConsentInfoBarDelegate::~OffersConsentInfoBarDelegate() { -} - -string16 OffersConsentInfoBarDelegate::GetMessageText() const { - return l10n_util::GetStringUTF16(IDS_OFFERS_CONSENT_INFOBAR_LABEL); -} - -int OffersConsentInfoBarDelegate::GetButtons() const { - return BUTTON_OK | BUTTON_CANCEL; -} - -string16 OffersConsentInfoBarDelegate::GetButtonLabel( - InfoBarButton button) const { - DCHECK(button == BUTTON_OK || button == BUTTON_CANCEL); - if (button == BUTTON_OK) - return l10n_util::GetStringUTF16(IDS_OFFERS_CONSENT_INFOBAR_ENABLE_BUTTON); - return l10n_util::GetStringUTF16(IDS_OFFERS_CONSENT_INFOBAR_DISABLE_BUTTON); -} - -bool OffersConsentInfoBarDelegate::Accept() { - consent_receiver_->SetConsent(true); - return true; -} - -bool OffersConsentInfoBarDelegate::Cancel() { - consent_receiver_->SetConsent(false); - return true; -} - -void OffersConsentInfoBarDelegate::InfoBarDismissed() { - // Assume no consent if the user closes the Info Bar without - // pressing any of the buttons. - consent_receiver_->SetConsent(false); -} - -void OffersConsentInfoBarDelegate::Observe( - int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { - if (type == chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE || - type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { - if (extension_host_.get() == content::Details<ExtensionHost>(details).ptr()) - RemoveSelf(); - } -} - -GetUserConsentFunction::GetUserConsentFunction() { -} - -void GetUserConsentFunction::SetConsent(bool is_consent) { - result_.reset(Value::CreateBooleanValue(is_consent)); - SendResponse(true); - Release(); -} - -GetUserConsentFunction::~GetUserConsentFunction() { -} - -bool GetUserConsentFunction::RunImpl() { - AddRef(); // Balanced in SetConsent(). - ShowConsentInfoBar(); - return true; -} - -void GetUserConsentFunction::ShowConsentInfoBar() { - const Extension* extension = GetExtension(); - GURL url = extension->GetResourceURL(""); - - Browser* browser = GetCurrentBrowser(); - - TabContentsWrapper* tab_contents = NULL; - tab_contents = browser->GetSelectedTabContentsWrapper(); - tab_contents->infobar_tab_helper()->AddInfoBar( - new OffersConsentInfoBarDelegate(browser, - tab_contents->infobar_tab_helper(), - url, - this)); - DCHECK(browser->extension_window_controller()); -} diff --git a/chrome/browser/chromeos/extensions/offers_private_api.h b/chrome/browser/chromeos/extensions/offers_private_api.h deleted file mode 100644 index df7a56a..0000000 --- a/chrome/browser/chromeos/extensions/offers_private_api.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_OFFERS_PRIVATE_API_H_ -#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_OFFERS_PRIVATE_API_H_ - -#include "base/compiler_specific.h" -#include "chrome/browser/extensions/extension_function.h" - -class GetCouponCodeFunction : public SyncExtensionFunction { - public: - GetCouponCodeFunction(); - - protected: - virtual ~GetCouponCodeFunction(); - virtual bool RunImpl() OVERRIDE; - - private: - DECLARE_EXTENSION_FUNCTION_NAME("offersPrivate.getCouponCode"); -}; - -class GetUserConsentFunction : public AsyncExtensionFunction { - public: - GetUserConsentFunction(); - - // Called when user's consent response is known. - void SetConsent(bool is_consent); - - protected: - virtual ~GetUserConsentFunction(); - virtual bool RunImpl() OVERRIDE; - - private: - // Show user consent confirmation bar. - void ShowConsentInfoBar(); - - DECLARE_EXTENSION_FUNCTION_NAME("offersPrivate.getUserConsent"); -}; - -#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_OFFERS_PRIVATE_API_H_ diff --git a/chrome/browser/chromeos/system/statistics_provider.cc b/chrome/browser/chromeos/system/statistics_provider.cc index b973175..0d6798f 100644 --- a/chrome/browser/chromeos/system/statistics_provider.cc +++ b/chrome/browser/chromeos/system/statistics_provider.cc @@ -45,9 +45,9 @@ const char kMachineHardwareInfoDelim[] = " \n"; // File to get ECHO coupon info from, and key/value delimiters of // the file. -const char kOffersCouponFile[] = "/var/cache/offers/vpd_echo.txt"; -const char kOffersCouponEq[] = "="; -const char kOffersCouponDelim[] = "\n"; +const char kEchoCouponFile[] = "/var/cache/echo/vpd_echo.txt"; +const char kEchoCouponEq[] = "="; +const char kEchoCouponDelim[] = "\n"; // File to get machine OS info from, and key/value delimiters of the file. const char kMachineOSInfoFile[] = "/etc/lsb-release"; @@ -154,9 +154,9 @@ void StatisticsProviderImpl::LoadMachineStatistics() { parser.GetNameValuePairsFromFile(FilePath(kMachineHardwareInfoFile), kMachineHardwareInfoEq, kMachineHardwareInfoDelim); - parser.GetNameValuePairsFromFile(FilePath(kOffersCouponFile), - kOffersCouponEq, - kOffersCouponDelim); + parser.GetNameValuePairsFromFile(FilePath(kEchoCouponFile), + kEchoCouponEq, + kEchoCouponDelim); parser.GetNameValuePairsFromFile(FilePath(kMachineOSInfoFile), kMachineOSInfoEq, kMachineOSInfoDelim); diff --git a/chrome/browser/extensions/component_loader.cc b/chrome/browser/extensions/component_loader.cc index 1fc05ce..a8723f4 100644 --- a/chrome/browser/extensions/component_loader.cc +++ b/chrome/browser/extensions/component_loader.cc @@ -295,14 +295,14 @@ void ComponentLoader::AddDefaultComponentExtensions() { FilePath(FILE_PATH_LITERAL("/usr/share/chromeos-assets/gaia_auth"))); } - // TODO(gauravsh): Only include offers extension on official builds. - FilePath offers_extension_path(FILE_PATH_LITERAL( - "/usr/share/chromeos-assets/offers")); - if (command_line->HasSwitch(switches::kOffersExtensionPath)) { - offers_extension_path = - command_line->GetSwitchValuePath(switches::kOffersExtensionPath); + // TODO(gauravsh): Only include echo extension on official builds. + FilePath echo_extension_path(FILE_PATH_LITERAL( + "/usr/share/chromeos-assets/echo")); + if (command_line->HasSwitch(switches::kEchoExtensionPath)) { + echo_extension_path = + command_line->GetSwitchValuePath(switches::kEchoExtensionPath); } - Add(IDR_OFFERS_MANIFEST, offers_extension_path); + Add(IDR_ECHO_MANIFEST, echo_extension_path); #if defined(OFFICIAL_BUILD) if (browser_defaults::enable_help_app) { diff --git a/chrome/browser/extensions/extension_function_registry.cc b/chrome/browser/extensions/extension_function_registry.cc index 9e60166..bae3c16 100644 --- a/chrome/browser/extensions/extension_function_registry.cc +++ b/chrome/browser/extensions/extension_function_registry.cc @@ -63,7 +63,7 @@ #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" -#include "chrome/browser/chromeos/extensions/offers_private_api.h" +#include "chrome/browser/chromeos/extensions/echo_private_api.h" #include "chrome/browser/chromeos/media/media_player_extension_api.h" #include "chrome/browser/extensions/api/terminal/terminal_private_api.h" #include "chrome/browser/extensions/extension_info_private_api_chromeos.h" @@ -382,9 +382,8 @@ void ExtensionFunctionRegistry::ResetFunctions() { // InputMethod RegisterFunction<GetInputMethodFunction>(); - // Offers - RegisterFunction<GetCouponCodeFunction>(); - RegisterFunction<GetUserConsentFunction>(); + // Echo + RegisterFunction<GetRegistrationCodeFunction>(); // Terminal RegisterFunction<OpenTerminalProcessFunction>(); diff --git a/chrome/browser/resources/chromeos/offers/OWNERS b/chrome/browser/resources/chromeos/echo/OWNERS index d3a0e8f..d3a0e8f 100644 --- a/chrome/browser/resources/chromeos/offers/OWNERS +++ b/chrome/browser/resources/chromeos/echo/OWNERS diff --git a/chrome/browser/resources/chromeos/offers/manifest.json b/chrome/browser/resources/chromeos/echo/manifest.json index edb4ebd..8f45c44 100644 --- a/chrome/browser/resources/chromeos/offers/manifest.json +++ b/chrome/browser/resources/chromeos/echo/manifest.json @@ -10,7 +10,7 @@ "content_security_policy": "default-src 'self'; script-src 'self' 'unsafe-eval' https://apis.google.com; frame-src 'self' https://www.googleapis.com https://www-googleapis-test.sandbox.google.com; object-src 'self'", "permissions": [ "cookies", - "offersPrivate", + "echoPrivate", "https://*/*" ], "web_accessible_resources": [ @@ -18,7 +18,7 @@ "main.js" ], "intents": { - "https://crosoffers.com/startEcho": [{ + "https://crosecho.com/startEcho": [{ "type" : ["application/vnd.chromeos.echo"], "title" : "Initiate Chrome OS ECHO", "path" : "main.html", diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 67ee5d6..aeb8f59 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -483,6 +483,8 @@ 'browser/chromeos/enterprise_extension_observer.h', 'browser/chromeos/extensions/bluetooth_event_router.cc', 'browser/chromeos/extensions/bluetooth_event_router.h', + 'browser/chromeos/extensions/echo_private_api.cc', + 'browser/chromeos/extensions/echo_private_api.h', 'browser/chromeos/extensions/file_browser_event_router.cc', 'browser/chromeos/extensions/file_browser_event_router.h', 'browser/chromeos/extensions/file_browser_notifications.cc', @@ -3955,10 +3957,10 @@ 'browser/accessibility/accessibility_extension_api.h', 'browser/bookmarks/bookmark_extension_api.cc', 'browser/bookmarks/bookmark_extension_api.h', + 'browser/chromeos/extensions/echo_private_api.cc', + 'browser/chromeos/extensions/echo_private_api.h', 'browser/chromeos/extensions/file_browser_private_api.cc', 'browser/chromeos/extensions/file_browser_private_api.h', - 'browser/chromeos/extensions/offers_private_api.cc', - 'browser/chromeos/extensions/offers_private_api.h', 'browser/chromeos/media/media_player_extension_api.cc', 'browser/chromeos/media/media_player_extension_api.h', 'browser/download/download_extension_api.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index f79c967..3c14a97 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2719,7 +2719,7 @@ 'browser/chromeos/disks/mock_disk_mount_manager.h', 'browser/chromeos/extensions/file_browser_notifications_browsertest.cc', 'browser/chromeos/extensions/file_browser_private_apitest.cc', - 'browser/chromeos/extensions/offers_private_apitest.cc', + 'browser/chromeos/extensions/echo_private_apitest.cc', 'browser/chromeos/extensions/external_filesystem_apitest.cc', 'browser/chromeos/gdata/gdata_documents_service_browsertest.cc', 'browser/chromeos/input_method/input_method_manager_browsertest.cc', diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 925e1a4..80e26d1 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -1265,9 +1265,9 @@ const char kLoginPassword[] = "login-password"; // mode. Should completely disable extensions, sync and bookmarks. const char kGuestSession[] = "bwsi"; -// Enables overriding the path for the default offers component extension. +// Enables overriding the path for the default echo component extension. // Useful for testing. -const char kOffersExtensionPath[] = "offers-ext-path"; +const char kEchoExtensionPath[] = "echo-ext-path"; // Show volume controls in status bar on ChromeOS. const char kShowVolumeStatus[] = "show-volume-status"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 1b4fcce..4afed1a 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -349,7 +349,7 @@ extern const char kLoginProfile[]; extern const char kLoginUser[]; extern const char kLoginPassword[]; extern const char kGuestSession[]; -extern const char kOffersExtensionPath[]; +extern const char kEchoExtensionPath[]; extern const char kShowVolumeStatus[]; extern const char kStubCros[]; extern const char kStubCrosSettings[]; diff --git a/chrome/common/extensions/api/_permission_features.json b/chrome/common/extensions/api/_permission_features.json index 18960b1..82c8b1c 100644 --- a/chrome/common/extensions/api/_permission_features.json +++ b/chrome/common/extensions/api/_permission_features.json @@ -150,7 +150,7 @@ "extension", "packaged_app", "hosted_app", "platform_app" ] }, - "offersPrivate": { + "echoPrivate": { "channel": "stable", "extension_types": ["extension", "packaged_app", "platform_app"], "location": "component" diff --git a/chrome/common/extensions/api/offersPrivate.json b/chrome/common/extensions/api/echoPrivate.json index 94f91e1..905c1fa 100644 --- a/chrome/common/extensions/api/offersPrivate.json +++ b/chrome/common/extensions/api/echoPrivate.json @@ -4,13 +4,13 @@ [ { - "namespace": "offersPrivate", + "namespace": "echoPrivate", "nodoc": true, "platforms": ["chromeos"], "types": [], "functions": [ { - "name": "getCouponCode", + "name": "getRegistrationCode", "description": "Get the group or coupon code from underlying storage.", "type": "function", "parameters": [ @@ -31,24 +31,6 @@ ] } ] - }, - { - "name": "getUserConsent", - "description": "Get user's consent by displaying an InfoBar.", - "type": "function", - "parameters": [ - { - "name": "callback", - "type": "function", - "parameters": [ - { - "name": "result", - "type": "boolean", - "description" : "Consent result." - } - ] - } - ] } ] } diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc index bdccc9b..049613a 100644 --- a/chrome/common/extensions/api/extension_api.cc +++ b/chrome/common/extensions/api/extension_api.cc @@ -331,8 +331,8 @@ void ExtensionAPI::InitDefaultConfiguration() { IDR_EXTENSION_API_JSON_MEDIAPLAYERPRIVATE)); RegisterSchema("metricsPrivate", ReadFromResource( IDR_EXTENSION_API_JSON_METRICSPRIVATE)); - RegisterSchema("offersPrivate", ReadFromResource( - IDR_EXTENSION_API_JSON_OFFERSPRIVATE)); + RegisterSchema("echoPrivate", ReadFromResource( + IDR_EXTENSION_API_JSON_ECHOPRIVATE)); RegisterSchema("omnibox", ReadFromResource( IDR_EXTENSION_API_JSON_OMNIBOX)); RegisterSchema("pageAction", ReadFromResource( diff --git a/chrome/common/extensions/extension_permission_set.cc b/chrome/common/extensions/extension_permission_set.cc index e58cf0a..d805f82 100644 --- a/chrome/common/extensions/extension_permission_set.cc +++ b/chrome/common/extensions/extension_permission_set.cc @@ -305,7 +305,7 @@ void ExtensionAPIPermission::RegisterAllPermissions( kInputMethodPrivate, "inputMethodPrivate", 0, ExtensionPermissionMessage::kNone, kFlagCannotBeOptional); info->RegisterPermission( - kOffersPrivate, "offersPrivate", 0, ExtensionPermissionMessage::kNone, + kEchoPrivate, "echoPrivate", 0, ExtensionPermissionMessage::kNone, kFlagCannotBeOptional); info->RegisterPermission( kTerminalPrivate, "terminalPrivate", 0, ExtensionPermissionMessage::kNone, diff --git a/chrome/common/extensions/extension_permission_set.h b/chrome/common/extensions/extension_permission_set.h index f42d4c9..3b468ca 100644 --- a/chrome/common/extensions/extension_permission_set.h +++ b/chrome/common/extensions/extension_permission_set.h @@ -122,7 +122,7 @@ class ExtensionAPIPermission { kMediaPlayerPrivate, kMetricsPrivate, kNotification, - kOffersPrivate, + kEchoPrivate, kPageCapture, kPlugin, kPrivacy, diff --git a/chrome/common/extensions/extension_permission_set_unittest.cc b/chrome/common/extensions/extension_permission_set_unittest.cc index bcb7199..b41a6a1 100644 --- a/chrome/common/extensions/extension_permission_set_unittest.cc +++ b/chrome/common/extensions/extension_permission_set_unittest.cc @@ -605,7 +605,7 @@ TEST(ExtensionPermissionsTest, PermissionMessages) { skip.insert(ExtensionAPIPermission::kInputMethodPrivate); skip.insert(ExtensionAPIPermission::kMediaPlayerPrivate); skip.insert(ExtensionAPIPermission::kMetricsPrivate); - skip.insert(ExtensionAPIPermission::kOffersPrivate); + skip.insert(ExtensionAPIPermission::kEchoPrivate); skip.insert(ExtensionAPIPermission::kSystemPrivate); skip.insert(ExtensionAPIPermission::kTerminalPrivate); skip.insert(ExtensionAPIPermission::kWebSocketProxyPrivate); diff --git a/chrome/common/extensions_api_resources.grd b/chrome/common/extensions_api_resources.grd index 16a6178..18a08ce 100644 --- a/chrome/common/extensions_api_resources.grd +++ b/chrome/common/extensions_api_resources.grd @@ -20,6 +20,7 @@ <include name="IDR_EXTENSION_API_JSON_COOKIES" file="extensions\api\cookies.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_DEBUGGER" file="extensions\api\debugger.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_DEVTOOLS" file="extensions\api\devtools.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_ECHOPRIVATE" file="extensions\api\echoPrivate.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_ACCESSIBILITY" file="extensions\api\experimental.accessibility.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_APP" file="extensions\api\experimental.app.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_BOOKMARKMANAGER" file="extensions\api\experimental.bookmarkManager.json" type="BINDATA" /> @@ -49,7 +50,6 @@ <include name="IDR_EXTENSION_API_JSON_MANAGEMENT" file="extensions\api\management.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_MEDIAPLAYERPRIVATE" file="extensions\api\mediaPlayerPrivate.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_METRICSPRIVATE" file="extensions\api\metricsPrivate.json" type="BINDATA" /> - <include name="IDR_EXTENSION_API_JSON_OFFERSPRIVATE" file="extensions\api\offersPrivate.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_OMNIBOX" file="extensions\api\omnibox.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_PAGEACTION" file="extensions\api\pageAction.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_PAGEACTIONS" file="extensions\api\pageActions.json" type="BINDATA" /> diff --git a/chrome/test/data/extensions/api_test/offers/component_extension/manifest.json b/chrome/test/data/extensions/api_test/echo/component_extension/manifest.json index 36c9d26..3a7d49c 100644 --- a/chrome/test/data/extensions/api_test/offers/component_extension/manifest.json +++ b/chrome/test/data/extensions/api_test/echo/component_extension/manifest.json @@ -1,10 +1,10 @@ { // chrome-extension://lbgjohhgghbkcgejgklgcmfijhbheflf/ "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDasz2sLsAlmcF0v7/FGwzWVP/T+CLhvWpojKckVp8RH0bN/x3HvQ8FUweTymsaLbqxMHn8LbMOYt9uvLg7MuUcs0puzo7vPEwW7FPwLdIke2Fth+uXgkBFUFvtrOoAyIXmiRRFoIi9qfNVQOvIz0nv0c7UEKoHT3UnT0ekxSl7lwIDAQAB", - "name": "chrome.offersPrivate.apitest", + "name": "chrome.echoPrivate.apitest", "version": "0.1", - "description": "tests for chrome.offersPrivate API.", + "description": "tests for chrome.echoPrivate API.", "manifest_version": 2, "background": {"scripts": ["test.js"]}, - "permissions": ["offersPrivate"] + "permissions": ["echoPrivate"] } diff --git a/chrome/test/data/extensions/api_test/offers/component_extension/test.js b/chrome/test/data/extensions/api_test/echo/component_extension/test.js index 2eb4102..4ffe6c5 100644 --- a/chrome/test/data/extensions/api_test/offers/component_extension/test.js +++ b/chrome/test/data/extensions/api_test/echo/component_extension/test.js @@ -3,21 +3,21 @@ // found in the LICENSE file. chrome.test.runTests([ - function getCouponCodeTest() { - var expected_code = ""; + function getRegistrationCodeTest() { + var expected_code = ''; // TODO(gauravsh): Mock out StatisticsProvider to make getCouponCode() // return a well known value for brower_tests. - chrome.offersPrivate.getCouponCode("COUPON_CODE", + chrome.echoPrivate.getRegistrationCode('COUPON_CODE', chrome.test.callbackPass(function(result) { chrome.test.assertTrue(result == expected_code); })); - chrome.offersPrivate.getCouponCode("GROUP_CODE", + chrome.echoPrivate.getRegistrationCode('GROUP_CODE', chrome.test.callbackPass(function(result) { chrome.test.assertTrue(result == expected_code); })); - chrome.offersPrivate.getCouponCode("INVALID_CODE", + chrome.echoPrivate.getRegistrationCode('INVALID_CODE', chrome.test.callbackPass(function(result) { - chrome.test.assertTrue(result == ""); + chrome.test.assertTrue(result == ''); })); } ]); |