diff options
author | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-10 00:03:28 +0000 |
---|---|---|
committer | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-10 00:03:28 +0000 |
commit | eb84780bc1c9f770b3b6029df44be59cc7d75125 (patch) | |
tree | 0fc16618ac883e6e0109019b7f29b7368c04efec | |
parent | 7d0e949cf60e10666ea69dc3e8675ba56e97649f (diff) | |
download | chromium_src-eb84780bc1c9f770b3b6029df44be59cc7d75125.zip chromium_src-eb84780bc1c9f770b3b6029df44be59cc7d75125.tar.gz chromium_src-eb84780bc1c9f770b3b6029df44be59cc7d75125.tar.bz2 |
Eliminate "using namespace" directives from extensions code
These are banned by the style guide - see the bug for links to why.
BUG=117267
TEST=Code should compile and existing tests should pass
Review URL: http://codereview.chromium.org/9666017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125945 0039d316-1c4b-4281-b951-d872f2087c98
19 files changed, 206 insertions, 179 deletions
diff --git a/chrome/browser/extensions/api/browsingdata/browsing_data_test.cc b/chrome/browser/extensions/api/browsingdata/browsing_data_test.cc index 1b390e2..2c98726 100644 --- a/chrome/browser/extensions/api/browsingdata/browsing_data_test.cc +++ b/chrome/browser/extensions/api/browsingdata/browsing_data_test.cc @@ -19,7 +19,8 @@ #include "chrome/test/base/in_process_browser_test.h" #include "content/public/browser/notification_service.h" -using namespace extension_function_test_utils; +using extension_function_test_utils::RunFunctionAndReturnError; +using extension_function_test_utils::RunFunctionAndReturnResult; namespace { diff --git a/chrome/browser/extensions/api/declarative/declarative_api.cc b/chrome/browser/extensions/api/declarative/declarative_api.cc index 99be5f3..34e3283 100644 --- a/chrome/browser/extensions/api/declarative/declarative_api.cc +++ b/chrome/browser/extensions/api/declarative/declarative_api.cc @@ -13,7 +13,11 @@ #include "chrome/common/extensions/api/experimental.declarative.h" #include "content/public/browser/browser_thread.h" -using namespace extensions::api::experimental; +using extensions::api::experimental::Rule; + +namespace AddRules = extensions::api::experimental::AddRules; +namespace GetRules = extensions::api::experimental::GetRules; +namespace RemoveRules = extensions::api::experimental::RemoveRules; namespace { diff --git a/chrome/browser/extensions/api/declarative/declarative_apitest.cc b/chrome/browser/extensions/api/declarative/declarative_apitest.cc index cb6ad14..84db982 100644 --- a/chrome/browser/extensions/api/declarative/declarative_apitest.cc +++ b/chrome/browser/extensions/api/declarative/declarative_apitest.cc @@ -14,7 +14,9 @@ #include "chrome/common/extensions/extension.h" #include "chrome/test/base/ui_test_utils.h" -using namespace extensions; +using extensions::RulesRegistry; +using extensions::RulesRegistryService; +using extensions::TestRulesRegistry; namespace { const char kTestEvent[] = "webRequest.onRequest"; diff --git a/chrome/browser/extensions/api/declarative/substring_set_matcher_unittest.cc b/chrome/browser/extensions/api/declarative/substring_set_matcher_unittest.cc index 763c86c..d18ba36 100644 --- a/chrome/browser/extensions/api/declarative/substring_set_matcher_unittest.cc +++ b/chrome/browser/extensions/api/declarative/substring_set_matcher_unittest.cc @@ -10,7 +10,8 @@ #include "testing/gtest/include/gtest/gtest.h" -using namespace extensions; +using extensions::SubstringPattern; +using extensions::SubstringSetMatcher; TEST(SubstringSetMatcherTest, SubstringPattern) { SubstringPattern r1("Test", 2); diff --git a/chrome/browser/extensions/api/dns/dns_api.cc b/chrome/browser/extensions/api/dns/dns_api.cc index bc74483..11a0537 100644 --- a/chrome/browser/extensions/api/dns/dns_api.cc +++ b/chrome/browser/extensions/api/dns/dns_api.cc @@ -15,7 +15,9 @@ #include "net/base/net_util.h" using content::BrowserThread; -using namespace extensions::api::experimental; +using extensions::api::experimental::ResolveCallbackResolveInfo; + +namespace Resolve = extensions::api::experimental::Resolve; namespace extensions { diff --git a/chrome/browser/extensions/api/dns/dns_apitest.cc b/chrome/browser/extensions/api/dns/dns_apitest.cc index 6614530..7657db2 100644 --- a/chrome/browser/extensions/api/dns/dns_apitest.cc +++ b/chrome/browser/extensions/api/dns/dns_apitest.cc @@ -16,8 +16,8 @@ #include "net/base/net_util.h" using content::BrowserThread; - -using namespace extension_function_test_utils; +using extension_function_test_utils::CreateEmptyExtension; +using extension_function_test_utils::RunFunctionAndReturnResult; namespace { diff --git a/chrome/browser/extensions/api/permissions/permissions_api.cc b/chrome/browser/extensions/api/permissions/permissions_api.cc index 668b96fc..440050a 100644 --- a/chrome/browser/extensions/api/permissions/permissions_api.cc +++ b/chrome/browser/extensions/api/permissions/permissions_api.cc @@ -16,10 +16,14 @@ #include "chrome/common/extensions/url_pattern_set.h" #include "googleurl/src/gurl.h" +using extensions::api::permissions::Permissions; using extensions::PermissionsUpdater; -using extensions::permissions_api_helpers::PackPermissionSet; -using extensions::permissions_api_helpers::UnpackPermissionSet; -using namespace extensions::api::permissions; + +namespace Contains = extensions::api::permissions::Contains; +namespace GetAll = extensions::api::permissions::GetAll; +namespace Remove = extensions::api::permissions::Remove; +namespace Request = extensions::api::permissions::Request; +namespace helpers = extensions::permissions_api_helpers; namespace { @@ -46,7 +50,7 @@ bool ContainsPermissionsFunction::RunImpl() { scoped_ptr<Contains::Params> params(Contains::Params::Create(*args_)); scoped_refptr<ExtensionPermissionSet> permissions = - UnpackPermissionSet(params->permissions, &error_); + helpers::UnpackPermissionSet(params->permissions, &error_); if (!permissions.get()) return false; @@ -57,7 +61,7 @@ bool ContainsPermissionsFunction::RunImpl() { bool GetAllPermissionsFunction::RunImpl() { scoped_ptr<Permissions> permissions = - PackPermissionSet(GetExtension()->GetActivePermissions()); + helpers::PackPermissionSet(GetExtension()->GetActivePermissions()); result_.reset(GetAll::Result::Create(*permissions)); return true; } @@ -67,7 +71,7 @@ bool RemovePermissionsFunction::RunImpl() { EXTENSION_FUNCTION_VALIDATE(params.get()); scoped_refptr<ExtensionPermissionSet> permissions = - UnpackPermissionSet(params->permissions, &error_); + helpers::UnpackPermissionSet(params->permissions, &error_); if (!permissions.get()) return false; @@ -124,7 +128,8 @@ bool RequestPermissionsFunction::RunImpl() { scoped_ptr<Request::Params> params(Request::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); - requested_permissions_ = UnpackPermissionSet(params->permissions, &error_); + requested_permissions_ = + helpers::UnpackPermissionSet(params->permissions, &error_); if (!requested_permissions_.get()) return false; diff --git a/chrome/browser/extensions/api/serial/serial_apitest.cc b/chrome/browser/extensions/api/serial/serial_apitest.cc index b588047..e146cc9 100644 --- a/chrome/browser/extensions/api/serial/serial_apitest.cc +++ b/chrome/browser/extensions/api/serial/serial_apitest.cc @@ -14,8 +14,6 @@ using content::BrowserThread; -using namespace extension_function_test_utils; - namespace { class SerialApiTest : public ExtensionApiTest { diff --git a/chrome/browser/extensions/api/socket/socket_apitest.cc b/chrome/browser/extensions/api/socket/socket_apitest.cc index 0037542..7d8ec3d 100644 --- a/chrome/browser/extensions/api/socket/socket_apitest.cc +++ b/chrome/browser/extensions/api/socket/socket_apitest.cc @@ -15,7 +15,7 @@ #include "chrome/test/base/ui_test_utils.h" #include "net/test/test_server.h" -using namespace extension_function_test_utils; +namespace utils = extension_function_test_utils; namespace { @@ -43,15 +43,15 @@ class SocketApiTest : public ExtensionApiTest { IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPCreateGood) { scoped_refptr<extensions::SocketCreateFunction> socket_create_function( new extensions::SocketCreateFunction()); - scoped_refptr<Extension> empty_extension(CreateEmptyExtension()); + scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); socket_create_function->set_extension(empty_extension.get()); socket_create_function->set_has_callback(true); - scoped_ptr<base::Value> result(RunFunctionAndReturnResult( + scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult( socket_create_function, GenerateCreateFunctionArgs("udp", kHostname, kPort), - browser(), NONE)); + browser(), utils::NONE)); ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); DictionaryValue *value = static_cast<DictionaryValue*>(result.get()); int socketId = -1; @@ -62,15 +62,15 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPCreateGood) { IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPCreateGood) { scoped_refptr<extensions::SocketCreateFunction> socket_create_function( new extensions::SocketCreateFunction()); - scoped_refptr<Extension> empty_extension(CreateEmptyExtension()); + scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); socket_create_function->set_extension(empty_extension.get()); socket_create_function->set_has_callback(true); - scoped_ptr<base::Value> result(RunFunctionAndReturnResult( + scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult( socket_create_function, GenerateCreateFunctionArgs("udp", kHostname, kPort), - browser(), NONE)); + browser(), utils::NONE)); ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); DictionaryValue *value = static_cast<DictionaryValue*>(result.get()); int socketId = -1; @@ -81,17 +81,17 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPCreateGood) { IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketCreateBad) { scoped_refptr<extensions::SocketCreateFunction> socket_create_function( new extensions::SocketCreateFunction()); - scoped_refptr<Extension> empty_extension(CreateEmptyExtension()); + scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); socket_create_function->set_extension(empty_extension.get()); socket_create_function->set_has_callback(true); // TODO(miket): this test currently passes only because of artificial code // that doesn't run in production. Fix this when we're able to. - RunFunctionAndReturnError( + utils::RunFunctionAndReturnError( socket_create_function, GenerateCreateFunctionArgs("xxxx", kHostname, kPort), - browser(), NONE); + browser(), utils::NONE); } IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPExtension) { diff --git a/chrome/browser/extensions/api/webrequest/webrequest_api_unittest.cc b/chrome/browser/extensions/api/webrequest/webrequest_api_unittest.cc index f04bf79..f5e9f2c 100644 --- a/chrome/browser/extensions/api/webrequest/webrequest_api_unittest.cc +++ b/chrome/browser/extensions/api/webrequest/webrequest_api_unittest.cc @@ -35,6 +35,22 @@ namespace helpers = extension_webrequest_api_helpers; namespace keys = extension_webrequest_api_constants; +using helpers::CalculateOnAuthRequiredDelta; +using helpers::CalculateOnBeforeRequestDelta; +using helpers::CalculateOnBeforeSendHeadersDelta; +using helpers::CalculateOnHeadersReceivedDelta; +using helpers::CharListToString; +using helpers::EventLogEntries; +using helpers::EventResponseDelta; +using helpers::EventResponseDeltas; +using helpers::EventResponseDeltas; +using helpers::InDecreasingExtensionInstallationTimeOrder; +using helpers::MergeCancelOfResponses; +using helpers::MergeOnBeforeRequestResponses; +using helpers::ResponseHeader; +using helpers::ResponseHeaders; +using helpers::StringToCharList; + namespace { static void EventHandledOnIOThread( void* profile, @@ -806,7 +822,6 @@ INSTANTIATE_TEST_CASE_P( TEST(ExtensionWebRequestHelpersTest, TestInDecreasingExtensionInstallationTimeOrder) { - using namespace extension_webrequest_api_helpers; linked_ptr<EventResponseDelta> a( new EventResponseDelta("ext_1", base::Time::FromInternalValue(0))); linked_ptr<EventResponseDelta> b( @@ -817,7 +832,6 @@ TEST(ExtensionWebRequestHelpersTest, } TEST(ExtensionWebRequestHelpersTest, TestStringToCharList) { - using namespace extension_webrequest_api_helpers; ListValue list_value; list_value.Append(Value::CreateIntegerValue('1')); list_value.Append(Value::CreateIntegerValue('2')); @@ -837,7 +851,6 @@ TEST(ExtensionWebRequestHelpersTest, TestStringToCharList) { } TEST(ExtensionWebRequestHelpersTest, TestCalculateOnBeforeRequestDelta) { - using namespace extension_webrequest_api_helpers; const bool cancel = true; const GURL localhost("http://localhost"); scoped_ptr<EventResponseDelta> delta( @@ -849,7 +862,6 @@ TEST(ExtensionWebRequestHelpersTest, TestCalculateOnBeforeRequestDelta) { } TEST(ExtensionWebRequestHelpersTest, TestCalculateOnBeforeSendHeadersDelta) { - using namespace extension_webrequest_api_helpers; const bool cancel = true; std::string value; net::HttpRequestHeaders old_headers; @@ -910,7 +922,6 @@ TEST(ExtensionWebRequestHelpersTest, TestCalculateOnBeforeSendHeadersDelta) { } TEST(ExtensionWebRequestHelpersTest, TestCalculateOnHeadersReceivedDelta) { - using namespace extension_webrequest_api_helpers; const bool cancel = true; char base_headers_string[] = "HTTP/1.0 200 OK\r\n" @@ -947,7 +958,6 @@ TEST(ExtensionWebRequestHelpersTest, TestCalculateOnHeadersReceivedDelta) { } TEST(ExtensionWebRequestHelpersTest, TestCalculateOnAuthRequiredDelta) { - using namespace extension_webrequest_api_helpers; const bool cancel = true; string16 username = ASCIIToUTF16("foo"); @@ -966,7 +976,6 @@ TEST(ExtensionWebRequestHelpersTest, TestCalculateOnAuthRequiredDelta) { } TEST(ExtensionWebRequestHelpersTest, TestMergeCancelOfResponses) { - using namespace extension_webrequest_api_helpers; EventResponseDeltas deltas; EventLogEntries event_log; bool canceled = false; @@ -992,7 +1001,6 @@ TEST(ExtensionWebRequestHelpersTest, TestMergeCancelOfResponses) { } TEST(ExtensionWebRequestHelpersTest, TestMergeOnBeforeRequestResponses) { - using namespace extension_webrequest_api_helpers; EventResponseDeltas deltas; EventLogEntries event_log; std::set<std::string> conflicting_extensions; @@ -1072,7 +1080,6 @@ TEST(ExtensionWebRequestHelpersTest, TestMergeOnBeforeRequestResponses) { // This tests that we can redirect to data:// urls, which is considered // a kind of cancelling requests. TEST(ExtensionWebRequestHelpersTest, TestMergeOnBeforeRequestResponses2) { - using namespace extension_webrequest_api_helpers; EventResponseDeltas deltas; EventLogEntries event_log; std::set<std::string> conflicting_extensions; @@ -1136,7 +1143,6 @@ TEST(ExtensionWebRequestHelpersTest, TestMergeOnBeforeRequestResponses2) { } TEST(ExtensionWebRequestHelpersTest, TestMergeOnBeforeSendHeadersResponses) { - using namespace extension_webrequest_api_helpers; net::HttpRequestHeaders base_headers; base_headers.AddHeaderFromString("key1: value 1"); base_headers.AddHeaderFromString("key2: value 2"); @@ -1233,7 +1239,6 @@ TEST(ExtensionWebRequestHelpersTest, TestMergeOnBeforeSendHeadersResponses) { } TEST(ExtensionWebRequestHelpersTest, TestMergeOnHeadersReceivedResponses) { - using namespace extension_webrequest_api_helpers; EventLogEntries event_log; std::set<std::string> conflicting_extensions; std::string header_value; @@ -1318,7 +1323,6 @@ TEST(ExtensionWebRequestHelpersTest, TestMergeOnHeadersReceivedResponses) { // Check that we do not delete too much TEST(ExtensionWebRequestHelpersTest, TestMergeOnHeadersReceivedResponsesDeletion) { - using namespace extension_webrequest_api_helpers; EventLogEntries event_log; std::set<std::string> conflicting_extensions; std::string header_value; @@ -1362,7 +1366,6 @@ TEST(ExtensionWebRequestHelpersTest, } TEST(ExtensionWebRequestHelpersTest, TestMergeOnAuthRequiredResponses) { - using namespace extension_webrequest_api_helpers; EventLogEntries event_log; std::set<std::string> conflicting_extensions; EventResponseDeltas deltas; diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index 6ab586a..dbf198b 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -69,8 +69,12 @@ #include "chrome/browser/ui/views/ash/panel_view_aura.h" #endif -namespace keys = extension_tabs_module_constants; +namespace Get = extensions::api::windows::Get; +namespace GetAll = extensions::api::windows::GetAll; +namespace GetCurrent = extensions::api::windows::GetCurrent; +namespace GetLastFocused = extensions::api::windows::GetLastFocused; namespace errors = extension_manifest_errors; +namespace keys = extension_tabs_module_constants; using content::NavigationController; using content::NavigationEntry; @@ -78,7 +82,6 @@ using content::OpenURLParams; using content::Referrer; using content::RenderViewHost; using content::WebContents; -using namespace extensions::api::windows; const int CaptureVisibleTabFunction::kDefaultQuality = 90; diff --git a/chrome/browser/extensions/extension_tabs_test.cc b/chrome/browser/extensions/extension_tabs_test.cc index 950fe45..32879da 100644 --- a/chrome/browser/extensions/extension_tabs_test.cc +++ b/chrome/browser/extensions/extension_tabs_test.cc @@ -22,8 +22,8 @@ #include "chrome/test/base/ui_test_utils.h" #include "ui/gfx/rect.h" -using namespace extension_function_test_utils; namespace keys = extension_tabs_module_constants; +namespace utils = extension_function_test_utils; namespace { @@ -36,7 +36,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { // Invalid window ID error. EXPECT_TRUE(MatchPattern( - RunFunctionAndReturnError( + utils::RunFunctionAndReturnError( new GetWindowFunction(), base::StringPrintf("[%u]", window_id + 1), browser()), @@ -49,27 +49,27 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { else bounds = browser()->window()->GetBounds(); - scoped_ptr<base::DictionaryValue> result(ToDictionary( - RunFunctionAndReturnResult( + scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( + utils::RunFunctionAndReturnResult( new GetWindowFunction(), base::StringPrintf("[%u]", window_id), browser()))); - EXPECT_EQ(window_id, GetInteger(result.get(), "id")); - EXPECT_FALSE(GetBoolean(result.get(), "incognito")); - EXPECT_EQ("normal", GetString(result.get(), "type")); - EXPECT_EQ(bounds.x(), GetInteger(result.get(), "left")); - EXPECT_EQ(bounds.y(), GetInteger(result.get(), "top")); - EXPECT_EQ(bounds.width(), GetInteger(result.get(), "width")); - EXPECT_EQ(bounds.height(), GetInteger(result.get(), "height")); + EXPECT_EQ(window_id, utils::GetInteger(result.get(), "id")); + EXPECT_FALSE(utils::GetBoolean(result.get(), "incognito")); + EXPECT_EQ("normal", utils::GetString(result.get(), "type")); + EXPECT_EQ(bounds.x(), utils::GetInteger(result.get(), "left")); + EXPECT_EQ(bounds.y(), utils::GetInteger(result.get(), "top")); + EXPECT_EQ(bounds.width(), utils::GetInteger(result.get(), "width")); + EXPECT_EQ(bounds.height(), utils::GetInteger(result.get(), "height")); // With "populate" enabled. - result.reset(ToDictionary( - RunFunctionAndReturnResult( + result.reset(utils::ToDictionary( + utils::RunFunctionAndReturnResult( new GetWindowFunction(), base::StringPrintf("[%u, {\"populate\": true}]", window_id), browser()))); - EXPECT_EQ(window_id, GetInteger(result.get(), "id")); + EXPECT_EQ(window_id, utils::GetInteger(result.get(), "id")); // "populate" was enabled so tabs should be populated. ListValue* tabs = NULL; EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs)); @@ -78,7 +78,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { // browser test doesn't seem to do anything, so can't test the opposite // either. EXPECT_EQ(browser()->window()->IsActive(), - GetBoolean(result.get(), "focused")); + utils::GetBoolean(result.get(), "focused")); // TODO(aa): Minimized and maximized dimensions. Is there a way to set // minimize/maximize programmatically? @@ -86,24 +86,24 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { // Popup. Browser* popup_browser = Browser::CreateForType(Browser::TYPE_POPUP, browser()->profile()); - result.reset(ToDictionary( - RunFunctionAndReturnResult( + result.reset(utils::ToDictionary( + utils::RunFunctionAndReturnResult( new GetWindowFunction(), base::StringPrintf( "[%u]", ExtensionTabUtil::GetWindowId(popup_browser)), browser()))); - EXPECT_EQ("popup", GetString(result.get(), "type")); + EXPECT_EQ("popup", utils::GetString(result.get(), "type")); // Panel. Browser* panel_browser = Browser::CreateForType(Browser::TYPE_PANEL, browser()->profile()); - result.reset(ToDictionary( - RunFunctionAndReturnResult( + result.reset(utils::ToDictionary( + utils::RunFunctionAndReturnResult( new GetWindowFunction(), base::StringPrintf( "[%u]", ExtensionTabUtil::GetWindowId(panel_browser)), browser()))); - EXPECT_EQ("panel", GetString(result.get(), "type")); + EXPECT_EQ("panel", utils::GetString(result.get(), "type")); // Incognito. Browser* incognito_browser = CreateIncognitoBrowser(); @@ -111,20 +111,20 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { // Without "include_incognito". EXPECT_TRUE(MatchPattern( - RunFunctionAndReturnError( + utils::RunFunctionAndReturnError( new GetWindowFunction(), base::StringPrintf("[%u]", incognito_window_id), browser()), keys::kWindowNotFoundError)); // With "include_incognito". - result.reset(ToDictionary( - RunFunctionAndReturnResult( + result.reset(utils::ToDictionary( + utils::RunFunctionAndReturnResult( new GetWindowFunction(), base::StringPrintf("[%u]", incognito_window_id), browser(), - INCLUDE_INCOGNITO))); - EXPECT_TRUE(GetBoolean(result.get(), "incognito")); + utils::INCLUDE_INCOGNITO))); + EXPECT_TRUE(utils::GetBoolean(result.get(), "incognito")); } IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetCurrentWindow) { @@ -133,28 +133,28 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetCurrentWindow) { int new_id = ExtensionTabUtil::GetWindowId(new_browser); // Get the current window using new_browser. - scoped_ptr<base::DictionaryValue> result(ToDictionary( - RunFunctionAndReturnResult( + scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( + utils::RunFunctionAndReturnResult( new GetCurrentWindowFunction(), "[]", new_browser))); // The id should match the window id of the browser instance that was passed // to RunFunctionAndReturnResult. - EXPECT_EQ(new_id, GetInteger(result.get(), "id")); + EXPECT_EQ(new_id, utils::GetInteger(result.get(), "id")); ListValue* tabs = NULL; EXPECT_FALSE(result.get()->GetList(keys::kTabsKey, &tabs)); // Get the current window using the old window and make the tabs populated. - result.reset(ToDictionary( - RunFunctionAndReturnResult( + result.reset(utils::ToDictionary( + utils::RunFunctionAndReturnResult( new GetCurrentWindowFunction(), "[{\"populate\": true}]", browser()))); // The id should match the window id of the browser instance that was passed // to RunFunctionAndReturnResult. - EXPECT_EQ(window_id, GetInteger(result.get(), "id")); + EXPECT_EQ(window_id, utils::GetInteger(result.get(), "id")); // "populate" was enabled so tabs should be populated. EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs)); } @@ -165,27 +165,27 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetLastFocusedWindow) { Browser* new_browser = CreateBrowser(browser()->profile()); int focused_window_id = ExtensionTabUtil::GetWindowId(new_browser); - scoped_ptr<base::DictionaryValue> result(ToDictionary( - RunFunctionAndReturnResult( + scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( + utils::RunFunctionAndReturnResult( new GetLastFocusedWindowFunction(), "[]", new_browser))); // The id should always match the last focused window and does not depend // on what was passed to RunFunctionAndReturnResult. - EXPECT_EQ(focused_window_id, GetInteger(result.get(), "id")); + EXPECT_EQ(focused_window_id, utils::GetInteger(result.get(), "id")); ListValue* tabs = NULL; EXPECT_FALSE(result.get()->GetList(keys::kTabsKey, &tabs)); - result.reset(ToDictionary( - RunFunctionAndReturnResult( + result.reset(utils::ToDictionary( + utils::RunFunctionAndReturnResult( new GetLastFocusedWindowFunction(), "[{\"populate\": true}]", browser()))); // The id should always match the last focused window and does not depend // on what was passed to RunFunctionAndReturnResult. - EXPECT_EQ(focused_window_id, GetInteger(result.get(), "id")); + EXPECT_EQ(focused_window_id, utils::GetInteger(result.get(), "id")); // "populate" was enabled so tabs should be populated. EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs)); } @@ -201,8 +201,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindows) { window_ids.insert(ExtensionTabUtil::GetWindowId(new_browser)); } - scoped_ptr<base::ListValue> result(ToList( - RunFunctionAndReturnResult( + scoped_ptr<base::ListValue> result(utils::ToList( + utils::RunFunctionAndReturnResult( new GetAllWindowsFunction(), "[]", browser()))); @@ -212,7 +212,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindows) { for (size_t i = 0; i < NUM_WINDOWS; ++i) { DictionaryValue* result_window = NULL; EXPECT_TRUE(windows->GetDictionary(i, &result_window)); - result_ids.insert(GetInteger(result_window, "id")); + result_ids.insert(utils::GetInteger(result_window, "id")); // "populate" was not passed in so tabs are not populated. ListValue* tabs = NULL; @@ -222,8 +222,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindows) { EXPECT_EQ(window_ids, result_ids); result_ids.clear(); - result.reset(ToList( - RunFunctionAndReturnResult( + result.reset(utils::ToList( + utils::RunFunctionAndReturnResult( new GetAllWindowsFunction(), "[{\"populate\": true}]", browser()))); @@ -233,7 +233,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindows) { for (size_t i = 0; i < windows->GetSize(); ++i) { DictionaryValue* result_window = NULL; EXPECT_TRUE(windows->GetDictionary(i, &result_window)); - result_ids.insert(GetInteger(result_window, "id")); + result_ids.insert(utils::GetInteger(result_window, "id")); // "populate" was enabled so tabs should be populated. ListValue* tabs = NULL; @@ -247,12 +247,12 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, UpdateNoPermissions) { // The test empty extension has no permissions, therefore it should not get // tab data in the function result. scoped_refptr<UpdateTabFunction> update_tab_function(new UpdateTabFunction()); - scoped_refptr<Extension> empty_extension(CreateEmptyExtension()); + scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); update_tab_function->set_extension(empty_extension.get()); // Without a callback the function will not generate a result. update_tab_function->set_has_callback(true); - scoped_ptr<base::Value> result(RunFunctionAndReturnResult( + scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult( update_tab_function.get(), "[null, {\"url\": \"neutrinos\"}]", browser())); @@ -267,33 +267,33 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), IncognitoModePrefs::FORCED); // Run without an explicit "incognito" param. - scoped_ptr<base::DictionaryValue> result(ToDictionary( - RunFunctionAndReturnResult( + scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( + utils::RunFunctionAndReturnResult( new CreateWindowFunction(), kArgsWithoutExplicitIncognitoParam, browser(), - INCLUDE_INCOGNITO))); + utils::INCLUDE_INCOGNITO))); // Make sure it is a new(different) window. EXPECT_NE(ExtensionTabUtil::GetWindowId(browser()), - GetInteger(result.get(), "id")); + utils::GetInteger(result.get(), "id")); // ... and it is incognito. - EXPECT_TRUE(GetBoolean(result.get(), "incognito")); + EXPECT_TRUE(utils::GetBoolean(result.get(), "incognito")); // Now try creating a window from incognito window. Browser* incognito_browser = CreateIncognitoBrowser(); // Run without an explicit "incognito" param. - result.reset(ToDictionary( - RunFunctionAndReturnResult( + result.reset(utils::ToDictionary( + utils::RunFunctionAndReturnResult( new CreateWindowFunction(), kArgsWithoutExplicitIncognitoParam, incognito_browser, - INCLUDE_INCOGNITO))); + utils::INCLUDE_INCOGNITO))); // Make sure it is a new(different) window. EXPECT_NE(ExtensionTabUtil::GetWindowId(incognito_browser), - GetInteger(result.get(), "id")); + utils::GetInteger(result.get(), "id")); // ... and it is incognito. - EXPECT_TRUE(GetBoolean(result.get(), "incognito")); + EXPECT_TRUE(utils::GetBoolean(result.get(), "incognito")); } IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, @@ -303,33 +303,33 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), IncognitoModePrefs::FORCED); // Run without an explicit "incognito" param. - scoped_ptr<base::DictionaryValue> result(ToDictionary( - RunFunctionAndReturnResult( + scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( + utils::RunFunctionAndReturnResult( new CreateWindowFunction(), kEmptyArgs, browser(), - INCLUDE_INCOGNITO))); + utils::INCLUDE_INCOGNITO))); // Make sure it is a new(different) window. EXPECT_NE(ExtensionTabUtil::GetWindowId(browser()), - GetInteger(result.get(), "id")); + utils::GetInteger(result.get(), "id")); // ... and it is incognito. - EXPECT_TRUE(GetBoolean(result.get(), "incognito")); + EXPECT_TRUE(utils::GetBoolean(result.get(), "incognito")); // Now try creating a window from incognito window. Browser* incognito_browser = CreateIncognitoBrowser(); // Run without an explicit "incognito" param. - result.reset(ToDictionary( - RunFunctionAndReturnResult( + result.reset(utils::ToDictionary( + utils::RunFunctionAndReturnResult( new CreateWindowFunction(), kEmptyArgs, incognito_browser, - INCLUDE_INCOGNITO))); + utils::INCLUDE_INCOGNITO))); // Make sure it is a new(different) window. EXPECT_NE(ExtensionTabUtil::GetWindowId(incognito_browser), - GetInteger(result.get(), "id")); + utils::GetInteger(result.get(), "id")); // ... and it is incognito. - EXPECT_TRUE(GetBoolean(result.get(), "incognito")); + EXPECT_TRUE(utils::GetBoolean(result.get(), "incognito")); } IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, @@ -342,7 +342,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, // Run with an explicit "incognito" param. EXPECT_TRUE(MatchPattern( - RunFunctionAndReturnError( + utils::RunFunctionAndReturnError( new CreateWindowFunction(), kArgsWithExplicitIncognitoParam, browser()), @@ -352,7 +352,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, Browser* incognito_browser = CreateIncognitoBrowser(); // Run with an explicit "incognito" param. EXPECT_TRUE(MatchPattern( - RunFunctionAndReturnError( + utils::RunFunctionAndReturnError( new CreateWindowFunction(), kArgsWithExplicitIncognitoParam, incognito_browser), @@ -370,7 +370,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, IncognitoModePrefs::DISABLED); // Run in normal window. EXPECT_TRUE(MatchPattern( - RunFunctionAndReturnError( + utils::RunFunctionAndReturnError( new CreateWindowFunction(), kArgs, browser()), @@ -378,7 +378,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, // Run in incognito window. EXPECT_TRUE(MatchPattern( - RunFunctionAndReturnError( + utils::RunFunctionAndReturnError( new CreateWindowFunction(), kArgs, incognito_browser), @@ -395,8 +395,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryCurrentWindowTabs) { int window_id = ExtensionTabUtil::GetWindowId(browser()); // Get tabs in the 'current' window called from non-focused browser. - scoped_ptr<base::ListValue> result(ToList( - RunFunctionAndReturnResult( + scoped_ptr<base::ListValue> result(utils::ToList( + utils::RunFunctionAndReturnResult( new QueryTabsFunction(), "[{\"currentWindow\":true}]", browser()))); @@ -407,12 +407,12 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryCurrentWindowTabs) { for (size_t i = 0; i < result_tabs->GetSize(); ++i) { DictionaryValue* result_tab = NULL; EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab)); - EXPECT_EQ(window_id, GetInteger(result_tab, keys::kWindowIdKey)); + EXPECT_EQ(window_id, utils::GetInteger(result_tab, keys::kWindowIdKey)); } // Get tabs NOT in the 'current' window called from non-focused browser. - result.reset(ToList( - RunFunctionAndReturnResult( + result.reset(utils::ToList( + utils::RunFunctionAndReturnResult( new QueryTabsFunction(), "[{\"currentWindow\":false}]", browser()))); @@ -423,7 +423,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryCurrentWindowTabs) { for (size_t i = 0; i < kExtraWindows; ++i) { DictionaryValue* result_tab = NULL; EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab)); - EXPECT_NE(window_id, GetInteger(result_tab, keys::kWindowIdKey)); + EXPECT_NE(window_id, utils::GetInteger(result_tab, keys::kWindowIdKey)); } } @@ -438,8 +438,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryLastFocusedWindowTabs) { int focused_window_id = ExtensionTabUtil::GetWindowId(focused_window); // Get tabs in the 'last focused' window called from non-focused browser. - scoped_ptr<base::ListValue> result(ToList( - RunFunctionAndReturnResult( + scoped_ptr<base::ListValue> result(utils::ToList( + utils::RunFunctionAndReturnResult( new QueryTabsFunction(), "[{\"lastFocusedWindow\":true}]", browser()))); @@ -450,12 +450,13 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryLastFocusedWindowTabs) { for (size_t i = 0; i < result_tabs->GetSize(); ++i) { DictionaryValue* result_tab = NULL; EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab)); - EXPECT_EQ(focused_window_id, GetInteger(result_tab, keys::kWindowIdKey)); + EXPECT_EQ(focused_window_id, utils::GetInteger(result_tab, + keys::kWindowIdKey)); } // Get tabs NOT in the 'last focused' window called from the focused browser. - result.reset(ToList( - RunFunctionAndReturnResult( + result.reset(utils::ToList( + utils::RunFunctionAndReturnResult( new QueryTabsFunction(), "[{\"lastFocusedWindow\":false}]", browser()))); @@ -466,7 +467,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryLastFocusedWindowTabs) { for (size_t i = 0; i < result_tabs->GetSize(); ++i) { DictionaryValue* result_tab = NULL; EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab)); - EXPECT_NE(focused_window_id, GetInteger(result_tab, keys::kWindowIdKey)); + EXPECT_NE(focused_window_id, utils::GetInteger(result_tab, + keys::kWindowIdKey)); } } @@ -486,13 +488,13 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DontCreateTabInClosingPopupWindow) { static const char kNewBlankTabArgs[] = "[{\"url\": \"about:blank\", \"windowId\": %u}]"; - scoped_ptr<base::DictionaryValue> result(ToDictionary( - RunFunctionAndReturnResult( + scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( + utils::RunFunctionAndReturnResult( create_tab_function.get(), base::StringPrintf(kNewBlankTabArgs, window_id), browser()))); - EXPECT_NE(window_id, GetInteger(result.get(), "windowId")); + EXPECT_NE(window_id, utils::GetInteger(result.get(), "windowId")); } IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, InvalidUpdateWindowState) { @@ -501,7 +503,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, InvalidUpdateWindowState) { static const char kArgsMinimizedWithFocus[] = "[%u, {\"state\": \"minimized\", \"focused\": true}]"; EXPECT_TRUE(MatchPattern( - RunFunctionAndReturnError( + utils::RunFunctionAndReturnError( new UpdateWindowFunction(), base::StringPrintf(kArgsMinimizedWithFocus, window_id), browser()), @@ -510,7 +512,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, InvalidUpdateWindowState) { static const char kArgsMaximizedWithoutFocus[] = "[%u, {\"state\": \"maximized\", \"focused\": false}]"; EXPECT_TRUE(MatchPattern( - RunFunctionAndReturnError( + utils::RunFunctionAndReturnError( new UpdateWindowFunction(), base::StringPrintf(kArgsMaximizedWithoutFocus, window_id), browser()), @@ -519,7 +521,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, InvalidUpdateWindowState) { static const char kArgsMinimizedWithBounds[] = "[%u, {\"state\": \"minimized\", \"width\": 500}]"; EXPECT_TRUE(MatchPattern( - RunFunctionAndReturnError( + utils::RunFunctionAndReturnError( new UpdateWindowFunction(), base::StringPrintf(kArgsMinimizedWithBounds, window_id), browser()), @@ -528,7 +530,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, InvalidUpdateWindowState) { static const char kArgsMaximizedWithBounds[] = "[%u, {\"state\": \"maximized\", \"width\": 500}]"; EXPECT_TRUE(MatchPattern( - RunFunctionAndReturnError( + utils::RunFunctionAndReturnError( new UpdateWindowFunction(), base::StringPrintf(kArgsMaximizedWithBounds, window_id), browser()), diff --git a/chrome/browser/extensions/extension_webstore_private_apitest.cc b/chrome/browser/extensions/extension_webstore_private_apitest.cc index c48ddde..2fb2b45 100644 --- a/chrome/browser/extensions/extension_webstore_private_apitest.cc +++ b/chrome/browser/extensions/extension_webstore_private_apitest.cc @@ -30,7 +30,7 @@ using content::GpuFeatureType; -using namespace extension_function_test_utils; +namespace utils = extension_function_test_utils; namespace { @@ -229,7 +229,7 @@ class ExtensionWebstoreGetWebGLStatusTest : public InProcessBrowserTest { static const char kEmptyArgs[] = "[]"; static const char kWebGLStatusAllowed[] = "webgl_allowed"; static const char kWebGLStatusBlocked[] = "webgl_blocked"; - scoped_ptr<base::Value> result(RunFunctionAndReturnResult( + scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult( new GetWebGLStatusFunction(), kEmptyArgs, browser())); EXPECT_EQ(base::Value::TYPE_STRING, result->GetType()); StringValue* value = static_cast<StringValue*>(result.get()); diff --git a/chrome/browser/extensions/settings/settings_apitest.cc b/chrome/browser/extensions/settings/settings_apitest.cc index 52832b8..a3bed62 100644 --- a/chrome/browser/extensions/settings/settings_apitest.cc +++ b/chrome/browser/extensions/settings/settings_apitest.cc @@ -20,7 +20,11 @@ namespace extensions { -using namespace settings_namespace; +using settings_namespace::FromString; +using settings_namespace::LOCAL; +using settings_namespace::Namespace; +using settings_namespace::SYNC; +using settings_namespace::ToString; namespace { diff --git a/chrome/browser/extensions/settings/settings_frontend_unittest.cc b/chrome/browser/extensions/settings/settings_frontend_unittest.cc index 3766ce4..e2fd81d 100644 --- a/chrome/browser/extensions/settings/settings_frontend_unittest.cc +++ b/chrome/browser/extensions/settings/settings_frontend_unittest.cc @@ -21,8 +21,8 @@ using content::BrowserThread; namespace extensions { -using namespace settings_namespace; -using namespace settings_test_util; +namespace settings = settings_namespace; +namespace util = settings_test_util; namespace { @@ -66,13 +66,13 @@ scoped_ptr<Value> CreateMegabyte() { class ExtensionSettingsFrontendTest : public testing::Test { public: ExtensionSettingsFrontendTest() - : storage_factory_(new ScopedSettingsStorageFactory()), + : storage_factory_(new util::ScopedSettingsStorageFactory()), ui_thread_(BrowserThread::UI, MessageLoop::current()), file_thread_(BrowserThread::FILE, MessageLoop::current()) {} virtual void SetUp() OVERRIDE { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); - profile_.reset(new MockProfile(temp_dir_.path())); + profile_.reset(new util::MockProfile(temp_dir_.path())); ResetFrontend(); } @@ -89,9 +89,9 @@ class ExtensionSettingsFrontendTest : public testing::Test { } ScopedTempDir temp_dir_; - scoped_ptr<MockProfile> profile_; + scoped_ptr<util::MockProfile> profile_; scoped_ptr<SettingsFrontend> frontend_; - scoped_refptr<ScopedSettingsStorageFactory> storage_factory_; + scoped_refptr<util::ScopedSettingsStorageFactory> storage_factory_; private: MessageLoop message_loop_; @@ -108,7 +108,7 @@ TEST_F(ExtensionSettingsFrontendTest, SettingsPreservedAcrossReconstruction) { profile_->GetMockExtensionService()->AddExtensionWithId( id, Extension::TYPE_EXTENSION); - SettingsStorage* storage = GetStorage(id, frontend_.get()); + SettingsStorage* storage = util::GetStorage(id, frontend_.get()); // The correctness of Get/Set/Remove/Clear is tested elsewhere so no need to // be too rigorous. @@ -125,7 +125,7 @@ TEST_F(ExtensionSettingsFrontendTest, SettingsPreservedAcrossReconstruction) { } ResetFrontend(); - storage = GetStorage(id, frontend_.get()); + storage = util::GetStorage(id, frontend_.get()); { SettingsStorage::ReadResult result = storage->Get(); @@ -139,7 +139,7 @@ TEST_F(ExtensionSettingsFrontendTest, SettingsClearedOnUninstall) { profile_->GetMockExtensionService()->AddExtensionWithId( id, Extension::TYPE_PACKAGED_APP); - SettingsStorage* storage = GetStorage(id, frontend_.get()); + SettingsStorage* storage = util::GetStorage(id, frontend_.get()); { StringValue bar("bar"); @@ -152,7 +152,7 @@ TEST_F(ExtensionSettingsFrontendTest, SettingsClearedOnUninstall) { MessageLoop::current()->RunAllPending(); // The storage area may no longer be valid post-uninstall, so re-request. - storage = GetStorage(id, frontend_.get()); + storage = util::GetStorage(id, frontend_.get()); { SettingsStorage::ReadResult result = storage->Get(); ASSERT_FALSE(result.HasError()); @@ -165,7 +165,7 @@ TEST_F(ExtensionSettingsFrontendTest, LeveldbDatabaseDeletedFromDiskOnClear) { profile_->GetMockExtensionService()->AddExtensionWithId( id, Extension::TYPE_EXTENSION); - SettingsStorage* storage = GetStorage(id, frontend_.get()); + SettingsStorage* storage = util::GetStorage(id, frontend_.get()); { StringValue bar("bar"); @@ -199,7 +199,7 @@ TEST_F(ExtensionSettingsFrontendTest, storage_factory_->Reset(new NullSettingsStorageFactory()); - SettingsStorage* storage = GetStorage(id, frontend_.get()); + SettingsStorage* storage = util::GetStorage(id, frontend_.get()); ASSERT_TRUE(storage != NULL); EXPECT_TRUE(storage->Get().HasError()); @@ -211,7 +211,7 @@ TEST_F(ExtensionSettingsFrontendTest, // storage areas start working. storage_factory_->Reset(new SettingsLeveldbStorage::Factory()); - storage = GetStorage(id, frontend_.get()); + storage = util::GetStorage(id, frontend_.get()); ASSERT_TRUE(storage != NULL); EXPECT_TRUE(storage->Get().HasError()); @@ -231,8 +231,10 @@ TEST_F(ExtensionSettingsFrontendTest, profile_->GetMockExtensionService()->AddExtensionWithId( id, Extension::TYPE_EXTENSION); - SettingsStorage* sync_storage = GetStorage(id, SYNC, frontend_.get()); - SettingsStorage* local_storage = GetStorage(id, LOCAL, frontend_.get()); + SettingsStorage* sync_storage = + util::GetStorage(id, settings::SYNC, frontend_.get()); + SettingsStorage* local_storage = + util::GetStorage(id, settings::LOCAL, frontend_.get()); // Sync storage should run out after ~100K. scoped_ptr<Value> kilobyte = CreateKilobyte(); @@ -307,9 +309,9 @@ TEST_F(ExtensionSettingsFrontendTest, id, Extension::TYPE_EXTENSION, permissions); frontend_->RunWithStorage( - id, SYNC, base::Bind(&UnlimitedSyncStorageTestCallback)); + id, settings::SYNC, base::Bind(&UnlimitedSyncStorageTestCallback)); frontend_->RunWithStorage( - id, LOCAL, base::Bind(&UnlimitedLocalStorageTestCallback)); + id, settings::LOCAL, base::Bind(&UnlimitedLocalStorageTestCallback)); MessageLoop::current()->RunAllPending(); } diff --git a/chrome/browser/extensions/settings/settings_sync_unittest.cc b/chrome/browser/extensions/settings/settings_sync_unittest.cc index 730bd87..05a1780 100644 --- a/chrome/browser/extensions/settings/settings_sync_unittest.cc +++ b/chrome/browser/extensions/settings/settings_sync_unittest.cc @@ -24,7 +24,7 @@ using content::BrowserThread; namespace extensions { -using namespace settings_test_util; +namespace util = settings_test_util; namespace { @@ -180,11 +180,11 @@ class ExtensionSettingsSyncTest : public testing::Test { ExtensionSettingsSyncTest() : ui_thread_(BrowserThread::UI, MessageLoop::current()), file_thread_(BrowserThread::FILE, MessageLoop::current()), - storage_factory_(new ScopedSettingsStorageFactory()) {} + storage_factory_(new util::ScopedSettingsStorageFactory()) {} virtual void SetUp() OVERRIDE { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); - profile_.reset(new MockProfile(temp_dir_.path())); + profile_.reset(new util::MockProfile(temp_dir_.path())); storage_factory_->Reset(new SettingsLeveldbStorage::Factory()); frontend_.reset( SettingsFrontend::Create(storage_factory_.get(), profile_.get())); @@ -201,7 +201,7 @@ class ExtensionSettingsSyncTest : public testing::Test { SettingsStorage* AddExtensionAndGetStorage( const std::string& id, Extension::Type type) { profile_->GetMockExtensionService()->AddExtensionWithId(id, type); - return GetStorage(id, frontend_.get()); + return util::GetStorage(id, frontend_.get()); } // Gets the SyncableService for the given sync type. @@ -232,9 +232,9 @@ class ExtensionSettingsSyncTest : public testing::Test { ScopedTempDir temp_dir_; MockSyncChangeProcessor sync_; - scoped_ptr<MockProfile> profile_; + scoped_ptr<util::MockProfile> profile_; scoped_ptr<SettingsFrontend> frontend_; - scoped_refptr<ScopedSettingsStorageFactory> storage_factory_; + scoped_refptr<util::ScopedSettingsStorageFactory> storage_factory_; }; // Get a semblance of coverage for both EXTENSION_SETTINGS and APP_SETTINGS diff --git a/chrome/browser/history/top_sites_extension_test.cc b/chrome/browser/history/top_sites_extension_test.cc index 6ceea51..13f8e69 100644 --- a/chrome/browser/history/top_sites_extension_test.cc +++ b/chrome/browser/history/top_sites_extension_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// 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. @@ -11,7 +11,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/test/base/in_process_browser_test.h" -using namespace extension_function_test_utils; +namespace utils = extension_function_test_utils; namespace { @@ -60,7 +60,7 @@ IN_PROC_BROWSER_TEST_F(TopSitesExtensionTest, GetTopSites) { // Without a callback the function will not generate a result. get_top_sites_function->set_has_callback(true); - scoped_ptr<base::Value> result(RunFunctionAndReturnResult( + scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult( get_top_sites_function.get(), "[]", browser())); base::ListValue* list; ASSERT_TRUE(result->GetAsList(&list)); diff --git a/chrome/common/extensions/csp_validator_unittest.cc b/chrome/common/extensions/csp_validator_unittest.cc index 5d735fc..b7fa4da 100644 --- a/chrome/common/extensions/csp_validator_unittest.cc +++ b/chrome/common/extensions/csp_validator_unittest.cc @@ -1,11 +1,12 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// 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/common/extensions/csp_validator.h" #include "testing/gtest/include/gtest/gtest.h" -using namespace extensions::csp_validator; +using extensions::csp_validator::ContentSecurityPolicyIsLegal; +using extensions::csp_validator::ContentSecurityPolicyIsSecure; TEST(ExtensionCSPValidator, IsLegal) { EXPECT_TRUE(ContentSecurityPolicyIsLegal("foo")); diff --git a/chrome/renderer/extensions/extension_dispatcher.cc b/chrome/renderer/extensions/extension_dispatcher.cc index 841ca21..23c57e4 100644 --- a/chrome/renderer/extensions/extension_dispatcher.cc +++ b/chrome/renderer/extensions/extension_dispatcher.cc @@ -35,6 +35,20 @@ #include "ui/base/resource/resource_bundle.h" #include "v8/include/v8.h" +using content::RenderThread; +using extensions::MiscellaneousBindings; +using extensions::SchemaGeneratedBindings; +using WebKit::WebDataSource; +using WebKit::WebDocument; +using WebKit::WebFrame; +using WebKit::WebSecurityPolicy; +using WebKit::WebString; +using WebKit::WebScopedUserGesture; +using WebKit::WebVector; +using WebKit::WebView; + +namespace util = extensions::custom_bindings_util; + namespace { static const int64 kInitialExtensionIdleHandlerDelayMs = 5*1000; @@ -48,18 +62,6 @@ ChromeV8Context::ContextType ExtensionGroupToContextType(int extension_group) { } -using namespace extensions; - -using WebKit::WebDataSource; -using WebKit::WebDocument; -using WebKit::WebFrame; -using WebKit::WebSecurityPolicy; -using WebKit::WebString; -using WebKit::WebScopedUserGesture; -using WebKit::WebVector; -using WebKit::WebView; -using content::RenderThread; - ExtensionDispatcher::ExtensionDispatcher() : is_webkit_initialized_(false), webrequest_adblock_(false), @@ -125,8 +127,7 @@ void ExtensionDispatcher::WebKitInitialized() { RegisterExtension(new ChromeV8Extension( "extensions/apitest.js", IDR_EXTENSION_APITEST_JS, NULL), true); - std::vector<v8::Extension*> custom_bindings = - custom_bindings_util::GetAll(this); + std::vector<v8::Extension*> custom_bindings = util::GetAll(this); for (std::vector<v8::Extension*>::iterator it = custom_bindings.begin(); it != custom_bindings.end(); ++it) { RegisterExtension(*it, true); @@ -323,8 +324,7 @@ bool ExtensionDispatcher::AllowScriptExtension( UserScriptSlave::GetDataSourceURLForFrame(frame)))) { // If the extension is a custom API binding, only allow if the extension // has permission to use the API. - std::string custom_binding_api_name = - custom_bindings_util::GetAPIName(v8_extension_name); + std::string custom_binding_api_name = util::GetAPIName(v8_extension_name); if (!custom_binding_api_name.empty()) { std::string extension_id = GetExtensionID(frame, world_id); const Extension* extension = extensions_.GetByID(extension_id); @@ -340,8 +340,7 @@ bool ExtensionDispatcher::AllowScriptExtension( CHECK_EQ("invalid", extension_id); return false; } - return custom_bindings_util::AllowAPIInjection( - custom_binding_api_name, *extension, this); + return util::AllowAPIInjection(custom_binding_api_name, *extension, this); } return true; |