summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-28 15:53:09 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-28 15:53:09 +0000
commit0937e50de88050542188cf32a492e4feedda9e7b (patch)
treeaa901bae5147e74da741f086db075c024c9eb34e /chrome/browser
parent4a6d9bbad732f21da27f021e504de06e949ffef1 (diff)
downloadchromium_src-0937e50de88050542188cf32a492e4feedda9e7b.zip
chromium_src-0937e50de88050542188cf32a492e4feedda9e7b.tar.gz
chromium_src-0937e50de88050542188cf32a492e4feedda9e7b.tar.bz2
Revert 50977 - Add support for RLZ chrome extension api.
BUG=NONE TEST=See unit tests as part of this CL. Review URL: http://codereview.chromium.org/2804010 TBR=rogerta@google.com Review URL: http://codereview.chromium.org/2835022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50979 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.cc10
-rw-r--r--chrome/browser/extensions/extension_rlz_apitest.cc58
-rw-r--r--chrome/browser/extensions/extension_rlz_module.cc134
-rw-r--r--chrome/browser/extensions/extension_rlz_module.h33
4 files changed, 1 insertions, 234 deletions
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 9015a68..31d6984 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -8,7 +8,7 @@
#include "base/singleton.h"
#include "base/ref_counted.h"
#include "base/values.h"
-#include "build/build_config.h"
+#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
@@ -36,7 +36,6 @@
#include "chrome/browser/extensions/extension_popup_api.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_processes_api.h"
-#include "chrome/browser/extensions/extension_rlz_module.h"
#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/extensions/extension_tabs_module_constants.h"
#include "chrome/browser/extensions/extension_test_api.h"
@@ -200,13 +199,6 @@ void FactoryRegistry::ResetFunctions() {
RegisterFunction<MetricsRecordMediumTimeFunction>();
RegisterFunction<MetricsRecordLongTimeFunction>();
- // RLZ.
-#if defined(OS_WIN)
- RegisterFunction<RlzRecordProductEventFunction>();
- RegisterFunction<RlzGetAccessPointRlzFunction>();
- RegisterFunction<RlzClearProductStateFunction>();
-#endif
-
// Cookies.
RegisterFunction<GetCookieFunction>();
RegisterFunction<GetAllCookiesFunction>();
diff --git a/chrome/browser/extensions/extension_rlz_apitest.cc b/chrome/browser/extensions/extension_rlz_apitest.cc
deleted file mode 100644
index b6fc697..0000000
--- a/chrome/browser/extensions/extension_rlz_apitest.cc
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2010 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 <map>
-
-#include "base/registry.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/extensions/extension_apitest.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/extensions/extension.h"
-#include "rlz/win/lib/rlz_lib.h"
-
-IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Rlz) {
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableExperimentalExtensionApis);
-
- // Before running the tests, clear the state of the RLZ products used.
- rlz_lib::AccessPoint access_points[] = {
- rlz_lib::GD_WEB_SERVER,
- rlz_lib::GD_OUTLOOK,
- rlz_lib::NO_ACCESS_POINT
- };
- rlz_lib::ClearProductState(rlz_lib::PINYIN_IME, access_points);
- rlz_lib::ClearProductState(rlz_lib::DESKTOP, access_points);
-
- // Check that the state has really been cleared.
- RegKey key(HKEY_CURRENT_USER, L"Software\\Google\\Common\\Rlz\\Events\\N");
- ASSERT_FALSE(key.Valid());
-
- // Set the access point that the test code is expecting.
- ASSERT_TRUE(rlz_lib::SetAccessPointRlz(rlz_lib::GD_DESKBAND, "rlz_apitest"));
-
- // Now run all the tests.
- ASSERT_TRUE(RunExtensionTest("rlz")) << message_;
-
- // Now make sure we recorded what was expected. If the code in test.js
- // changes, need to make appropriate changes here.
- key.Open(HKEY_CURRENT_USER, L"Software\\Google\\Common\\Rlz\\Events\\N");
- ASSERT_TRUE(key.Valid());
-
- DWORD value;
- ASSERT_TRUE(key.ReadValueDW(L"D3I", &value));
- ASSERT_EQ(1, value);
- ASSERT_TRUE(key.ReadValueDW(L"D3S", &value));
- ASSERT_EQ(1, value);
- ASSERT_TRUE(key.ReadValueDW(L"D3F", &value));
- ASSERT_EQ(1, value);
-
- ASSERT_TRUE(key.ReadValueDW(L"D4I", &value));
- ASSERT_EQ(1, value);
-
- key.Open(HKEY_CURRENT_USER, L"Software\\Google\\Common\\Rlz\\Events\\D");
- ASSERT_FALSE(key.Valid());
-
- // Cleanup.
- rlz_lib::ClearProductState(rlz_lib::PINYIN_IME, access_points);
-}
diff --git a/chrome/browser/extensions/extension_rlz_module.cc b/chrome/browser/extensions/extension_rlz_module.cc
deleted file mode 100644
index 31b76f8..0000000
--- a/chrome/browser/extensions/extension_rlz_module.cc
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright (c) 2010 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/extensions/extension_rlz_module.h"
-
-#include "base/scoped_ptr.h"
-#include "chrome/browser/rlz/rlz.h"
-#include "chrome/common/extensions/extension.h"
-#include "rlz/win/lib/lib_values.h"
-
-namespace {
-
-bool GetProductFromName(const std::string& product_name,
- rlz_lib::Product* product) {
- bool success = true;
- switch (product_name[0]) {
- case 'B':
- *product = rlz_lib::FF_TOOLBAR;
- break;
- case 'C':
- *product = rlz_lib::CHROME;
- break;
- case 'D':
- *product = rlz_lib::DESKTOP;
- break;
- case 'K':
- *product = rlz_lib::QSB_WIN;
- break;
- case 'N':
- *product = rlz_lib::PINYIN_IME;
- break;
- case 'P':
- *product = rlz_lib::TOOLBAR_NOTIFIER;
- break;
- case 'T':
- *product = rlz_lib::IE_TOOLBAR;
- break;
- case 'U':
- *product = rlz_lib::PACK;
- break;
- case 'W':
- *product = rlz_lib::WEBAPPS;
- break;
- default:
- success = false;
- break;
- }
-
- return success;
-}
-
-bool GetEventFromName(const std::string& event_name,
- rlz_lib::Event* event_id) {
- *event_id = rlz_lib::INVALID_EVENT;
-
- if (event_name == "install") {
- *event_id = rlz_lib::INSTALL;
- } else if (event_name == "set-to-google") {
- *event_id = rlz_lib::SET_TO_GOOGLE;
- } else if (event_name == "first-search") {
- *event_id = rlz_lib::FIRST_SEARCH;
- } else if (event_name == "activate") {
- *event_id = rlz_lib::ACTIVATE;
- }
-
- return *event_id != rlz_lib::INVALID_EVENT;
-}
-
-} // anonymous namespace
-
-bool RlzRecordProductEventFunction::RunImpl() {
- std::string product_name;
- EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &product_name));
- rlz_lib::Product product;
- EXTENSION_FUNCTION_VALIDATE(GetProductFromName(product_name, &product));
-
- std::string ap_name;
- EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &ap_name));
- rlz_lib::AccessPoint access_point;
- EXTENSION_FUNCTION_VALIDATE(rlz_lib::GetAccessPointFromName(ap_name.c_str(),
- &access_point));
-
- std::string event_name;
- EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &event_name));
- rlz_lib::Event event_id;
- EXTENSION_FUNCTION_VALIDATE(GetEventFromName(event_name, &event_id));
-
- return RLZTracker::RecordProductEvent(product, access_point, event_id);
-}
-
-bool RlzGetAccessPointRlzFunction::RunImpl() {
- std::string ap_name;
- EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &ap_name));
- rlz_lib::AccessPoint access_point;
- EXTENSION_FUNCTION_VALIDATE(rlz_lib::GetAccessPointFromName(ap_name.c_str(),
- &access_point));
-
- char rlz[rlz_lib::kMaxRlzLength + 1];
- rlz_lib::GetAccessPointRlz(access_point, rlz, rlz_lib::kMaxRlzLength);
- result_.reset(Value::CreateStringValue(rlz));
- return true;
-}
-
-bool RlzClearProductStateFunction::RunImpl() {
- std::string product_name;
- EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &product_name));
- rlz_lib::Product product;
- EXTENSION_FUNCTION_VALIDATE(GetProductFromName(product_name, &product));
-
- ListValue* access_points_list;
- EXTENSION_FUNCTION_VALIDATE(args_->GetList(1, &access_points_list));
- if (access_points_list->GetSize() < 1) {
- EXTENSION_FUNCTION_ERROR("Access point array should not be empty.");
- }
-
- // Allocate an access point array to pass to ClearProductState(). The array
- // must be termindated with the value rlz_lib::NO_ACCESS_POINT, hence + 1
- // when allocating the array.
- scoped_array<rlz_lib::AccessPoint> access_points(
- new rlz_lib::AccessPoint[access_points_list->GetSize() + 1]);
-
- size_t i;
- for (i = 0; i < access_points_list->GetSize(); ++i) {
- std::string ap_name;
- EXTENSION_FUNCTION_VALIDATE(access_points_list->GetString(i, &ap_name));
- EXTENSION_FUNCTION_VALIDATE(rlz_lib::GetAccessPointFromName(
- ap_name.c_str(), &access_points[i]));
- }
- access_points[i] = rlz_lib::NO_ACCESS_POINT;
-
- rlz_lib::ClearProductState(product, access_points.get());
- return true;
-}
diff --git a/chrome/browser/extensions/extension_rlz_module.h b/chrome/browser/extensions/extension_rlz_module.h
deleted file mode 100644
index 88affd9..0000000
--- a/chrome/browser/extensions/extension_rlz_module.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2010 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_EXTENSIONS_EXTENSION_RLZ_MODULE_H__
-#define CHROME_BROWSER_EXTENSIONS_EXTENSION_RLZ_MODULE_H__
-
-#include "build/build_config.h"
-
-#if defined(OS_WIN)
-
-#include <string>
-
-#include "chrome/browser/extensions/extension_function.h"
-
-class RlzRecordProductEventFunction : public SyncExtensionFunction {
- virtual bool RunImpl();
- DECLARE_EXTENSION_FUNCTION_NAME("experimental.rlz.recordProductEvent")
-};
-
-class RlzGetAccessPointRlzFunction : public SyncExtensionFunction {
- virtual bool RunImpl();
- DECLARE_EXTENSION_FUNCTION_NAME("experimental.rlz.getAccessPointRlz")
-};
-
-class RlzClearProductStateFunction : public SyncExtensionFunction {
- virtual bool RunImpl();
- DECLARE_EXTENSION_FUNCTION_NAME("experimental.rlz.clearProductState")
-};
-
-#endif // defined(OS_WIN)
-
-#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_RLZ_MODULE_H__