| Index: chrome/browser/extensions/api/tabs/tabs_test.cc
|
| ===================================================================
|
| --- chrome/browser/extensions/api/tabs/tabs_test.cc (revision 176046)
|
| +++ chrome/browser/extensions/api/tabs/tabs_test.cc (working copy)
|
| @@ -2,15 +2,15 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "chrome/browser/extensions/api/tabs/tabs.h"
|
|
|
| #include <string>
|
|
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/scoped_ptr.h"
|
| -#include "base/string_util.h"
|
| #include "base/stringprintf.h"
|
| +#include "base/string_util.h"
|
| #include "base/values.h"
|
| -#include "chrome/browser/extensions/api/tabs/tabs_api.h"
|
| #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
|
| #include "chrome/browser/extensions/extension_function_test_utils.h"
|
| #include "chrome/browser/extensions/extension_tab_util.h"
|
| @@ -38,7 +38,7 @@
|
| int window_id = ExtensionTabUtil::GetWindowId(browser());
|
|
|
| // Invalid window ID error.
|
| - scoped_refptr<WindowsGetFunction> function = new WindowsGetFunction();
|
| + scoped_refptr<GetWindowFunction> function = new GetWindowFunction();
|
| scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension());
|
| function->set_extension(extension.get());
|
| EXPECT_TRUE(MatchPattern(
|
| @@ -55,7 +55,7 @@
|
| else
|
| bounds = browser()->window()->GetBounds();
|
|
|
| - function = new WindowsGetFunction();
|
| + function = new GetWindowFunction();
|
| function->set_extension(extension.get());
|
| scoped_ptr<base::DictionaryValue> result(utils::ToDictionary(
|
| utils::RunFunctionAndReturnSingleResult(
|
| @@ -71,7 +71,7 @@
|
| EXPECT_EQ(bounds.height(), utils::GetInteger(result.get(), "height"));
|
|
|
| // With "populate" enabled.
|
| - function = new WindowsGetFunction();
|
| + function = new GetWindowFunction();
|
| function->set_extension(extension.get());
|
| result.reset(utils::ToDictionary(
|
| utils::RunFunctionAndReturnSingleResult(
|
| @@ -96,7 +96,7 @@
|
| // Popup.
|
| Browser* popup_browser = new Browser(
|
| Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile()));
|
| - function = new WindowsGetFunction();
|
| + function = new GetWindowFunction();
|
| function->set_extension(extension.get());
|
| result.reset(utils::ToDictionary(
|
| utils::RunFunctionAndReturnSingleResult(
|
| @@ -109,7 +109,7 @@
|
| // Panel.
|
| Browser* panel_browser = new Browser(
|
| Browser::CreateParams(Browser::TYPE_PANEL, browser()->profile()));
|
| - function = new WindowsGetFunction();
|
| + function = new GetWindowFunction();
|
| function->set_extension(extension.get());
|
| result.reset(utils::ToDictionary(
|
| utils::RunFunctionAndReturnSingleResult(
|
| @@ -124,7 +124,7 @@
|
| int incognito_window_id = ExtensionTabUtil::GetWindowId(incognito_browser);
|
|
|
| // Without "include_incognito".
|
| - function = new WindowsGetFunction();
|
| + function = new GetWindowFunction();
|
| function->set_extension(extension.get());
|
| EXPECT_TRUE(MatchPattern(
|
| utils::RunFunctionAndReturnError(
|
| @@ -134,7 +134,7 @@
|
| keys::kWindowNotFoundError));
|
|
|
| // With "include_incognito".
|
| - function = new WindowsGetFunction();
|
| + function = new GetWindowFunction();
|
| function->set_extension(extension.get());
|
| result.reset(utils::ToDictionary(
|
| utils::RunFunctionAndReturnSingleResult(
|
| @@ -151,8 +151,8 @@
|
| int new_id = ExtensionTabUtil::GetWindowId(new_browser);
|
|
|
| // Get the current window using new_browser.
|
| - scoped_refptr<WindowsGetCurrentFunction> function =
|
| - new WindowsGetCurrentFunction();
|
| + scoped_refptr<GetCurrentWindowFunction> function =
|
| + new GetCurrentWindowFunction();
|
| scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension());
|
| function->set_extension(extension.get());
|
| scoped_ptr<base::DictionaryValue> result(utils::ToDictionary(
|
| @@ -167,7 +167,7 @@
|
| EXPECT_FALSE(result.get()->GetList(keys::kTabsKey, &tabs));
|
|
|
| // Get the current window using the old window and make the tabs populated.
|
| - function = new WindowsGetCurrentFunction();
|
| + function = new GetCurrentWindowFunction();
|
| function->set_extension(extension.get());
|
| result.reset(utils::ToDictionary(
|
| utils::RunFunctionAndReturnSingleResult(function.get(),
|
| @@ -192,7 +192,7 @@
|
| window_ids.insert(ExtensionTabUtil::GetWindowId(new_browser));
|
| }
|
|
|
| - scoped_refptr<WindowsGetAllFunction> function = new WindowsGetAllFunction();
|
| + scoped_refptr<GetAllWindowsFunction> function = new GetAllWindowsFunction();
|
| scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension());
|
| function->set_extension(extension.get());
|
| scoped_ptr<base::ListValue> result(utils::ToList(
|
| @@ -215,7 +215,7 @@
|
| EXPECT_EQ(window_ids, result_ids);
|
|
|
| result_ids.clear();
|
| - function = new WindowsGetAllFunction();
|
| + function = new GetAllWindowsFunction();
|
| function->set_extension(extension.get());
|
| result.reset(utils::ToList(
|
| utils::RunFunctionAndReturnSingleResult(function.get(),
|
| @@ -240,8 +240,7 @@
|
| 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<TabsUpdateFunction> update_tab_function(
|
| - new TabsUpdateFunction());
|
| + scoped_refptr<UpdateTabFunction> update_tab_function(new UpdateTabFunction());
|
| scoped_refptr<extensions::Extension> empty_extension(
|
| utils::CreateEmptyExtension());
|
| update_tab_function->set_extension(empty_extension.get());
|
| @@ -266,7 +265,7 @@
|
| IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(),
|
| IncognitoModePrefs::FORCED);
|
| // Run without an explicit "incognito" param.
|
| - scoped_refptr<WindowsCreateFunction> function(new WindowsCreateFunction());
|
| + scoped_refptr<CreateWindowFunction> function(new CreateWindowFunction());
|
| scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension());
|
| function->set_extension(extension.get());
|
| scoped_ptr<base::DictionaryValue> result(utils::ToDictionary(
|
| @@ -285,7 +284,7 @@
|
| // Now try creating a window from incognito window.
|
| Browser* incognito_browser = CreateIncognitoBrowser();
|
| // Run without an explicit "incognito" param.
|
| - function = new WindowsCreateFunction();
|
| + function = new CreateWindowFunction();
|
| function->set_extension(extension.get());
|
| result.reset(utils::ToDictionary(
|
| utils::RunFunctionAndReturnSingleResult(
|
| @@ -307,7 +306,7 @@
|
| IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(),
|
| IncognitoModePrefs::FORCED);
|
| // Run without an explicit "incognito" param.
|
| - scoped_refptr<WindowsCreateFunction> function = new WindowsCreateFunction();
|
| + scoped_refptr<CreateWindowFunction> function = new CreateWindowFunction();
|
| scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension());
|
| function->set_extension(extension.get());
|
| scoped_ptr<base::DictionaryValue> result(utils::ToDictionary(
|
| @@ -325,7 +324,7 @@
|
| // Now try creating a window from incognito window.
|
| Browser* incognito_browser = CreateIncognitoBrowser();
|
| // Run without an explicit "incognito" param.
|
| - function = new WindowsCreateFunction();
|
| + function = new CreateWindowFunction();
|
| function->set_extension(extension.get());
|
| result.reset(utils::ToDictionary(
|
| utils::RunFunctionAndReturnSingleResult(function.get(),
|
| @@ -348,7 +347,7 @@
|
| IncognitoModePrefs::FORCED);
|
|
|
| // Run with an explicit "incognito" param.
|
| - scoped_refptr<WindowsCreateFunction> function = new WindowsCreateFunction();
|
| + scoped_refptr<CreateWindowFunction> function = new CreateWindowFunction();
|
| scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension());
|
| function->set_extension(extension.get());
|
| EXPECT_TRUE(MatchPattern(
|
| @@ -360,7 +359,7 @@
|
| // Now try opening a normal window from incognito window.
|
| Browser* incognito_browser = CreateIncognitoBrowser();
|
| // Run with an explicit "incognito" param.
|
| - function = new WindowsCreateFunction();
|
| + function = new CreateWindowFunction();
|
| function->set_extension(extension.get());
|
| EXPECT_TRUE(MatchPattern(
|
| utils::RunFunctionAndReturnError(function.get(),
|
| @@ -379,7 +378,7 @@
|
| IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(),
|
| IncognitoModePrefs::DISABLED);
|
| // Run in normal window.
|
| - scoped_refptr<WindowsCreateFunction> function = new WindowsCreateFunction();
|
| + scoped_refptr<CreateWindowFunction> function = new CreateWindowFunction();
|
| scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension());
|
| function->set_extension(extension.get());
|
| EXPECT_TRUE(MatchPattern(
|
| @@ -389,7 +388,7 @@
|
| keys::kIncognitoModeIsDisabled));
|
|
|
| // Run in incognito window.
|
| - function = new WindowsCreateFunction();
|
| + function = new CreateWindowFunction();
|
| function->set_extension(extension.get());
|
| EXPECT_TRUE(MatchPattern(
|
| utils::RunFunctionAndReturnError(function.get(),
|
| @@ -408,7 +407,7 @@
|
| int window_id = ExtensionTabUtil::GetWindowId(browser());
|
|
|
| // Get tabs in the 'current' window called from non-focused browser.
|
| - scoped_refptr<TabsQueryFunction> function = new TabsQueryFunction();
|
| + scoped_refptr<QueryTabsFunction> function = new QueryTabsFunction();
|
| function->set_extension(utils::CreateEmptyExtension().get());
|
| scoped_ptr<base::ListValue> result(utils::ToList(
|
| utils::RunFunctionAndReturnSingleResult(function.get(),
|
| @@ -425,7 +424,7 @@
|
| }
|
|
|
| // Get tabs NOT in the 'current' window called from non-focused browser.
|
| - function = new TabsQueryFunction();
|
| + function = new QueryTabsFunction();
|
| function->set_extension(utils::CreateEmptyExtension().get());
|
| result.reset(utils::ToList(
|
| utils::RunFunctionAndReturnSingleResult(function.get(),
|
| @@ -451,8 +450,7 @@
|
| int window_id = ExtensionTabUtil::GetWindowId(popup_browser);
|
| chrome::CloseWindow(popup_browser);
|
|
|
| - scoped_refptr<TabsCreateFunction> create_tab_function(
|
| - new TabsCreateFunction());
|
| + scoped_refptr<CreateTabFunction> create_tab_function(new CreateTabFunction());
|
| create_tab_function->set_extension(utils::CreateEmptyExtension().get());
|
| // Without a callback the function will not generate a result.
|
| create_tab_function->set_has_callback(true);
|
| @@ -474,7 +472,7 @@
|
|
|
| static const char kArgsMinimizedWithFocus[] =
|
| "[%u, {\"state\": \"minimized\", \"focused\": true}]";
|
| - scoped_refptr<WindowsUpdateFunction> function = new WindowsUpdateFunction();
|
| + scoped_refptr<UpdateWindowFunction> function = new UpdateWindowFunction();
|
| scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension());
|
| function->set_extension(extension.get());
|
| EXPECT_TRUE(MatchPattern(
|
| @@ -486,7 +484,7 @@
|
|
|
| static const char kArgsMaximizedWithoutFocus[] =
|
| "[%u, {\"state\": \"maximized\", \"focused\": false}]";
|
| - function = new WindowsUpdateFunction();
|
| + function = new UpdateWindowFunction();
|
| function->set_extension(extension.get());
|
| EXPECT_TRUE(MatchPattern(
|
| utils::RunFunctionAndReturnError(
|
| @@ -497,7 +495,7 @@
|
|
|
| static const char kArgsMinimizedWithBounds[] =
|
| "[%u, {\"state\": \"minimized\", \"width\": 500}]";
|
| - function = new WindowsUpdateFunction();
|
| + function = new UpdateWindowFunction();
|
| function->set_extension(extension.get());
|
| EXPECT_TRUE(MatchPattern(
|
| utils::RunFunctionAndReturnError(
|
| @@ -508,7 +506,7 @@
|
|
|
| static const char kArgsMaximizedWithBounds[] =
|
| "[%u, {\"state\": \"maximized\", \"width\": 500}]";
|
| - function = new WindowsUpdateFunction();
|
| + function = new UpdateWindowFunction();
|
| function->set_extension(extension.get());
|
| EXPECT_TRUE(MatchPattern(
|
| utils::RunFunctionAndReturnError(
|
| @@ -531,8 +529,8 @@
|
| TabStripModel* tab_strip;
|
| ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index);
|
|
|
| - scoped_refptr<TabsDuplicateFunction> duplicate_tab_function(
|
| - new TabsDuplicateFunction());
|
| + scoped_refptr<DuplicateTabFunction> duplicate_tab_function(
|
| + new DuplicateTabFunction());
|
| scoped_ptr<base::DictionaryValue> test_extension_value(
|
| utils::ParseDictionary(
|
| "{\"name\": \"Test\", \"version\": \"1.0\", \"permissions\": [\"tabs\"]}"
|
| @@ -575,8 +573,8 @@
|
| TabStripModel* tab_strip;
|
| ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index);
|
|
|
| - scoped_refptr<TabsDuplicateFunction> duplicate_tab_function(
|
| - new TabsDuplicateFunction());
|
| + scoped_refptr<DuplicateTabFunction> duplicate_tab_function(
|
| + new DuplicateTabFunction());
|
| scoped_refptr<extensions::Extension> empty_extension(
|
| utils::CreateEmptyExtension());
|
| duplicate_tab_function->set_extension(empty_extension.get());
|
|
|