diff options
Diffstat (limited to 'chrome')
75 files changed, 648 insertions, 623 deletions
diff --git a/chrome/common/automation_messages.cc b/chrome/common/automation_messages.cc index 1e21812..2d266c3 100644 --- a/chrome/common/automation_messages.cc +++ b/chrome/common/automation_messages.cc @@ -194,7 +194,7 @@ struct ParamTraits<net::UploadElement> { void ParamTraits<scoped_refptr<net::UploadData> >::Write(Message* m, const param_type& p) { WriteParam(m, p.get() != NULL); - if (p) { + if (p.get()) { WriteParam(m, p->elements()); WriteParam(m, p->identifier()); WriteParam(m, p->is_chunked()); diff --git a/chrome/common/cancelable_task_tracker_unittest.cc b/chrome/common/cancelable_task_tracker_unittest.cc index 4e93787..11cff80 100644 --- a/chrome/common/cancelable_task_tracker_unittest.cc +++ b/chrome/common/cancelable_task_tracker_unittest.cc @@ -230,18 +230,14 @@ TEST_F(CancelableTaskTrackerTest, CancelAll) { scoped_refptr<base::TestSimpleTaskRunner> test_task_runner( new base::TestSimpleTaskRunner()); - ignore_result( - task_tracker_.PostTask( - test_task_runner, - FROM_HERE, - MakeExpectedNotRunClosure(FROM_HERE))); + ignore_result(task_tracker_.PostTask( + test_task_runner.get(), FROM_HERE, MakeExpectedNotRunClosure(FROM_HERE))); ignore_result( - task_tracker_.PostTaskAndReply( - test_task_runner, - FROM_HERE, - MakeExpectedNotRunClosure(FROM_HERE), - MakeExpectedNotRunClosure(FROM_HERE))); + task_tracker_.PostTaskAndReply(test_task_runner.get(), + FROM_HERE, + MakeExpectedNotRunClosure(FROM_HERE), + MakeExpectedNotRunClosure(FROM_HERE))); CancelableTaskTracker::IsCanceledCallback is_canceled; ignore_result(task_tracker_.NewTrackedTaskId(&is_canceled)); @@ -269,18 +265,15 @@ TEST_F(CancelableTaskTrackerTest, DestructionCancelsAll) { // Create another task tracker with a smaller scope. CancelableTaskTracker task_tracker; - ignore_result( - task_tracker.PostTask( - test_task_runner, - FROM_HERE, - MakeExpectedNotRunClosure(FROM_HERE))); + ignore_result(task_tracker.PostTask(test_task_runner.get(), + FROM_HERE, + MakeExpectedNotRunClosure(FROM_HERE))); ignore_result( - task_tracker.PostTaskAndReply( - test_task_runner, - FROM_HERE, - MakeExpectedNotRunClosure(FROM_HERE), - MakeExpectedNotRunClosure(FROM_HERE))); + task_tracker.PostTaskAndReply(test_task_runner.get(), + FROM_HERE, + MakeExpectedNotRunClosure(FROM_HERE), + MakeExpectedNotRunClosure(FROM_HERE))); ignore_result(task_tracker_.NewTrackedTaskId(&is_canceled)); } @@ -301,11 +294,8 @@ TEST_F(CancelableTaskTrackerTest, HasTrackedTasksPost) { EXPECT_FALSE(task_tracker_.HasTrackedTasks()); - ignore_result( - task_tracker_.PostTask( - test_task_runner, - FROM_HERE, - MakeExpectedNotRunClosure(FROM_HERE))); + ignore_result(task_tracker_.PostTask( + test_task_runner.get(), FROM_HERE, MakeExpectedNotRunClosure(FROM_HERE))); task_tracker_.TryCancelAll(); @@ -327,11 +317,10 @@ TEST_F(CancelableTaskTrackerTest, HasTrackedTasksPostWithReply) { EXPECT_FALSE(task_tracker_.HasTrackedTasks()); ignore_result( - task_tracker_.PostTaskAndReply( - test_task_runner, - FROM_HERE, - MakeExpectedNotRunClosure(FROM_HERE), - MakeExpectedNotRunClosure(FROM_HERE))); + task_tracker_.PostTaskAndReply(test_task_runner.get(), + FROM_HERE, + MakeExpectedNotRunClosure(FROM_HERE), + MakeExpectedNotRunClosure(FROM_HERE))); task_tracker_.TryCancelAll(); diff --git a/chrome/common/extensions/api/commands/commands_manifest_unittest.cc b/chrome/common/extensions/api/commands/commands_manifest_unittest.cc index 02d3489..21b79c6 100644 --- a/chrome/common/extensions/api/commands/commands_manifest_unittest.cc +++ b/chrome/common/extensions/api/commands/commands_manifest_unittest.cc @@ -32,9 +32,9 @@ TEST_F(CommandsManifestTest, CommandManifestSimple) { scoped_refptr<Extension> extension = LoadAndExpectSuccess("command_simple.json"); - ASSERT_TRUE(extension); + ASSERT_TRUE(extension.get()); - const CommandMap* commands = CommandsInfo::GetNamedCommands(extension); + const CommandMap* commands = CommandsInfo::GetNamedCommands(extension.get()); ASSERT_TRUE(commands); ASSERT_EQ(1u, commands->size()); CommandMap::const_iterator iter = commands->begin(); @@ -45,14 +45,15 @@ TEST_F(CommandsManifestTest, CommandManifestSimple) { ASSERT_EQ(ctrl_shift_f, named_command->accelerator()); const Command* browser_action = - CommandsInfo::GetBrowserActionCommand(extension); + CommandsInfo::GetBrowserActionCommand(extension.get()); ASSERT_TRUE(NULL != browser_action); ASSERT_STREQ("_execute_browser_action", browser_action->command_name().c_str()); ASSERT_STREQ("", UTF16ToASCII(browser_action->description()).c_str()); ASSERT_EQ(alt_shift_f, browser_action->accelerator()); - const Command* page_action = CommandsInfo::GetPageActionCommand(extension); + const Command* page_action = + CommandsInfo::GetPageActionCommand(extension.get()); ASSERT_TRUE(NULL != page_action); ASSERT_STREQ("_execute_page_action", page_action->command_name().c_str()); @@ -86,7 +87,7 @@ TEST_F(CommandsManifestTest, BrowserActionSynthesizesCommand) { // An extension with a browser action but no extension command specified // should get a command assigned to it. const extensions::Command* command = - CommandsInfo::GetBrowserActionCommand(extension); + CommandsInfo::GetBrowserActionCommand(extension.get()); ASSERT_TRUE(command != NULL); ASSERT_EQ(ui::VKEY_UNKNOWN, command->accelerator().key_code()); } diff --git a/chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc b/chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc index 789c7ba..b23228a 100644 --- a/chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc +++ b/chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc @@ -33,7 +33,7 @@ TEST_F(BrowserActionManifestTest, ASSERT_TRUE(extension.get()); const ActionInfo* browser_action_info = - ActionInfo::GetBrowserActionInfo(extension); + ActionInfo::GetBrowserActionInfo(extension.get()); ASSERT_TRUE(browser_action_info); EXPECT_TRUE(browser_action_info->default_icon.empty()); } @@ -52,7 +52,7 @@ TEST_F(BrowserActionManifestTest, ASSERT_TRUE(extension.get()); const ActionInfo* browser_action_info = - ActionInfo::GetBrowserActionInfo(extension); + ActionInfo::GetBrowserActionInfo(extension.get()); ASSERT_TRUE(browser_action_info); ASSERT_FALSE(browser_action_info->default_icon.empty()); @@ -79,7 +79,7 @@ TEST_F(BrowserActionManifestTest, ASSERT_TRUE(extension.get()); const ActionInfo* browser_action_info = - ActionInfo::GetBrowserActionInfo(extension); + ActionInfo::GetBrowserActionInfo(extension.get()); ASSERT_TRUE(browser_action_info); ASSERT_FALSE(browser_action_info->default_icon.empty()); diff --git a/chrome/common/extensions/api/extension_action/page_action_manifest_unittest.cc b/chrome/common/extensions/api/extension_action/page_action_manifest_unittest.cc index 77374ac..15d61d8 100644 --- a/chrome/common/extensions/api/extension_action/page_action_manifest_unittest.cc +++ b/chrome/common/extensions/api/extension_action/page_action_manifest_unittest.cc @@ -27,7 +27,8 @@ scoped_ptr<ActionInfo> PageActionManifestTest::LoadAction( const std::string& manifest_filename) { scoped_refptr<Extension> extension = LoadAndExpectSuccess( manifest_filename.c_str()); - const ActionInfo* page_action_info = ActionInfo::GetPageActionInfo(extension); + const ActionInfo* page_action_info = + ActionInfo::GetPageActionInfo(extension.get()); EXPECT_TRUE(page_action_info); if (page_action_info) { return make_scoped_ptr(new ActionInfo(*page_action_info)); @@ -40,8 +41,9 @@ scoped_ptr<ActionInfo> PageActionManifestTest::LoadAction( TEST_F(PageActionManifestTest, ManifestVersion2) { scoped_refptr<Extension> extension( LoadAndExpectSuccess("page_action_manifest_version_2.json")); - ASSERT_TRUE(extension); - const ActionInfo* page_action_info = ActionInfo::GetPageActionInfo(extension); + ASSERT_TRUE(extension.get()); + const ActionInfo* page_action_info = + ActionInfo::GetPageActionInfo(extension.get()); ASSERT_TRUE(page_action_info); EXPECT_EQ("", page_action_info->id); @@ -121,7 +123,8 @@ TEST_F(PageActionManifestTest, LoadPageActionHelper) { // Only use "popup", expect success. scoped_refptr<Extension> extension = LoadAndExpectSuccess("page_action_popup.json"); - const ActionInfo* extension_action = ActionInfo::GetPageActionInfo(extension); + const ActionInfo* extension_action = + ActionInfo::GetPageActionInfo(extension.get()); ASSERT_TRUE(extension_action); ASSERT_STREQ( extension->url().Resolve(kPopupHtmlFile).spec().c_str(), @@ -136,7 +139,7 @@ TEST_F(PageActionManifestTest, LoadPageActionHelper) { // Use only "default_popup", expect success. extension = LoadAndExpectSuccess("page_action_popup.json"); - extension_action = ActionInfo::GetPageActionInfo(extension); + extension_action = ActionInfo::GetPageActionInfo(extension.get()); ASSERT_TRUE(extension_action); ASSERT_STREQ( extension->url().Resolve(kPopupHtmlFile).spec().c_str(), diff --git a/chrome/common/extensions/api/extension_action/script_badge_manifest_unittest.cc b/chrome/common/extensions/api/extension_action/script_badge_manifest_unittest.cc index c77b597..e4258cc 100644 --- a/chrome/common/extensions/api/extension_action/script_badge_manifest_unittest.cc +++ b/chrome/common/extensions/api/extension_action/script_badge_manifest_unittest.cc @@ -53,7 +53,7 @@ TEST_F(ScriptBadgeManifestTest, ScriptBadgeBasic) { .Build()); ASSERT_TRUE(extension.get()); const ActionInfo* script_badge_info = - ActionInfo::GetScriptBadgeInfo(extension); + ActionInfo::GetScriptBadgeInfo(extension.get()); ASSERT_TRUE(script_badge_info); EXPECT_THAT(StripMissingFlagWarning(extension->install_warnings()), testing::ElementsAre(/*empty*/)); @@ -93,7 +93,7 @@ TEST_F(ScriptBadgeManifestTest, ScriptBadgeExplicitTitleAndIconsIgnored) { .Build()); ASSERT_TRUE(extension.get()); const ActionInfo* script_badge_info = - ActionInfo::GetScriptBadgeInfo(extension); + ActionInfo::GetScriptBadgeInfo(extension.get()); ASSERT_TRUE(script_badge_info); EXPECT_THAT(StripMissingFlagWarning(extension->install_warnings()), @@ -129,7 +129,7 @@ TEST_F(ScriptBadgeManifestTest, ScriptBadgeIconFallsBackToPuzzlePiece) { .Build()); ASSERT_TRUE(extension.get()); const ActionInfo* script_badge_info = - ActionInfo::GetScriptBadgeInfo(extension); + ActionInfo::GetScriptBadgeInfo(extension.get()); ASSERT_TRUE(script_badge_info); EXPECT_THAT(extension->install_warnings(), testing::ElementsAre(/*empty*/)); diff --git a/chrome/common/extensions/api/i18n/default_locale_manifest_unittest.cc b/chrome/common/extensions/api/i18n/default_locale_manifest_unittest.cc index 9da5532..506987f 100644 --- a/chrome/common/extensions/api/i18n/default_locale_manifest_unittest.cc +++ b/chrome/common/extensions/api/i18n/default_locale_manifest_unittest.cc @@ -18,7 +18,7 @@ TEST_F(DefaultLocaleManifestTest, DefaultLocale) { scoped_refptr<Extension> extension( LoadAndExpectSuccess("default_locale_valid.json")); - EXPECT_EQ("de-AT", LocaleInfo::GetDefaultLocale(extension)); + EXPECT_EQ("de-AT", LocaleInfo::GetDefaultLocale(extension.get())); } } // namespace extensions diff --git a/chrome/common/extensions/api/identity/extension_manifests_auth_unittest.cc b/chrome/common/extensions/api/identity/extension_manifests_auth_unittest.cc index 33b0481..cadc5f2 100644 --- a/chrome/common/extensions/api/identity/extension_manifests_auth_unittest.cc +++ b/chrome/common/extensions/api/identity/extension_manifests_auth_unittest.cc @@ -38,10 +38,10 @@ TEST_F(OAuth2ManifestTest, OAuth2SectionParsing) { scoped_refptr<extensions::Extension> extension = LoadAndExpectSuccess(manifest); EXPECT_TRUE(extension->install_warnings().empty()); - EXPECT_EQ("client1", OAuth2Info::GetOAuth2Info(extension).client_id); - EXPECT_EQ(2U, OAuth2Info::GetOAuth2Info(extension).scopes.size()); - EXPECT_EQ("scope1", OAuth2Info::GetOAuth2Info(extension).scopes[0]); - EXPECT_EQ("scope2", OAuth2Info::GetOAuth2Info(extension).scopes[1]); + EXPECT_EQ("client1", OAuth2Info::GetOAuth2Info(extension.get()).client_id); + EXPECT_EQ(2U, OAuth2Info::GetOAuth2Info(extension.get()).scopes.size()); + EXPECT_EQ("scope1", OAuth2Info::GetOAuth2Info(extension.get()).scopes[0]); + EXPECT_EQ("scope2", OAuth2Info::GetOAuth2Info(extension.get()).scopes[1]); } // OAuth2 section should be parsed for a packaged app. @@ -54,10 +54,10 @@ TEST_F(OAuth2ManifestTest, OAuth2SectionParsing) { scoped_refptr<extensions::Extension> extension = LoadAndExpectSuccess(manifest); EXPECT_TRUE(extension->install_warnings().empty()); - EXPECT_EQ("client1", OAuth2Info::GetOAuth2Info(extension).client_id); - EXPECT_EQ(2U, OAuth2Info::GetOAuth2Info(extension).scopes.size()); - EXPECT_EQ("scope1", OAuth2Info::GetOAuth2Info(extension).scopes[0]); - EXPECT_EQ("scope2", OAuth2Info::GetOAuth2Info(extension).scopes[1]); + EXPECT_EQ("client1", OAuth2Info::GetOAuth2Info(extension.get()).client_id); + EXPECT_EQ(2U, OAuth2Info::GetOAuth2Info(extension.get()).scopes.size()); + EXPECT_EQ("scope1", OAuth2Info::GetOAuth2Info(extension.get()).scopes[0]); + EXPECT_EQ("scope2", OAuth2Info::GetOAuth2Info(extension.get()).scopes[1]); } // OAuth2 section should NOT be parsed for a hosted app. @@ -75,8 +75,8 @@ TEST_F(OAuth2ManifestTest, OAuth2SectionParsing) { EXPECT_EQ("'oauth2' is only allowed for extensions, legacy packaged apps " "and packaged apps, and this is a hosted app.", warning.message); - EXPECT_EQ("", OAuth2Info::GetOAuth2Info(extension).client_id); - EXPECT_TRUE(OAuth2Info::GetOAuth2Info(extension).scopes.empty()); + EXPECT_EQ("", OAuth2Info::GetOAuth2Info(extension.get()).client_id); + EXPECT_TRUE(OAuth2Info::GetOAuth2Info(extension.get()).scopes.empty()); } } diff --git a/chrome/common/extensions/extension_file_util_unittest.cc b/chrome/common/extensions/extension_file_util_unittest.cc index 8f89c45..343f4cf 100644 --- a/chrome/common/extensions/extension_file_util_unittest.cc +++ b/chrome/common/extensions/extension_file_util_unittest.cc @@ -114,7 +114,7 @@ TEST_F(ExtensionFileUtilTest, LoadExtensionWithValidLocales) { std::string error; scoped_refptr<Extension> extension(extension_file_util::LoadExtension( install_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); - ASSERT_TRUE(extension != NULL); + ASSERT_TRUE(extension.get() != NULL); EXPECT_EQ("The first extension that I made.", extension->description()); } @@ -130,7 +130,7 @@ TEST_F(ExtensionFileUtilTest, LoadExtensionWithoutLocalesFolder) { std::string error; scoped_refptr<Extension> extension(extension_file_util::LoadExtension( install_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); - ASSERT_FALSE(extension == NULL); + ASSERT_FALSE(extension.get() == NULL); EXPECT_TRUE(error.empty()); } @@ -194,7 +194,7 @@ TEST_F(ExtensionFileUtilTest, std::string error; scoped_refptr<Extension> extension(extension_file_util::LoadExtension( install_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); - ASSERT_TRUE(extension == NULL); + ASSERT_TRUE(extension.get() == NULL); ASSERT_FALSE(error.empty()); ASSERT_STREQ("Manifest file is missing or unreadable.", error.c_str()); } @@ -211,7 +211,7 @@ TEST_F(ExtensionFileUtilTest, LoadExtensionGivesHelpfullErrorOnBadManifest) { std::string error; scoped_refptr<Extension> extension(extension_file_util::LoadExtension( install_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); - ASSERT_TRUE(extension == NULL); + ASSERT_TRUE(extension.get() == NULL); ASSERT_FALSE(error.empty()); ASSERT_STREQ("Manifest is not valid JSON. " "Line: 2, column: 16, Syntax error.", error.c_str()); @@ -227,9 +227,10 @@ TEST_F(ExtensionFileUtilTest, FailLoadingNonUTF8Scripts) { std::string error; scoped_refptr<Extension> extension(extension_file_util::LoadExtension( install_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); - ASSERT_TRUE(extension == NULL); + ASSERT_TRUE(extension.get() == NULL); ASSERT_STREQ("Could not load file 'bad_encoding.js' for content script. " - "It isn't UTF-8 encoded.", error.c_str()); + "It isn't UTF-8 encoded.", + error.c_str()); } TEST_F(ExtensionFileUtilTest, ExtensionURLToRelativeFilePath) { @@ -392,9 +393,8 @@ TEST_F(ExtensionFileUtilTest, ValidateThemeUTF8) { ASSERT_TRUE(extension.get()) << error; std::vector<extensions::InstallWarning> warnings; - EXPECT_TRUE(extension_file_util::ValidateExtension(extension, - &error, &warnings)) << - error; + EXPECT_TRUE(extension_file_util::ValidateExtension( + extension.get(), &error, &warnings)) << error; EXPECT_EQ(0U, warnings.size()); } @@ -417,8 +417,8 @@ TEST_F(ExtensionFileUtilTest, BackgroundScriptsMustExist) { value.get(), temp.path(), Manifest::UNPACKED, 0, &error); ASSERT_TRUE(extension.get()) << error; - EXPECT_FALSE(extension_file_util::ValidateExtension(extension, - &error, &warnings)); + EXPECT_FALSE(extension_file_util::ValidateExtension( + extension.get(), &error, &warnings)); EXPECT_EQ(l10n_util::GetStringFUTF8( IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, ASCIIToUTF16("foo.js")), error); @@ -432,8 +432,8 @@ TEST_F(ExtensionFileUtilTest, BackgroundScriptsMustExist) { ASSERT_TRUE(extension.get()) << error; warnings.clear(); - EXPECT_FALSE(extension_file_util::ValidateExtension(extension, - &error, &warnings)); + EXPECT_FALSE(extension_file_util::ValidateExtension( + extension.get(), &error, &warnings)); EXPECT_EQ(l10n_util::GetStringFUTF8( IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, ASCIIToUTF16("http://google.com/foo.js")), @@ -543,9 +543,8 @@ TEST_F(ExtensionFileUtilTest, CheckZeroLengthImageFile) { std::string error; scoped_refptr<Extension> extension(extension_file_util::LoadExtension( ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); - EXPECT_TRUE(extension == NULL); - EXPECT_STREQ("Could not load extension icon 'icon.png'.", - error.c_str()); + EXPECT_TRUE(extension.get() == NULL); + EXPECT_STREQ("Could not load extension icon 'icon.png'.", error.c_str()); // Try to install an extension with a zero-length browser action icon file. ext_dir = install_dir.AppendASCII("extensions") @@ -555,9 +554,9 @@ TEST_F(ExtensionFileUtilTest, CheckZeroLengthImageFile) { scoped_refptr<Extension> extension2(extension_file_util::LoadExtension( ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); - EXPECT_TRUE(extension2 == NULL); + EXPECT_TRUE(extension2.get() == NULL); EXPECT_STREQ("Could not load icon 'icon.png' for browser action.", - error.c_str()); + error.c_str()); // Try to install an extension with a zero-length page action icon file. ext_dir = install_dir.AppendASCII("extensions") @@ -567,9 +566,9 @@ TEST_F(ExtensionFileUtilTest, CheckZeroLengthImageFile) { scoped_refptr<Extension> extension3(extension_file_util::LoadExtension( ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); - EXPECT_TRUE(extension3 == NULL); + EXPECT_TRUE(extension3.get() == NULL); EXPECT_STREQ("Could not load icon 'icon.png' for page action.", - error.c_str()); + error.c_str()); } // TODO(aa): More tests as motivation allows. Maybe steal some from diff --git a/chrome/common/extensions/extension_messages.cc b/chrome/common/extensions/extension_messages.cc index 44b4758..e32b48d 100644 --- a/chrome/common/extensions/extension_messages.cc +++ b/chrome/common/extensions/extension_messages.cc @@ -42,9 +42,9 @@ scoped_refptr<Extension> ExtensionMsg_Loaded_Params::ConvertToExtension( std::string* error) const { scoped_refptr<Extension> extension = Extension::Create(path, location, *manifest, creation_flags, error); - if (extension) { + if (extension.get()) { extensions::PermissionsData::SetActivePermissions( - extension, + extension.get(), new PermissionSet(apis, explicit_hosts, scriptable_hosts)); } return extension; diff --git a/chrome/common/extensions/extension_set_unittest.cc b/chrome/common/extensions/extension_set_unittest.cc index edabcb9..36dc7ea 100644 --- a/chrome/common/extensions/extension_set_unittest.cc +++ b/chrome/common/extensions/extension_set_unittest.cc @@ -62,7 +62,7 @@ TEST(ExtensionSetTest, ExtensionSet) { scoped_refptr<Extension> ext4( CreateTestExtension("c", std::string(), std::string())); - ASSERT_TRUE(ext1 && ext2 && ext3 && ext4); + ASSERT_TRUE(ext1.get() && ext2.get() && ext3.get() && ext4.get()); ExtensionSet extensions; @@ -123,7 +123,7 @@ TEST(ExtensionSetTest, ExtensionSet) { CreateTestExtension("d", std::string(), std::string())); scoped_refptr<Extension> ext6( CreateTestExtension("e", std::string(), std::string())); - ASSERT_TRUE(ext5 && ext6); + ASSERT_TRUE(ext5.get() && ext6.get()); scoped_ptr<ExtensionSet> to_add(new ExtensionSet()); // |ext3| is already in |extensions|, should not affect size. diff --git a/chrome/common/extensions/extension_sync_type_unittest.cc b/chrome/common/extensions/extension_sync_type_unittest.cc index 88cef0f..1f7a20f 100644 --- a/chrome/common/extensions/extension_sync_type_unittest.cc +++ b/chrome/common/extensions/extension_sync_type_unittest.cc @@ -58,7 +58,7 @@ class ExtensionSyncTypeTest : public testing::Test { std::string error; scoped_refptr<Extension> extension = Extension::Create( extension_path, location, source, creation_flags, &error); - EXPECT_TRUE(extension); + EXPECT_TRUE(extension.get()); EXPECT_EQ("", error); return extension; } @@ -225,7 +225,7 @@ TEST_F(ExtensionSyncTypeTest, ExtensionWithPlugin) { MakeSyncTestExtension(EXTENSION, GURL(), GURL(), Manifest::INTERNAL, 1, base::FilePath(), Extension::NO_FLAGS)); - if (extension) + if (extension.get()) EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); } @@ -234,7 +234,7 @@ TEST_F(ExtensionSyncTypeTest, ExtensionWithTwoPlugins) { MakeSyncTestExtension(EXTENSION, GURL(), GURL(), Manifest::INTERNAL, 2, base::FilePath(), Extension::NO_FLAGS)); - if (extension) + if (extension.get()) EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); } #endif // !defined(OS_CHROMEOS) diff --git a/chrome/common/extensions/extension_test_util.cc b/chrome/common/extensions/extension_test_util.cc index b9b0425..20182ca 100644 --- a/chrome/common/extensions/extension_test_util.cc +++ b/chrome/common/extensions/extension_test_util.cc @@ -68,7 +68,7 @@ scoped_refptr<Extension> LoadManifest(const std::string& dir, scoped_refptr<Extension> extension = LoadManifestUnchecked(dir, test_file, location, extra_flags, &error); - EXPECT_TRUE(extension) << test_file << ":" << error; + EXPECT_TRUE(extension.get()) << test_file << ":" << error; return extension; } diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc index 73d4a8c..275a41e 100644 --- a/chrome/common/extensions/extension_unittest.cc +++ b/chrome/common/extensions/extension_unittest.cc @@ -170,55 +170,57 @@ TEST(ExtensionTest, WantsFileAccess) { extension = LoadManifest("permissions", "permissions_all_urls.json"); EXPECT_TRUE(extension->wants_file_access()); EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( - extension, file_url, file_url, -1, NULL, -1, NULL)); + extension.get(), file_url, file_url, -1, NULL, -1, NULL)); extension = LoadManifest( "permissions", "permissions_all_urls.json", Extension::ALLOW_FILE_ACCESS); EXPECT_TRUE(extension->wants_file_access()); EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage( - extension, file_url, file_url, -1, NULL, -1, NULL)); + extension.get(), file_url, file_url, -1, NULL, -1, NULL)); // file:///* permission extension = LoadManifest("permissions", "permissions_file_scheme.json"); EXPECT_TRUE(extension->wants_file_access()); EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( - extension, file_url, file_url, -1, NULL, -1, NULL)); - extension = LoadManifest("permissions", "permissions_file_scheme.json", - Extension::ALLOW_FILE_ACCESS); + extension.get(), file_url, file_url, -1, NULL, -1, NULL)); + extension = LoadManifest("permissions", + "permissions_file_scheme.json", + Extension::ALLOW_FILE_ACCESS); EXPECT_TRUE(extension->wants_file_access()); EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage( - extension, file_url, file_url, -1, NULL, -1, NULL)); + extension.get(), file_url, file_url, -1, NULL, -1, NULL)); // http://* permission extension = LoadManifest("permissions", "permissions_http_scheme.json"); EXPECT_FALSE(extension->wants_file_access()); EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( - extension, file_url, file_url, -1, NULL, -1, NULL)); - extension = LoadManifest("permissions", "permissions_http_scheme.json", - Extension::ALLOW_FILE_ACCESS); + extension.get(), file_url, file_url, -1, NULL, -1, NULL)); + extension = LoadManifest("permissions", + "permissions_http_scheme.json", + Extension::ALLOW_FILE_ACCESS); EXPECT_FALSE(extension->wants_file_access()); EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( - extension, file_url, file_url, -1, NULL, -1, NULL)); + extension.get(), file_url, file_url, -1, NULL, -1, NULL)); // <all_urls> content script match extension = LoadManifest("permissions", "content_script_all_urls.json"); EXPECT_TRUE(extension->wants_file_access()); EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( - extension, + extension.get(), file_url, file_url, -1, - &ContentScriptsInfo::GetContentScripts(extension)[0], + &ContentScriptsInfo::GetContentScripts(extension.get())[0], -1, NULL)); extension = LoadManifest("permissions", "content_script_all_urls.json", Extension::ALLOW_FILE_ACCESS); EXPECT_TRUE(extension->wants_file_access()); EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage( - extension, + extension.get(), file_url, file_url, -1, - &ContentScriptsInfo::GetContentScripts(extension)[0], + &ContentScriptsInfo::GetContentScripts(extension.get())[0], -1, NULL)); @@ -226,22 +228,22 @@ TEST(ExtensionTest, WantsFileAccess) { extension = LoadManifest("permissions", "content_script_file_scheme.json"); EXPECT_TRUE(extension->wants_file_access()); EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( - extension, + extension.get(), file_url, file_url, -1, - &ContentScriptsInfo::GetContentScripts(extension)[0], + &ContentScriptsInfo::GetContentScripts(extension.get())[0], -1, NULL)); extension = LoadManifest("permissions", "content_script_file_scheme.json", Extension::ALLOW_FILE_ACCESS); EXPECT_TRUE(extension->wants_file_access()); EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage( - extension, + extension.get(), file_url, file_url, -1, - &ContentScriptsInfo::GetContentScripts(extension)[0], + &ContentScriptsInfo::GetContentScripts(extension.get())[0], -1, NULL)); @@ -249,22 +251,22 @@ TEST(ExtensionTest, WantsFileAccess) { extension = LoadManifest("permissions", "content_script_http_scheme.json"); EXPECT_FALSE(extension->wants_file_access()); EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( - extension, + extension.get(), file_url, file_url, -1, - &ContentScriptsInfo::GetContentScripts(extension)[0], + &ContentScriptsInfo::GetContentScripts(extension.get())[0], -1, NULL)); extension = LoadManifest("permissions", "content_script_http_scheme.json", Extension::ALLOW_FILE_ACCESS); EXPECT_FALSE(extension->wants_file_access()); EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( - extension, + extension.get(), file_url, file_url, -1, - &ContentScriptsInfo::GetContentScripts(extension)[0], + &ContentScriptsInfo::GetContentScripts(extension.get())[0], -1, NULL)); } diff --git a/chrome/common/extensions/manifest_handler_unittest.cc b/chrome/common/extensions/manifest_handler_unittest.cc index ae38d5e..bb3a54b 100644 --- a/chrome/common/extensions/manifest_handler_unittest.cc +++ b/chrome/common/extensions/manifest_handler_unittest.cc @@ -229,7 +229,7 @@ TEST_F(ManifestHandlerTest, FailingHandlers) { *manifest_a, Extension::NO_FLAGS, &error); - EXPECT_TRUE(extension); + EXPECT_TRUE(extension.get()); // Register a handler for "a" that fails. ParsingWatcher watcher; @@ -242,7 +242,7 @@ TEST_F(ManifestHandlerTest, FailingHandlers) { *manifest_a, Extension::NO_FLAGS, &error); - EXPECT_FALSE(extension); + EXPECT_FALSE(extension.get()); EXPECT_EQ("A", error); } @@ -256,24 +256,24 @@ TEST_F(ManifestHandlerTest, Validate) { .Set("a", 1) .Set("b", 2)) .Build(); - EXPECT_TRUE(extension); + EXPECT_TRUE(extension.get()); std::string error; std::vector<InstallWarning> warnings; // Always validates and fails. (new TestManifestValidator(false, true, SingleKey("c")))->Register(); - EXPECT_FALSE(ManifestHandler::ValidateExtension( - extension, &error, &warnings)); + EXPECT_FALSE( + ManifestHandler::ValidateExtension(extension.get(), &error, &warnings)); // This overrides the registered handler for "c". (new TestManifestValidator(false, false, SingleKey("c")))->Register(); - EXPECT_TRUE(ManifestHandler::ValidateExtension( - extension, &error, &warnings)); + EXPECT_TRUE( + ManifestHandler::ValidateExtension(extension.get(), &error, &warnings)); // Validates "a" and fails. (new TestManifestValidator(false, true, SingleKey("a")))->Register(); - EXPECT_FALSE(ManifestHandler::ValidateExtension( - extension, &error, &warnings)); + EXPECT_FALSE( + ManifestHandler::ValidateExtension(extension.get(), &error, &warnings)); } } // namespace extensions diff --git a/chrome/common/extensions/manifest_handlers/content_scripts_manifest_unittest.cc b/chrome/common/extensions/manifest_handlers/content_scripts_manifest_unittest.cc index f2c3a91..5b611f7 100644 --- a/chrome/common/extensions/manifest_handlers/content_scripts_manifest_unittest.cc +++ b/chrome/common/extensions/manifest_handlers/content_scripts_manifest_unittest.cc @@ -49,8 +49,8 @@ TEST_F(ContentScriptsManifestTest, OnChromeUrlsWithFlag) { scoped_refptr<Extension> extension = LoadAndExpectSuccess("content_script_chrome_url_invalid.json"); const GURL newtab_url("chrome://newtab/"); - EXPECT_TRUE(ContentScriptsInfo::ExtensionHasScriptAtURL(extension, - newtab_url)); + EXPECT_TRUE( + ContentScriptsInfo::ExtensionHasScriptAtURL(extension.get(), newtab_url)); } TEST_F(ContentScriptsManifestTest, ScriptableHosts) { @@ -58,7 +58,7 @@ TEST_F(ContentScriptsManifestTest, ScriptableHosts) { scoped_refptr<Extension> extension = LoadAndExpectSuccess("content_script_yahoo.json"); URLPatternSet scriptable_hosts = - ContentScriptsInfo::GetScriptableHosts(extension); + ContentScriptsInfo::GetScriptableHosts(extension.get()); URLPatternSet expected; expected.AddPattern( diff --git a/chrome/common/extensions/manifest_handlers/externally_connectable_unittest.cc b/chrome/common/extensions/manifest_handlers/externally_connectable_unittest.cc index 1af834e..e24d4f6 100644 --- a/chrome/common/extensions/manifest_handlers/externally_connectable_unittest.cc +++ b/chrome/common/extensions/manifest_handlers/externally_connectable_unittest.cc @@ -29,9 +29,10 @@ class ExternallyConnectableTest : public ExtensionManifestTest { TEST_F(ExternallyConnectableTest, IDsAndMatches) { scoped_refptr<Extension> extension = LoadAndExpectSuccess("externally_connectable_ids_and_matches.json"); - ASSERT_TRUE(extension); + ASSERT_TRUE(extension.get()); - ExternallyConnectableInfo* info = ExternallyConnectableInfo::Get(extension); + ExternallyConnectableInfo* info = + ExternallyConnectableInfo::Get(extension.get()); ASSERT_TRUE(info); EXPECT_THAT(info->ids, ElementsAre("abcdefghijklmnopabcdefghijklmnop", @@ -86,9 +87,10 @@ TEST_F(ExternallyConnectableTest, IDsAndMatches) { TEST_F(ExternallyConnectableTest, IDs) { scoped_refptr<Extension> extension = LoadAndExpectSuccess("externally_connectable_ids.json"); - ASSERT_TRUE(extension); + ASSERT_TRUE(extension.get()); - ExternallyConnectableInfo* info = ExternallyConnectableInfo::Get(extension); + ExternallyConnectableInfo* info = + ExternallyConnectableInfo::Get(extension.get()); ASSERT_TRUE(info); EXPECT_THAT(info->ids, ElementsAre("abcdefghijklmnopabcdefghijklmnop", @@ -102,9 +104,10 @@ TEST_F(ExternallyConnectableTest, IDs) { TEST_F(ExternallyConnectableTest, Matches) { scoped_refptr<Extension> extension = LoadAndExpectSuccess("externally_connectable_matches.json"); - ASSERT_TRUE(extension); + ASSERT_TRUE(extension.get()); - ExternallyConnectableInfo* info = ExternallyConnectableInfo::Get(extension); + ExternallyConnectableInfo* info = + ExternallyConnectableInfo::Get(extension.get()); ASSERT_TRUE(info); EXPECT_THAT(info->ids, ElementsAre()); @@ -139,9 +142,10 @@ TEST_F(ExternallyConnectableTest, Matches) { TEST_F(ExternallyConnectableTest, AllIDs) { scoped_refptr<Extension> extension = LoadAndExpectSuccess("externally_connectable_all_ids.json"); - ASSERT_TRUE(extension); + ASSERT_TRUE(extension.get()); - ExternallyConnectableInfo* info = ExternallyConnectableInfo::Get(extension); + ExternallyConnectableInfo* info = + ExternallyConnectableInfo::Get(extension.get()); ASSERT_TRUE(info); EXPECT_THAT(info->ids, ElementsAre("abcdefghijklmnopabcdefghijklmnop", diff --git a/chrome/common/extensions/manifest_handlers/shared_module_manifest_unittest.cc b/chrome/common/extensions/manifest_handlers/shared_module_manifest_unittest.cc index d5ddea8..0fbdcfc 100644 --- a/chrome/common/extensions/manifest_handlers/shared_module_manifest_unittest.cc +++ b/chrome/common/extensions/manifest_handlers/shared_module_manifest_unittest.cc @@ -31,11 +31,13 @@ TEST_F(SharedModuleManifestTest, ExportsAll) { scoped_refptr<Extension> extension = LoadAndExpectSuccess(manifest); - EXPECT_TRUE(SharedModuleInfo::IsSharedModule(extension)) << manifest.name(); - EXPECT_FALSE(SharedModuleInfo::ImportsModules(extension)) << manifest.name(); - EXPECT_TRUE(SharedModuleInfo::IsExportAllowed(extension, "foo")) + EXPECT_TRUE(SharedModuleInfo::IsSharedModule(extension.get())) << manifest.name(); - EXPECT_TRUE(SharedModuleInfo::IsExportAllowed(extension, "foo/bar")) + EXPECT_FALSE(SharedModuleInfo::ImportsModules(extension.get())) + << manifest.name(); + EXPECT_TRUE(SharedModuleInfo::IsExportAllowed(extension.get(), "foo")) + << manifest.name(); + EXPECT_TRUE(SharedModuleInfo::IsExportAllowed(extension.get(), "foo/bar")) << manifest.name(); } @@ -44,11 +46,13 @@ TEST_F(SharedModuleManifestTest, ExportFoo) { scoped_refptr<Extension> extension = LoadAndExpectSuccess(manifest); - EXPECT_TRUE(SharedModuleInfo::IsSharedModule(extension)) << manifest.name(); - EXPECT_FALSE(SharedModuleInfo::ImportsModules(extension)) << manifest.name(); - EXPECT_TRUE(SharedModuleInfo::IsExportAllowed(extension, "foo")) + EXPECT_TRUE(SharedModuleInfo::IsSharedModule(extension.get())) + << manifest.name(); + EXPECT_FALSE(SharedModuleInfo::ImportsModules(extension.get())) << manifest.name(); - EXPECT_FALSE(SharedModuleInfo::IsExportAllowed(extension, "foo/bar")) + EXPECT_TRUE(SharedModuleInfo::IsExportAllowed(extension.get(), "foo")) + << manifest.name(); + EXPECT_FALSE(SharedModuleInfo::IsExportAllowed(extension.get(), "foo/bar")) << manifest.name(); } @@ -82,18 +86,23 @@ TEST_F(SharedModuleManifestTest, Import) { scoped_refptr<Extension> extension = LoadAndExpectSuccess(manifest); - EXPECT_FALSE(SharedModuleInfo::IsSharedModule(extension)) << manifest.name(); - EXPECT_TRUE(SharedModuleInfo::ImportsModules(extension)) << manifest.name(); + EXPECT_FALSE(SharedModuleInfo::IsSharedModule(extension.get())) + << manifest.name(); + EXPECT_TRUE(SharedModuleInfo::ImportsModules(extension.get())) + << manifest.name(); const std::vector<SharedModuleInfo::ImportInfo>& imports = - SharedModuleInfo::GetImports(extension); + SharedModuleInfo::GetImports(extension.get()); ASSERT_EQ(2U, imports.size()); EXPECT_EQ(imports[0].extension_id, kImportId1); EXPECT_EQ(imports[0].minimum_version, ""); EXPECT_EQ(imports[1].extension_id, kImportId2); EXPECT_TRUE(base::Version(imports[1].minimum_version).IsValid()); - EXPECT_TRUE(SharedModuleInfo::ImportsExtensionById(extension, kImportId1)); - EXPECT_TRUE(SharedModuleInfo::ImportsExtensionById(extension, kImportId2)); - EXPECT_FALSE(SharedModuleInfo::ImportsExtensionById(extension, kNoImport)); + EXPECT_TRUE( + SharedModuleInfo::ImportsExtensionById(extension.get(), kImportId1)); + EXPECT_TRUE( + SharedModuleInfo::ImportsExtensionById(extension.get(), kImportId2)); + EXPECT_FALSE( + SharedModuleInfo::ImportsExtensionById(extension.get(), kNoImport)); } TEST_F(SharedModuleManifestTest, ImportParseErrors) { diff --git a/chrome/common/extensions/manifest_tests/extension_manifest_test.cc b/chrome/common/extensions/manifest_tests/extension_manifest_test.cc index 61d1c2e..e37eb64 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifest_test.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifest_test.cc @@ -122,7 +122,7 @@ scoped_refptr<Extension> ExtensionManifestTest::LoadAndExpectSuccess( std::string error; scoped_refptr<Extension> extension = LoadExtension(manifest, &error, location, flags); - EXPECT_TRUE(extension) << manifest.name(); + EXPECT_TRUE(extension.get()) << manifest.name(); EXPECT_EQ("", error) << manifest.name(); return extension; } @@ -142,7 +142,7 @@ scoped_refptr<Extension> ExtensionManifestTest::LoadAndExpectWarning( std::string error; scoped_refptr<Extension> extension = LoadExtension(manifest, &error, location, flags); - EXPECT_TRUE(extension) << manifest.name(); + EXPECT_TRUE(extension.get()) << manifest.name(); EXPECT_EQ("", error) << manifest.name(); EXPECT_EQ(1u, extension->install_warnings().size()); EXPECT_EQ(expected_warning, extension->install_warnings()[0].message); diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc index 26e9513..7b49ccab 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc @@ -37,17 +37,17 @@ TEST_F(ExtensionManifestBackgroundTest, BackgroundScripts) { scoped_refptr<Extension> extension( LoadAndExpectSuccess(Manifest(manifest.get(), ""))); - ASSERT_TRUE(extension); + ASSERT_TRUE(extension.get()); const std::vector<std::string>& background_scripts = - BackgroundInfo::GetBackgroundScripts(extension); + BackgroundInfo::GetBackgroundScripts(extension.get()); ASSERT_EQ(2u, background_scripts.size()); EXPECT_EQ("foo.js", background_scripts[0u]); EXPECT_EQ("bar/baz.js", background_scripts[1u]); - EXPECT_TRUE(BackgroundInfo::HasBackgroundPage(extension)); - EXPECT_EQ(std::string("/") + - extension_filenames::kGeneratedBackgroundPageFilename, - BackgroundInfo::GetBackgroundURL(extension).path()); + EXPECT_TRUE(BackgroundInfo::HasBackgroundPage(extension.get())); + EXPECT_EQ( + std::string("/") + extension_filenames::kGeneratedBackgroundPageFilename, + BackgroundInfo::GetBackgroundURL(extension.get()).path()); manifest->SetString("background_page", "monkey.html"); LoadAndExpectError(Manifest(manifest.get(), ""), @@ -57,17 +57,19 @@ TEST_F(ExtensionManifestBackgroundTest, BackgroundScripts) { TEST_F(ExtensionManifestBackgroundTest, BackgroundPage) { scoped_refptr<Extension> extension( LoadAndExpectSuccess("background_page.json")); - ASSERT_TRUE(extension); - EXPECT_EQ("/foo.html", BackgroundInfo::GetBackgroundURL(extension).path()); - EXPECT_TRUE(BackgroundInfo::AllowJSAccess(extension)); + ASSERT_TRUE(extension.get()); + EXPECT_EQ("/foo.html", + BackgroundInfo::GetBackgroundURL(extension.get()).path()); + EXPECT_TRUE(BackgroundInfo::AllowJSAccess(extension.get())); std::string error; scoped_ptr<base::DictionaryValue> manifest( LoadManifest("background_page_legacy.json", &error)); ASSERT_TRUE(manifest.get()); extension = LoadAndExpectSuccess(Manifest(manifest.get(), "")); - ASSERT_TRUE(extension); - EXPECT_EQ("/foo.html", BackgroundInfo::GetBackgroundURL(extension).path()); + ASSERT_TRUE(extension.get()); + EXPECT_EQ("/foo.html", + BackgroundInfo::GetBackgroundURL(extension.get()).path()); manifest->SetInteger(keys::kManifestVersion, 2); LoadAndExpectWarning( @@ -78,12 +80,12 @@ TEST_F(ExtensionManifestBackgroundTest, BackgroundPage) { TEST_F(ExtensionManifestBackgroundTest, BackgroundAllowNoJsAccess) { scoped_refptr<Extension> extension; extension = LoadAndExpectSuccess("background_allow_no_js_access.json"); - ASSERT_TRUE(extension); - EXPECT_FALSE(BackgroundInfo::AllowJSAccess(extension)); + ASSERT_TRUE(extension.get()); + EXPECT_FALSE(BackgroundInfo::AllowJSAccess(extension.get())); extension = LoadAndExpectSuccess("background_allow_no_js_access2.json"); - ASSERT_TRUE(extension); - EXPECT_FALSE(BackgroundInfo::AllowJSAccess(extension)); + ASSERT_TRUE(extension.get()); + EXPECT_FALSE(BackgroundInfo::AllowJSAccess(extension.get())); } TEST_F(ExtensionManifestBackgroundTest, BackgroundPageWebRequest) { @@ -100,8 +102,8 @@ TEST_F(ExtensionManifestBackgroundTest, BackgroundPageWebRequest) { manifest->SetInteger(keys::kManifestVersion, 2); scoped_refptr<Extension> extension( LoadAndExpectSuccess(Manifest(manifest.get(), ""))); - ASSERT_TRUE(extension); - EXPECT_TRUE(BackgroundInfo::HasLazyBackgroundPage(extension)); + ASSERT_TRUE(extension.get()); + EXPECT_TRUE(BackgroundInfo::HasLazyBackgroundPage(extension.get())); base::ListValue* permissions = new base::ListValue(); permissions->Append(new base::StringValue("webRequest")); diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_chromepermission_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_chromepermission_unittest.cc index 759f8b3..98c4111 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_chromepermission_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_chromepermission_unittest.cc @@ -31,7 +31,7 @@ TEST_F(ExtensionManifestTest, ChromeURLPermissionAllowedWithFlag) { EXPECT_EQ("", error); const GURL newtab_url("chrome://newtab/"); EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage( - extension, newtab_url, newtab_url, 0, NULL, -1, &error)) << error; + extension.get(), newtab_url, newtab_url, 0, NULL, -1, &error)) << error; } TEST_F(ExtensionManifestTest, ChromeResourcesPermissionValidOnlyForComponents) { diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_devtools_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_devtools_unittest.cc index f7a7ed6..2802867 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_devtools_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_devtools_unittest.cc @@ -19,7 +19,7 @@ TEST_F(DevToolsPageManifestTest, DevToolsExtensions) { scoped_refptr<extensions::Extension> extension; extension = LoadAndExpectSuccess("devtools_extension.json"); EXPECT_EQ(extension->url().spec() + "devtools.html", - extensions::ManifestURL::GetDevToolsPage(extension).spec()); - EXPECT_TRUE( - extensions::PermissionsData::HasEffectiveAccessToAllHosts(extension)); + extensions::ManifestURL::GetDevToolsPage(extension.get()).spec()); + EXPECT_TRUE(extensions::PermissionsData::HasEffectiveAccessToAllHosts( + extension.get())); } diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_homepage_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_homepage_unittest.cc index 0b2c184..6e1779e1 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_homepage_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_homepage_unittest.cc @@ -34,15 +34,16 @@ TEST_F(HomepageURLManifestTest, GetHomepageURL) { scoped_refptr<extensions::Extension> extension( LoadAndExpectSuccess("homepage_valid.json")); EXPECT_EQ(GURL("http://foo.com#bar"), - extensions::ManifestURL::GetHomepageURL(extension)); + extensions::ManifestURL::GetHomepageURL(extension.get())); // The Google Gallery URL ends with the id, which depends on the path, which // can be different in testing, so we just check the part before id. extension = LoadAndExpectSuccess("homepage_google_hosted.json"); EXPECT_TRUE(StartsWithASCII( - extensions::ManifestURL::GetHomepageURL(extension).spec(), - "https://chrome.google.com/webstore/detail/", false)); + extensions::ManifestURL::GetHomepageURL(extension.get()).spec(), + "https://chrome.google.com/webstore/detail/", + false)); extension = LoadAndExpectSuccess("homepage_externally_hosted.json"); - EXPECT_EQ(GURL(), extensions::ManifestURL::GetHomepageURL(extension)); + EXPECT_EQ(GURL(), extensions::ManifestURL::GetHomepageURL(extension.get())); } diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_icons_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_icons_unittest.cc index aac8860..d014a851 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_icons_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_icons_unittest.cc @@ -18,7 +18,7 @@ class IconsManifestTest : public ExtensionManifestTest { TEST_F(IconsManifestTest, NormalizeIconPaths) { scoped_refptr<extensions::Extension> extension( LoadAndExpectSuccess("normalize_icon_paths.json")); - const ExtensionIconSet& icons = IconsInfo::GetIcons(extension); + const ExtensionIconSet& icons = IconsInfo::GetIcons(extension.get()); EXPECT_EQ("16.png", icons.Get(extension_misc::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY)); @@ -29,14 +29,15 @@ TEST_F(IconsManifestTest, NormalizeIconPaths) { TEST_F(IconsManifestTest, InvalidIconSizes) { scoped_refptr<extensions::Extension> extension( LoadAndExpectSuccess("init_ignored_icon_size.json")); - EXPECT_EQ("", IconsInfo::GetIcons(extension).Get( - 300, ExtensionIconSet::MATCH_EXACTLY)); + EXPECT_EQ("", + IconsInfo::GetIcons(extension.get()) + .Get(300, ExtensionIconSet::MATCH_EXACTLY)); } TEST_F(IconsManifestTest, ValidIconSizes) { scoped_refptr<extensions::Extension> extension( LoadAndExpectSuccess("init_valid_icon_size.json")); - const ExtensionIconSet& icons = IconsInfo::GetIcons(extension); + const ExtensionIconSet& icons = IconsInfo::GetIcons(extension.get()); EXPECT_EQ("16.png", icons.Get(extension_misc::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY)); diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc index 0b4af1f..e6f5eb8 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc @@ -100,9 +100,9 @@ TEST_F(InitValueManifestTest, InitFromValueValid) { // Test with an options page. extension = LoadAndExpectSuccess("init_valid_options.json"); EXPECT_EQ("chrome-extension", - ManifestURL::GetOptionsPage(extension).scheme()); + ManifestURL::GetOptionsPage(extension.get()).scheme()); EXPECT_EQ("/options.html", - ManifestURL::GetOptionsPage(extension).path()); + ManifestURL::GetOptionsPage(extension.get()).path()); Testcase testcases[] = { // Test that an empty list of page actions does not stop a browser action diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_isolatedapp_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_isolatedapp_unittest.cc index d291558..bdbba82 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_isolatedapp_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_isolatedapp_unittest.cc @@ -27,7 +27,7 @@ TEST_F(IsolatedAppsManifestTest, IsolatedApps) { switches::kEnableExperimentalExtensionApis); scoped_refptr<Extension> extension2( LoadAndExpectSuccess("isolated_app_valid.json")); - EXPECT_TRUE(AppIsolationInfo::HasIsolatedStorage(extension2)); + EXPECT_TRUE(AppIsolationInfo::HasIsolatedStorage(extension2.get())); } } // namespace extensions diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_kiosk_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_kiosk_unittest.cc index a9bbc40..6056813 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_kiosk_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_kiosk_unittest.cc @@ -21,37 +21,37 @@ TEST_F(ExtensionManifestKioskEnabledTest, InvalidKioskEnabled) { TEST_F(ExtensionManifestKioskEnabledTest, KioskEnabledHostedApp) { scoped_refptr<Extension> extension( LoadAndExpectSuccess("kiosk_enabled_hosted_app.json")); - EXPECT_FALSE(KioskEnabledInfo::IsKioskEnabled(extension)); + EXPECT_FALSE(KioskEnabledInfo::IsKioskEnabled(extension.get())); } TEST_F(ExtensionManifestKioskEnabledTest, KioskEnabledPackagedApp) { scoped_refptr<Extension> extension( LoadAndExpectSuccess("kiosk_enabled_packaged_app.json")); - EXPECT_FALSE(KioskEnabledInfo::IsKioskEnabled(extension)); + EXPECT_FALSE(KioskEnabledInfo::IsKioskEnabled(extension.get())); } TEST_F(ExtensionManifestKioskEnabledTest, KioskEnabledExtension) { scoped_refptr<Extension> extension( LoadAndExpectSuccess("kiosk_enabled_extension.json")); - EXPECT_FALSE(KioskEnabledInfo::IsKioskEnabled(extension)); + EXPECT_FALSE(KioskEnabledInfo::IsKioskEnabled(extension.get())); } TEST_F(ExtensionManifestKioskEnabledTest, KioskEnabledPlatformApp) { scoped_refptr<Extension> extension( LoadAndExpectSuccess("kiosk_enabled_platform_app.json")); - EXPECT_TRUE(KioskEnabledInfo::IsKioskEnabled(extension)); + EXPECT_TRUE(KioskEnabledInfo::IsKioskEnabled(extension.get())); } TEST_F(ExtensionManifestKioskEnabledTest, KioskDisabledPlatformApp) { scoped_refptr<Extension> extension( LoadAndExpectSuccess("kiosk_disabled_platform_app.json")); - EXPECT_FALSE(KioskEnabledInfo::IsKioskEnabled(extension)); + EXPECT_FALSE(KioskEnabledInfo::IsKioskEnabled(extension.get())); } TEST_F(ExtensionManifestKioskEnabledTest, KioskDefaultPlatformApp) { scoped_refptr<Extension> extension( LoadAndExpectSuccess("kiosk_default_platform_app.json")); - EXPECT_FALSE(KioskEnabledInfo::IsKioskEnabled(extension)); + EXPECT_FALSE(KioskEnabledInfo::IsKioskEnabled(extension.get())); } } // namespace extensions diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_offline_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_offline_unittest.cc index 4fc698c..64190a8 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_offline_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_offline_unittest.cc @@ -20,22 +20,22 @@ TEST_F(ExtensionManifestOfflineEnabledTest, OfflineEnabled) { errors::kInvalidOfflineEnabled); scoped_refptr<Extension> extension_0( LoadAndExpectSuccess("offline_enabled_extension.json")); - EXPECT_TRUE(OfflineEnabledInfo::IsOfflineEnabled(extension_0)); + EXPECT_TRUE(OfflineEnabledInfo::IsOfflineEnabled(extension_0.get())); scoped_refptr<Extension> extension_1( LoadAndExpectSuccess("offline_enabled_packaged_app.json")); - EXPECT_TRUE(OfflineEnabledInfo::IsOfflineEnabled(extension_1)); + EXPECT_TRUE(OfflineEnabledInfo::IsOfflineEnabled(extension_1.get())); scoped_refptr<Extension> extension_2( LoadAndExpectSuccess("offline_disabled_packaged_app.json")); - EXPECT_FALSE(OfflineEnabledInfo::IsOfflineEnabled(extension_2)); + EXPECT_FALSE(OfflineEnabledInfo::IsOfflineEnabled(extension_2.get())); scoped_refptr<Extension> extension_3( LoadAndExpectSuccess("offline_default_packaged_app.json")); - EXPECT_FALSE(OfflineEnabledInfo::IsOfflineEnabled(extension_3)); + EXPECT_FALSE(OfflineEnabledInfo::IsOfflineEnabled(extension_3.get())); scoped_refptr<Extension> extension_4( LoadAndExpectSuccess("offline_enabled_hosted_app.json")); - EXPECT_TRUE(OfflineEnabledInfo::IsOfflineEnabled(extension_4)); + EXPECT_TRUE(OfflineEnabledInfo::IsOfflineEnabled(extension_4.get())); scoped_refptr<Extension> extension_5( LoadAndExpectSuccess("offline_default_platform_app.json")); - EXPECT_TRUE(OfflineEnabledInfo::IsOfflineEnabled(extension_5)); + EXPECT_TRUE(OfflineEnabledInfo::IsOfflineEnabled(extension_5.get())); } } // namespace extensions diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_options_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_options_unittest.cc index 9da54df..224062c 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_options_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_options_unittest.cc @@ -17,19 +17,19 @@ TEST_F(OptionsPageManifestTest, OptionsPageInApps) { // Allow options page with absolute URL in hosted apps. extension = LoadAndExpectSuccess("hosted_app_absolute_options.json"); - EXPECT_STREQ( - "http", - extensions::ManifestURL::GetOptionsPage(extension).scheme().c_str()); + EXPECT_STREQ("http", + extensions::ManifestURL::GetOptionsPage(extension.get()) + .scheme().c_str()); EXPECT_STREQ( "example.com", - extensions::ManifestURL::GetOptionsPage(extension).host().c_str()); - EXPECT_STREQ( - "options.html", - extensions::ManifestURL:: - GetOptionsPage(extension).ExtractFileName().c_str()); + extensions::ManifestURL::GetOptionsPage(extension.get()).host().c_str()); + EXPECT_STREQ("options.html", + extensions::ManifestURL::GetOptionsPage(extension.get()) + .ExtractFileName().c_str()); extension = LoadAndExpectSuccess("platform_app_with_options_page.json"); - EXPECT_TRUE(extensions::ManifestURL::GetOptionsPage(extension).is_empty()); + EXPECT_TRUE(extensions::ManifestURL::GetOptionsPage(extension.get()) + .is_empty()); Testcase testcases[] = { // Forbid options page with relative URL in hosted apps. diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_override_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_override_unittest.cc index 13fa6d8..caeeb78 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_override_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_override_unittest.cc @@ -24,11 +24,11 @@ TEST_F(URLOverridesManifestTest, Override) { extension = LoadAndExpectSuccess("override_new_tab.json"); EXPECT_EQ(extension->url().spec() + "newtab.html", - extensions::URLOverrides::GetChromeURLOverrides(extension). - find("newtab")->second.spec()); + extensions::URLOverrides::GetChromeURLOverrides(extension.get()) + .find("newtab")->second.spec()); extension = LoadAndExpectSuccess("override_history.json"); EXPECT_EQ(extension->url().spec() + "history.html", - extensions::URLOverrides::GetChromeURLOverrides(extension). - find("history")->second.spec()); + extensions::URLOverrides::GetChromeURLOverrides(extension.get()) + .find("history")->second.spec()); } diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc index 62c1023..ae4620b 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc @@ -23,15 +23,15 @@ class PlatformAppsManifestTest : public ExtensionManifestTest { TEST_F(PlatformAppsManifestTest, PlatformApps) { scoped_refptr<Extension> extension = LoadAndExpectSuccess("init_valid_platform_app.json"); - EXPECT_TRUE(AppIsolationInfo::HasIsolatedStorage(extension)); - EXPECT_TRUE(IncognitoInfo::IsSplitMode(extension)); + EXPECT_TRUE(AppIsolationInfo::HasIsolatedStorage(extension.get())); + EXPECT_TRUE(IncognitoInfo::IsSplitMode(extension.get())); extension = LoadAndExpectSuccess("init_valid_platform_app_no_manifest_version.json"); EXPECT_EQ(2, extension->manifest_version()); extension = LoadAndExpectSuccess("incognito_valid_platform_app.json"); - EXPECT_TRUE(IncognitoInfo::IsSplitMode(extension)); + EXPECT_TRUE(IncognitoInfo::IsSplitMode(extension.get())); Testcase error_testcases[] = { Testcase("init_invalid_platform_app_2.json", @@ -87,9 +87,9 @@ TEST_F(PlatformAppsManifestTest, PlatformAppContentSecurityPolicy) { EXPECT_EQ(0U, extension->install_warnings().size()) << "Unexpected warning " << extension->install_warnings()[0].message; EXPECT_TRUE(extension->is_platform_app()); - EXPECT_EQ( - "default-src 'self' https://www.google.com", - CSPInfo::GetResourceContentSecurityPolicy(extension, std::string())); + EXPECT_EQ("default-src 'self' https://www.google.com", + CSPInfo::GetResourceContentSecurityPolicy(extension.get(), + std::string())); // But even whitelisted ones must specify a secure policy. LoadAndExpectError( diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_requirements_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_requirements_unittest.cc index b182059..02d6f2e 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_requirements_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_requirements_unittest.cc @@ -51,16 +51,16 @@ TEST_F(RequirementsManifestTest, RequirementsValid) { scoped_refptr<Extension> extension(LoadAndExpectSuccess( "requirements_valid_empty.json")); ASSERT_TRUE(extension.get()); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).webgl, false); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).css3d, false); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).npapi, false); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).webgl, false); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).css3d, false); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).npapi, false); // Test loading all the requirements. extension = LoadAndExpectSuccess("requirements_valid_full.json"); ASSERT_TRUE(extension.get()); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).webgl, true); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).css3d, true); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).npapi, true); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).webgl, true); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).css3d, true); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).npapi, true); } // When an npapi plugin is present, the default of the "npapi" requirement @@ -69,28 +69,28 @@ TEST_F(RequirementsManifestTest, RequirementsNpapiDefault) { scoped_refptr<Extension> extension(LoadAndExpectSuccess( "requirements_npapi_empty.json")); ASSERT_TRUE(extension.get()); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).webgl, false); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).css3d, false); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).npapi, true); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).webgl, false); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).css3d, false); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).npapi, true); extension = LoadAndExpectSuccess( "requirements_npapi_empty_plugins_empty.json"); ASSERT_TRUE(extension.get()); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).webgl, false); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).css3d, false); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).npapi, false); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).webgl, false); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).css3d, false); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).npapi, false); extension = LoadAndExpectSuccess("requirements_npapi.json"); ASSERT_TRUE(extension.get()); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).webgl, false); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).css3d, false); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).npapi, false); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).webgl, false); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).css3d, false); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).npapi, false); extension = LoadAndExpectSuccess("requirements_npapi_plugins_empty.json"); ASSERT_TRUE(extension.get()); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).webgl, false); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).css3d, false); - EXPECT_EQ(RequirementsInfo::GetRequirements(extension).npapi, true); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).webgl, false); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).css3d, false); + EXPECT_EQ(RequirementsInfo::GetRequirements(extension.get()).npapi, true); } } // namespace extensions diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_sandboxed_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_sandboxed_unittest.cc index e6e2986..da3965c 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_sandboxed_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_sandboxed_unittest.cc @@ -41,23 +41,30 @@ TEST_F(SandboxedPagesManifestTest, SandboxedPages) { const char kCustomSandboxedCSP[] = "sandbox; script-src: https://www.google.com"; - EXPECT_EQ(kSandboxedCSP, - CSPInfo::GetResourceContentSecurityPolicy(extension1, "/test")); - EXPECT_EQ(kDefaultCSP, - CSPInfo::GetResourceContentSecurityPolicy(extension1, "/none")); - EXPECT_EQ(kDefaultCSP, - CSPInfo::GetResourceContentSecurityPolicy(extension2, "/test")); - EXPECT_EQ(kCustomSandboxedCSP, - CSPInfo::GetResourceContentSecurityPolicy(extension3, "/test")); - EXPECT_EQ(kDefaultCSP, - CSPInfo::GetResourceContentSecurityPolicy(extension3, "/none")); - EXPECT_EQ(kSandboxedCSP, - CSPInfo::GetResourceContentSecurityPolicy(extension4, "/test")); EXPECT_EQ( kSandboxedCSP, - CSPInfo::GetResourceContentSecurityPolicy(extension5, "/path/test.ext")); - EXPECT_EQ(kDefaultCSP, - CSPInfo::GetResourceContentSecurityPolicy(extension5, "/test")); + CSPInfo::GetResourceContentSecurityPolicy(extension1.get(), "/test")); + EXPECT_EQ( + kDefaultCSP, + CSPInfo::GetResourceContentSecurityPolicy(extension1.get(), "/none")); + EXPECT_EQ( + kDefaultCSP, + CSPInfo::GetResourceContentSecurityPolicy(extension2.get(), "/test")); + EXPECT_EQ( + kCustomSandboxedCSP, + CSPInfo::GetResourceContentSecurityPolicy(extension3.get(), "/test")); + EXPECT_EQ( + kDefaultCSP, + CSPInfo::GetResourceContentSecurityPolicy(extension3.get(), "/none")); + EXPECT_EQ( + kSandboxedCSP, + CSPInfo::GetResourceContentSecurityPolicy(extension4.get(), "/test")); + EXPECT_EQ(kSandboxedCSP, + CSPInfo::GetResourceContentSecurityPolicy(extension5.get(), + "/path/test.ext")); + EXPECT_EQ( + kDefaultCSP, + CSPInfo::GetResourceContentSecurityPolicy(extension5.get(), "/test")); Testcase testcases[] = { Testcase("sandboxed_pages_invalid_1.json", diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_web_accessible_resources_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_web_accessible_resources_unittest.cc index 98ee6aa..44daa6e 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_web_accessible_resources_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_web_accessible_resources_unittest.cc @@ -39,45 +39,45 @@ TEST_F(WebAccessibleResourcesManifestTest, WebAccessibleResources) { LoadAndExpectSuccess("web_accessible_resources_6.json")); EXPECT_TRUE( - WebAccessibleResourcesInfo::HasWebAccessibleResources(extension1)); + WebAccessibleResourcesInfo::HasWebAccessibleResources(extension1.get())); EXPECT_FALSE( - WebAccessibleResourcesInfo::HasWebAccessibleResources(extension2)); + WebAccessibleResourcesInfo::HasWebAccessibleResources(extension2.get())); EXPECT_TRUE( - WebAccessibleResourcesInfo::HasWebAccessibleResources(extension3)); + WebAccessibleResourcesInfo::HasWebAccessibleResources(extension3.get())); EXPECT_FALSE( - WebAccessibleResourcesInfo::HasWebAccessibleResources(extension4)); + WebAccessibleResourcesInfo::HasWebAccessibleResources(extension4.get())); EXPECT_TRUE( - WebAccessibleResourcesInfo::HasWebAccessibleResources(extension5)); + WebAccessibleResourcesInfo::HasWebAccessibleResources(extension5.get())); EXPECT_TRUE( - WebAccessibleResourcesInfo::HasWebAccessibleResources(extension6)); + WebAccessibleResourcesInfo::HasWebAccessibleResources(extension6.get())); EXPECT_TRUE(WebAccessibleResourcesInfo::IsResourceWebAccessible( - extension1, "test")); + extension1.get(), "test")); EXPECT_FALSE(WebAccessibleResourcesInfo::IsResourceWebAccessible( - extension1, "none")); + extension1.get(), "none")); EXPECT_FALSE(WebAccessibleResourcesInfo::IsResourceWebAccessible( - extension2, "test")); + extension2.get(), "test")); EXPECT_TRUE(WebAccessibleResourcesInfo::IsResourceWebAccessible( - extension3, "test")); + extension3.get(), "test")); EXPECT_FALSE(WebAccessibleResourcesInfo::IsResourceWebAccessible( - extension3, "none")); + extension3.get(), "none")); EXPECT_TRUE(WebAccessibleResourcesInfo::IsResourceWebAccessible( - extension4, "test")); + extension4.get(), "test")); EXPECT_TRUE(WebAccessibleResourcesInfo::IsResourceWebAccessible( - extension4, "none")); + extension4.get(), "none")); EXPECT_TRUE(WebAccessibleResourcesInfo::IsResourceWebAccessible( - extension5, "anything")); + extension5.get(), "anything")); EXPECT_TRUE(WebAccessibleResourcesInfo::IsResourceWebAccessible( - extension5, "path/anything")); + extension5.get(), "path/anything")); EXPECT_TRUE(WebAccessibleResourcesInfo::IsResourceWebAccessible( - extension6, "path/anything.ext")); + extension6.get(), "path/anything.ext")); EXPECT_FALSE(WebAccessibleResourcesInfo::IsResourceWebAccessible( - extension6, "anything.ext")); + extension6.get(), "anything.ext")); EXPECT_FALSE(WebAccessibleResourcesInfo::IsResourceWebAccessible( - extension6, "path/anything.badext")); + extension6.get(), "path/anything.badext")); } diff --git a/chrome/common/extensions/permissions/bluetooth_device_permission.cc b/chrome/common/extensions/permissions/bluetooth_device_permission.cc index 8cb0b18..d9d00c7 100644 --- a/chrome/common/extensions/permissions/bluetooth_device_permission.cc +++ b/chrome/common/extensions/permissions/bluetooth_device_permission.cc @@ -46,7 +46,7 @@ PermissionMessages BluetoothDevicePermission::GetMessages() const { const std::string& device_address = i->device_address(); string16 device_identifier; - if (bluetooth_adapter) { + if (bluetooth_adapter.get()) { device::BluetoothDevice* device = bluetooth_adapter->GetDevice(device_address); if (device) diff --git a/chrome/common/extensions/permissions/permission_set.cc b/chrome/common/extensions/permissions/permission_set.cc index a6467aa..3025353 100644 --- a/chrome/common/extensions/permissions/permission_set.cc +++ b/chrome/common/extensions/permissions/permission_set.cc @@ -120,8 +120,8 @@ PermissionSet* PermissionSet::CreateDifference( const PermissionSet* set1, const PermissionSet* set2) { scoped_refptr<PermissionSet> empty = new PermissionSet(); - const PermissionSet* set1_safe = (set1 == NULL) ? empty : set1; - const PermissionSet* set2_safe = (set2 == NULL) ? empty : set2; + const PermissionSet* set1_safe = (set1 == NULL) ? empty.get() : set1; + const PermissionSet* set2_safe = (set2 == NULL) ? empty.get() : set2; APIPermissionSet apis; APIPermissionSet::Difference(set1_safe->apis(), set2_safe->apis(), &apis); @@ -144,8 +144,8 @@ PermissionSet* PermissionSet::CreateIntersection( const PermissionSet* set1, const PermissionSet* set2) { scoped_refptr<PermissionSet> empty = new PermissionSet(); - const PermissionSet* set1_safe = (set1 == NULL) ? empty : set1; - const PermissionSet* set2_safe = (set2 == NULL) ? empty : set2; + const PermissionSet* set1_safe = (set1 == NULL) ? empty.get() : set1; + const PermissionSet* set2_safe = (set2 == NULL) ? empty.get() : set2; APIPermissionSet apis; APIPermissionSet::Intersection(set1_safe->apis(), set2_safe->apis(), &apis); @@ -168,8 +168,8 @@ PermissionSet* PermissionSet::CreateUnion( const PermissionSet* set1, const PermissionSet* set2) { scoped_refptr<PermissionSet> empty = new PermissionSet(); - const PermissionSet* set1_safe = (set1 == NULL) ? empty : set1; - const PermissionSet* set2_safe = (set2 == NULL) ? empty : set2; + const PermissionSet* set1_safe = (set1 == NULL) ? empty.get() : set1; + const PermissionSet* set2_safe = (set2 == NULL) ? empty.get() : set2; APIPermissionSet apis; APIPermissionSet::Union(set1_safe->apis(), set2_safe->apis(), &apis); diff --git a/chrome/common/extensions/permissions/permission_set_unittest.cc b/chrome/common/extensions/permissions/permission_set_unittest.cc index 633a7b1..35de01e 100644 --- a/chrome/common/extensions/permissions/permission_set_unittest.cc +++ b/chrome/common/extensions/permissions/permission_set_unittest.cc @@ -125,12 +125,11 @@ TEST(PermissionsTest, EffectiveHostPermissions) { extension = LoadManifest("effective_host_permissions", "empty.json"); permissions = extension->GetActivePermissions(); - EXPECT_EQ( - 0u, - PermissionsData::GetEffectiveHostPermissions( - extension).patterns().size()); - EXPECT_FALSE(permissions->HasEffectiveAccessToURL( - GURL("http://www.google.com"))); + EXPECT_EQ(0u, + PermissionsData::GetEffectiveHostPermissions(extension.get()) + .patterns().size()); + EXPECT_FALSE( + permissions->HasEffectiveAccessToURL(GURL("http://www.google.com"))); EXPECT_FALSE(permissions->HasEffectiveAccessToAllHosts()); extension = LoadManifest("effective_host_permissions", "one_host.json"); @@ -270,12 +269,12 @@ TEST(PermissionsTest, CreateUnion) { set1 = new PermissionSet(apis1, explicit_hosts1, scriptable_hosts1); set2 = new PermissionSet(apis2, explicit_hosts2, scriptable_hosts2); union_set = PermissionSet::CreateUnion(set1.get(), set2.get()); - EXPECT_TRUE(set1->Contains(*set2)); - EXPECT_TRUE(set1->Contains(*union_set)); - EXPECT_FALSE(set2->Contains(*set1)); - EXPECT_FALSE(set2->Contains(*union_set)); - EXPECT_TRUE(union_set->Contains(*set1)); - EXPECT_TRUE(union_set->Contains(*set2)); + EXPECT_TRUE(set1->Contains(*set2.get())); + EXPECT_TRUE(set1->Contains(*union_set.get())); + EXPECT_FALSE(set2->Contains(*set1.get())); + EXPECT_FALSE(set2->Contains(*union_set.get())); + EXPECT_TRUE(union_set->Contains(*set1.get())); + EXPECT_TRUE(union_set->Contains(*set2.get())); EXPECT_FALSE(union_set->HasEffectiveFullAccess()); EXPECT_EQ(expected_apis, union_set->apis()); @@ -330,12 +329,12 @@ TEST(PermissionsTest, CreateUnion) { set2 = new PermissionSet(apis2, explicit_hosts2, scriptable_hosts2); union_set = PermissionSet::CreateUnion(set1.get(), set2.get()); - EXPECT_FALSE(set1->Contains(*set2)); - EXPECT_FALSE(set1->Contains(*union_set)); - EXPECT_FALSE(set2->Contains(*set1)); - EXPECT_FALSE(set2->Contains(*union_set)); - EXPECT_TRUE(union_set->Contains(*set1)); - EXPECT_TRUE(union_set->Contains(*set2)); + EXPECT_FALSE(set1->Contains(*set2.get())); + EXPECT_FALSE(set1->Contains(*union_set.get())); + EXPECT_FALSE(set2->Contains(*set1.get())); + EXPECT_FALSE(set2->Contains(*union_set.get())); + EXPECT_TRUE(union_set->Contains(*set1.get())); + EXPECT_TRUE(union_set->Contains(*set2.get())); EXPECT_TRUE(union_set->HasEffectiveFullAccess()); EXPECT_TRUE(union_set->HasEffectiveAccessToAllHosts()); @@ -390,12 +389,12 @@ TEST(PermissionsTest, CreateIntersection) { set1 = new PermissionSet(apis1, explicit_hosts1, scriptable_hosts1); set2 = new PermissionSet(apis2, explicit_hosts2, scriptable_hosts2); new_set = PermissionSet::CreateIntersection(set1.get(), set2.get()); - EXPECT_TRUE(set1->Contains(*new_set)); - EXPECT_TRUE(set2->Contains(*new_set)); - EXPECT_TRUE(set1->Contains(*set2)); - EXPECT_FALSE(set2->Contains(*set1)); - EXPECT_FALSE(new_set->Contains(*set1)); - EXPECT_TRUE(new_set->Contains(*set2)); + EXPECT_TRUE(set1->Contains(*new_set.get())); + EXPECT_TRUE(set2->Contains(*new_set.get())); + EXPECT_TRUE(set1->Contains(*set2.get())); + EXPECT_FALSE(set2->Contains(*set1.get())); + EXPECT_FALSE(new_set->Contains(*set1.get())); + EXPECT_TRUE(new_set->Contains(*set2.get())); EXPECT_TRUE(new_set->IsEmpty()); EXPECT_FALSE(new_set->HasEffectiveFullAccess()); @@ -444,12 +443,12 @@ TEST(PermissionsTest, CreateIntersection) { set2 = new PermissionSet(apis2, explicit_hosts2, scriptable_hosts2); new_set = PermissionSet::CreateIntersection(set1.get(), set2.get()); - EXPECT_TRUE(set1->Contains(*new_set)); - EXPECT_TRUE(set2->Contains(*new_set)); - EXPECT_FALSE(set1->Contains(*set2)); - EXPECT_FALSE(set2->Contains(*set1)); - EXPECT_FALSE(new_set->Contains(*set1)); - EXPECT_FALSE(new_set->Contains(*set2)); + EXPECT_TRUE(set1->Contains(*new_set.get())); + EXPECT_TRUE(set2->Contains(*new_set.get())); + EXPECT_FALSE(set1->Contains(*set2.get())); + EXPECT_FALSE(set2->Contains(*set1.get())); + EXPECT_FALSE(new_set->Contains(*set1.get())); + EXPECT_FALSE(new_set->Contains(*set2.get())); EXPECT_FALSE(new_set->HasEffectiveFullAccess()); EXPECT_FALSE(new_set->HasEffectiveAccessToAllHosts()); @@ -504,7 +503,7 @@ TEST(PermissionsTest, CreateDifference) { set1 = new PermissionSet(apis1, explicit_hosts1, scriptable_hosts1); set2 = new PermissionSet(apis2, explicit_hosts2, scriptable_hosts2); new_set = PermissionSet::CreateDifference(set1.get(), set2.get()); - EXPECT_EQ(*set1, *new_set); + EXPECT_EQ(*set1.get(), *new_set.get()); // Now use a real second set. apis2.insert(APIPermission::kTab); @@ -545,8 +544,8 @@ TEST(PermissionsTest, CreateDifference) { set2 = new PermissionSet(apis2, explicit_hosts2, scriptable_hosts2); new_set = PermissionSet::CreateDifference(set1.get(), set2.get()); - EXPECT_TRUE(set1->Contains(*new_set)); - EXPECT_FALSE(set2->Contains(*new_set)); + EXPECT_TRUE(set1->Contains(*new_set.get())); + EXPECT_FALSE(set2->Contains(*new_set.get())); EXPECT_FALSE(new_set->HasEffectiveFullAccess()); EXPECT_FALSE(new_set->HasEffectiveAccessToAllHosts()); @@ -607,7 +606,7 @@ TEST(PermissionsTest, HasLessPrivilegesThan) { new_extension->GetActivePermissions()); EXPECT_EQ(kTests[i].expect_increase, - old_p->HasLessPrivilegesThan(new_p)) << kTests[i].base_name; + old_p->HasLessPrivilegesThan(new_p.get())) << kTests[i].base_name; } } @@ -814,7 +813,7 @@ TEST(PermissionsTest, GetWarningMessages_ManyHosts) { extension = LoadManifest("permissions", "many-hosts.json"); std::vector<string16> warnings = - PermissionsData::GetPermissionMessageStrings(extension); + PermissionsData::GetPermissionMessageStrings(extension.get()); ASSERT_EQ(1u, warnings.size()); EXPECT_EQ("Access your data on encrypted.google.com and www.google.com", UTF16ToUTF8(warnings[0])); @@ -826,8 +825,8 @@ TEST(PermissionsTest, GetWarningMessages_Plugins) { extension = LoadManifest("permissions", "plugins.json"); std::vector<string16> warnings = - PermissionsData::GetPermissionMessageStrings(extension); - // We don't parse the plugins key on Chrome OS, so it should not ask for any + PermissionsData::GetPermissionMessageStrings(extension.get()); +// We don't parse the plugins key on Chrome OS, so it should not ask for any // permissions. #if defined(OS_CHROMEOS) ASSERT_EQ(0u, warnings.size()); @@ -878,9 +877,9 @@ TEST(PermissionsTest, GetWarningMessages_Serial) { EXPECT_TRUE(extension->is_platform_app()); EXPECT_TRUE(extension->HasAPIPermission(APIPermission::kSerial)); std::vector<string16> warnings = - PermissionsData::GetPermissionMessageStrings(extension); - EXPECT_TRUE(Contains(warnings, - "Use serial devices attached to your computer")); + PermissionsData::GetPermissionMessageStrings(extension.get()); + EXPECT_TRUE( + Contains(warnings, "Use serial devices attached to your computer")); ASSERT_EQ(1u, warnings.size()); } @@ -892,7 +891,7 @@ TEST(PermissionsTest, GetWarningMessages_Socket_AnyHost) { EXPECT_TRUE(extension->is_platform_app()); EXPECT_TRUE(extension->HasAPIPermission(APIPermission::kSocket)); std::vector<string16> warnings = - PermissionsData::GetPermissionMessageStrings(extension); + PermissionsData::GetPermissionMessageStrings(extension.get()); EXPECT_EQ(1u, warnings.size()); EXPECT_TRUE(Contains(warnings, "Exchange data with any computer " "on the local network or internet")); @@ -906,7 +905,7 @@ TEST(PermissionsTest, GetWarningMessages_Socket_OneDomainTwoHostnames) { EXPECT_TRUE(extension->is_platform_app()); EXPECT_TRUE(extension->HasAPIPermission(APIPermission::kSocket)); std::vector<string16> warnings = - PermissionsData::GetPermissionMessageStrings(extension); + PermissionsData::GetPermissionMessageStrings(extension.get()); // Verify the warnings, including support for unicode characters, the fact // that domain host warnings come before specific host warnings, and the fact @@ -932,7 +931,7 @@ TEST(PermissionsTest, GetWarningMessages_Socket_TwoDomainsOneHostname) { EXPECT_TRUE(extension->is_platform_app()); EXPECT_TRUE(extension->HasAPIPermission(APIPermission::kSocket)); std::vector<string16> warnings = - PermissionsData::GetPermissionMessageStrings(extension); + PermissionsData::GetPermissionMessageStrings(extension.get()); // Verify the warnings, including the fact that domain host warnings come // before specific host warnings and the fact that domains and hostnames are @@ -954,12 +953,12 @@ TEST(PermissionsTest, GetWarningMessages_PlatformApppHosts) { extension = LoadManifest("permissions", "platform_app_hosts.json"); EXPECT_TRUE(extension->is_platform_app()); std::vector<string16> warnings = - PermissionsData::GetPermissionMessageStrings(extension); + PermissionsData::GetPermissionMessageStrings(extension.get()); ASSERT_EQ(0u, warnings.size()); extension = LoadManifest("permissions", "platform_app_all_urls.json"); EXPECT_TRUE(extension->is_platform_app()); - warnings = PermissionsData::GetPermissionMessageStrings(extension); + warnings = PermissionsData::GetPermissionMessageStrings(extension.get()); ASSERT_EQ(0u, warnings.size()); } @@ -1354,7 +1353,7 @@ TEST(PermissionsTest, SyncFileSystemPermission) { EXPECT_TRUE(extension->is_platform_app()); EXPECT_TRUE(extension->HasAPIPermission(APIPermission::kSyncFileSystem)); std::vector<string16> warnings = - PermissionsData::GetPermissionMessageStrings(extension); + PermissionsData::GetPermissionMessageStrings(extension.get()); EXPECT_TRUE(Contains(warnings, "Store data in your Google Drive account")); ASSERT_EQ(1u, warnings.size()); } diff --git a/chrome/common/extensions/permissions/permissions_data.cc b/chrome/common/extensions/permissions/permissions_data.cc index 8e964da..ce35730 100644 --- a/chrome/common/extensions/permissions/permissions_data.cc +++ b/chrome/common/extensions/permissions/permissions_data.cc @@ -348,8 +348,7 @@ void PermissionsData::UpdateTabSpecificPermissions( &extension->permissions_data()->tab_specific_permissions_; if (tab_permissions->count(tab_id)) { (*tab_permissions)[tab_id] = PermissionSet::CreateUnion( - (*tab_permissions)[tab_id], - permissions.get()); + (*tab_permissions)[tab_id].get(), permissions.get()); } else { (*tab_permissions)[tab_id] = permissions; } diff --git a/chrome/common/extensions/permissions/permissions_data_unittest.cc b/chrome/common/extensions/permissions/permissions_data_unittest.cc index fce5d2b..803aa1d 100644 --- a/chrome/common/extensions/permissions/permissions_data_unittest.cc +++ b/chrome/common/extensions/permissions/permissions_data_unittest.cc @@ -40,7 +40,7 @@ bool CheckSocketPermission( int port) { SocketPermission::CheckParam param(type, host, port); return PermissionsData::CheckAPIPermissionWithParam( - extension, APIPermission::kSocket, ¶m); + extension.get(), APIPermission::kSocket, ¶m); } } // namespace @@ -50,42 +50,41 @@ TEST(ExtensionPermissionsTest, EffectiveHostPermissions) { URLPatternSet hosts; extension = LoadManifest("effective_host_permissions", "empty.json"); - EXPECT_EQ( - 0u, - PermissionsData::GetEffectiveHostPermissions( - extension).patterns().size()); + EXPECT_EQ(0u, + PermissionsData::GetEffectiveHostPermissions(extension.get()) + .patterns().size()); EXPECT_FALSE(hosts.MatchesURL(GURL("http://www.google.com"))); - EXPECT_FALSE(PermissionsData::HasEffectiveAccessToAllHosts(extension)); + EXPECT_FALSE(PermissionsData::HasEffectiveAccessToAllHosts(extension.get())); extension = LoadManifest("effective_host_permissions", "one_host.json"); - hosts = PermissionsData::GetEffectiveHostPermissions(extension); + hosts = PermissionsData::GetEffectiveHostPermissions(extension.get()); EXPECT_TRUE(hosts.MatchesURL(GURL("http://www.google.com"))); EXPECT_FALSE(hosts.MatchesURL(GURL("https://www.google.com"))); - EXPECT_FALSE(PermissionsData::HasEffectiveAccessToAllHosts(extension)); + EXPECT_FALSE(PermissionsData::HasEffectiveAccessToAllHosts(extension.get())); extension = LoadManifest("effective_host_permissions", "one_host_wildcard.json"); - hosts = PermissionsData::GetEffectiveHostPermissions(extension); + hosts = PermissionsData::GetEffectiveHostPermissions(extension.get()); EXPECT_TRUE(hosts.MatchesURL(GURL("http://google.com"))); EXPECT_TRUE(hosts.MatchesURL(GURL("http://foo.google.com"))); - EXPECT_FALSE(PermissionsData::HasEffectiveAccessToAllHosts(extension)); + EXPECT_FALSE(PermissionsData::HasEffectiveAccessToAllHosts(extension.get())); extension = LoadManifest("effective_host_permissions", "two_hosts.json"); - hosts = PermissionsData::GetEffectiveHostPermissions(extension); + hosts = PermissionsData::GetEffectiveHostPermissions(extension.get()); EXPECT_TRUE(hosts.MatchesURL(GURL("http://www.google.com"))); EXPECT_TRUE(hosts.MatchesURL(GURL("http://www.reddit.com"))); - EXPECT_FALSE(PermissionsData::HasEffectiveAccessToAllHosts(extension)); + EXPECT_FALSE(PermissionsData::HasEffectiveAccessToAllHosts(extension.get())); extension = LoadManifest("effective_host_permissions", "https_not_considered.json"); - hosts = PermissionsData::GetEffectiveHostPermissions(extension); + hosts = PermissionsData::GetEffectiveHostPermissions(extension.get()); EXPECT_TRUE(hosts.MatchesURL(GURL("http://google.com"))); EXPECT_TRUE(hosts.MatchesURL(GURL("https://google.com"))); - EXPECT_FALSE(PermissionsData::HasEffectiveAccessToAllHosts(extension)); + EXPECT_FALSE(PermissionsData::HasEffectiveAccessToAllHosts(extension.get())); extension = LoadManifest("effective_host_permissions", "two_content_scripts.json"); - hosts = PermissionsData::GetEffectiveHostPermissions(extension); + hosts = PermissionsData::GetEffectiveHostPermissions(extension.get()); EXPECT_TRUE(hosts.MatchesURL(GURL("http://google.com"))); EXPECT_TRUE(hosts.MatchesURL(GURL("http://www.reddit.com"))); EXPECT_TRUE(extension->GetActivePermissions()->HasEffectiveAccessToURL( @@ -93,27 +92,27 @@ TEST(ExtensionPermissionsTest, EffectiveHostPermissions) { EXPECT_TRUE(hosts.MatchesURL(GURL("http://news.ycombinator.com"))); EXPECT_TRUE(extension->GetActivePermissions()->HasEffectiveAccessToURL( GURL("http://news.ycombinator.com"))); - EXPECT_FALSE(PermissionsData::HasEffectiveAccessToAllHosts(extension)); + EXPECT_FALSE(PermissionsData::HasEffectiveAccessToAllHosts(extension.get())); extension = LoadManifest("effective_host_permissions", "all_hosts.json"); - hosts = PermissionsData::GetEffectiveHostPermissions(extension); + hosts = PermissionsData::GetEffectiveHostPermissions(extension.get()); EXPECT_TRUE(hosts.MatchesURL(GURL("http://test/"))); EXPECT_FALSE(hosts.MatchesURL(GURL("https://test/"))); EXPECT_TRUE(hosts.MatchesURL(GURL("http://www.google.com"))); - EXPECT_TRUE(PermissionsData::HasEffectiveAccessToAllHosts(extension)); + EXPECT_TRUE(PermissionsData::HasEffectiveAccessToAllHosts(extension.get())); extension = LoadManifest("effective_host_permissions", "all_hosts2.json"); - hosts = PermissionsData::GetEffectiveHostPermissions(extension); + hosts = PermissionsData::GetEffectiveHostPermissions(extension.get()); EXPECT_TRUE(hosts.MatchesURL(GURL("http://test/"))); EXPECT_TRUE(hosts.MatchesURL(GURL("http://www.google.com"))); - EXPECT_TRUE(PermissionsData::HasEffectiveAccessToAllHosts(extension)); + EXPECT_TRUE(PermissionsData::HasEffectiveAccessToAllHosts(extension.get())); extension = LoadManifest("effective_host_permissions", "all_hosts3.json"); - hosts = PermissionsData::GetEffectiveHostPermissions(extension); + hosts = PermissionsData::GetEffectiveHostPermissions(extension.get()); EXPECT_FALSE(hosts.MatchesURL(GURL("http://test/"))); EXPECT_TRUE(hosts.MatchesURL(GURL("https://test/"))); EXPECT_TRUE(hosts.MatchesURL(GURL("http://www.google.com"))); - EXPECT_TRUE(PermissionsData::HasEffectiveAccessToAllHosts(extension)); + EXPECT_TRUE(PermissionsData::HasEffectiveAccessToAllHosts(extension.get())); } TEST(ExtensionPermissionsTest, SocketPermissions) { @@ -131,9 +130,10 @@ TEST(ExtensionPermissionsTest, SocketPermissions) { "socket1.json", Manifest::INTERNAL, Extension::NO_FLAGS, &error); - EXPECT_TRUE(extension == NULL); + EXPECT_TRUE(extension.get() == NULL); ASSERT_EQ(ErrorUtils::FormatErrorMessage( - extension_manifest_errors::kInvalidPermission, "socket"), error); + extension_manifest_errors::kInvalidPermission, "socket"), + error); extension = LoadManifest("socket_permissions", "socket2.json"); EXPECT_TRUE(CheckSocketPermission(extension, @@ -202,7 +202,7 @@ TEST(ExtensionPermissionsTest, GetPermissionMessages_ManyAPIPermissions) { scoped_refptr<Extension> extension; extension = LoadManifest("permissions", "many-apis.json"); std::vector<string16> warnings = - PermissionsData::GetPermissionMessageStrings(extension); + PermissionsData::GetPermissionMessageStrings(extension.get()); ASSERT_EQ(6u, warnings.size()); EXPECT_EQ("Access your data on api.flickr.com", UTF16ToUTF8(warnings[0])); @@ -221,7 +221,7 @@ TEST(ExtensionPermissionsTest, GetPermissionMessages_LocationApiPermission) { Manifest::COMPONENT, Extension::NO_FLAGS); std::vector<string16> warnings = - PermissionsData::GetPermissionMessageStrings(extension); + PermissionsData::GetPermissionMessageStrings(extension.get()); ASSERT_EQ(1u, warnings.size()); EXPECT_EQ("Detect your physical location", UTF16ToUTF8(warnings[0])); } @@ -230,7 +230,7 @@ TEST(ExtensionPermissionsTest, GetPermissionMessages_ManyHosts) { scoped_refptr<Extension> extension; extension = LoadManifest("permissions", "many-hosts.json"); std::vector<string16> warnings = - PermissionsData::GetPermissionMessageStrings(extension); + PermissionsData::GetPermissionMessageStrings(extension.get()); ASSERT_EQ(1u, warnings.size()); EXPECT_EQ("Access your data on encrypted.google.com and www.google.com", UTF16ToUTF8(warnings[0])); @@ -240,8 +240,8 @@ TEST(ExtensionPermissionsTest, GetPermissionMessages_Plugins) { scoped_refptr<Extension> extension; extension = LoadManifest("permissions", "plugins.json"); std::vector<string16> warnings = - PermissionsData::GetPermissionMessageStrings(extension); - // We don't parse the plugins key on Chrome OS, so it should not ask for any + PermissionsData::GetPermissionMessageStrings(extension.get()); +// We don't parse the plugins key on Chrome OS, so it should not ask for any // permissions. #if defined(OS_CHROMEOS) ASSERT_EQ(0u, warnings.size()); @@ -364,39 +364,40 @@ TEST_F(ExtensionScriptAndCaptureVisibleTest, Permissions) { scoped_refptr<Extension> extension = LoadManifestStrict("script_and_capture", "extension_regular_all.json"); - EXPECT_TRUE(Allowed(extension, http_url)); - EXPECT_TRUE(Allowed(extension, https_url)); - EXPECT_TRUE(Blocked(extension, file_url)); - EXPECT_TRUE(Blocked(extension, settings_url)); - EXPECT_TRUE(CaptureOnly(extension, favicon_url)); - EXPECT_TRUE(Blocked(extension, about_url)); - EXPECT_TRUE(Blocked(extension, extension_url)); + EXPECT_TRUE(Allowed(extension.get(), http_url)); + EXPECT_TRUE(Allowed(extension.get(), https_url)); + EXPECT_TRUE(Blocked(extension.get(), file_url)); + EXPECT_TRUE(Blocked(extension.get(), settings_url)); + EXPECT_TRUE(CaptureOnly(extension.get(), favicon_url)); + EXPECT_TRUE(Blocked(extension.get(), about_url)); + EXPECT_TRUE(Blocked(extension.get(), extension_url)); // Test access to iframed content. GURL within_extension_url = extension->GetResourceURL("page.html"); - EXPECT_TRUE(AllowedScript(extension, http_url, http_url_with_path)); - EXPECT_TRUE(AllowedScript(extension, https_url, http_url_with_path)); - EXPECT_TRUE(AllowedScript(extension, http_url, within_extension_url)); - EXPECT_TRUE(AllowedScript(extension, https_url, within_extension_url)); - EXPECT_TRUE(BlockedScript(extension, http_url, extension_url)); - EXPECT_TRUE(BlockedScript(extension, https_url, extension_url)); - - EXPECT_FALSE(PermissionsData::HasHostPermission(extension, settings_url)); - EXPECT_FALSE(PermissionsData::HasHostPermission(extension, about_url)); - EXPECT_TRUE(PermissionsData::HasHostPermission(extension, favicon_url)); + EXPECT_TRUE(AllowedScript(extension.get(), http_url, http_url_with_path)); + EXPECT_TRUE(AllowedScript(extension.get(), https_url, http_url_with_path)); + EXPECT_TRUE(AllowedScript(extension.get(), http_url, within_extension_url)); + EXPECT_TRUE(AllowedScript(extension.get(), https_url, within_extension_url)); + EXPECT_TRUE(BlockedScript(extension.get(), http_url, extension_url)); + EXPECT_TRUE(BlockedScript(extension.get(), https_url, extension_url)); + + EXPECT_FALSE( + PermissionsData::HasHostPermission(extension.get(), settings_url)); + EXPECT_FALSE(PermissionsData::HasHostPermission(extension.get(), about_url)); + EXPECT_TRUE(PermissionsData::HasHostPermission(extension.get(), favicon_url)); // Test * for scheme, which implies just the http/https schemes. extension = LoadManifestStrict("script_and_capture", "extension_wildcard.json"); - EXPECT_TRUE(Allowed(extension, http_url)); - EXPECT_TRUE(Allowed(extension, https_url)); - EXPECT_TRUE(Blocked(extension, settings_url)); - EXPECT_TRUE(Blocked(extension, about_url)); - EXPECT_TRUE(Blocked(extension, file_url)); - EXPECT_TRUE(Blocked(extension, favicon_url)); - extension = LoadManifest("script_and_capture", - "extension_wildcard_settings.json"); - EXPECT_TRUE(Blocked(extension, settings_url)); + EXPECT_TRUE(Allowed(extension.get(), http_url)); + EXPECT_TRUE(Allowed(extension.get(), https_url)); + EXPECT_TRUE(Blocked(extension.get(), settings_url)); + EXPECT_TRUE(Blocked(extension.get(), about_url)); + EXPECT_TRUE(Blocked(extension.get(), file_url)); + EXPECT_TRUE(Blocked(extension.get(), favicon_url)); + extension = + LoadManifest("script_and_capture", "extension_wildcard_settings.json"); + EXPECT_TRUE(Blocked(extension.get(), settings_url)); // Having chrome://*/ should not work for regular extensions. Note that // for favicon access, we require the explicit pattern chrome://favicon/*. @@ -405,52 +406,51 @@ TEST_F(ExtensionScriptAndCaptureVisibleTest, Permissions) { "extension_wildcard_chrome.json", Manifest::INTERNAL, Extension::NO_FLAGS, &error); - EXPECT_TRUE(extension == NULL); + EXPECT_TRUE(extension.get() == NULL); EXPECT_EQ( ErrorUtils::FormatErrorMessage( - extension_manifest_errors::kInvalidPermissionScheme, - "chrome://*/"), + extension_manifest_errors::kInvalidPermissionScheme, "chrome://*/"), error); // Having chrome://favicon/* should not give you chrome://* extension = LoadManifestStrict("script_and_capture", "extension_chrome_favicon_wildcard.json"); - EXPECT_TRUE(Blocked(extension, settings_url)); - EXPECT_TRUE(CaptureOnly(extension, favicon_url)); - EXPECT_TRUE(Blocked(extension, about_url)); - EXPECT_TRUE(PermissionsData::HasHostPermission(extension, favicon_url)); + EXPECT_TRUE(Blocked(extension.get(), settings_url)); + EXPECT_TRUE(CaptureOnly(extension.get(), favicon_url)); + EXPECT_TRUE(Blocked(extension.get(), about_url)); + EXPECT_TRUE(PermissionsData::HasHostPermission(extension.get(), favicon_url)); // Having http://favicon should not give you chrome://favicon extension = LoadManifestStrict("script_and_capture", "extension_http_favicon.json"); - EXPECT_TRUE(Blocked(extension, settings_url)); - EXPECT_TRUE(Blocked(extension, favicon_url)); + EXPECT_TRUE(Blocked(extension.get(), settings_url)); + EXPECT_TRUE(Blocked(extension.get(), favicon_url)); // Component extensions with <all_urls> should get everything. extension = LoadManifest("script_and_capture", "extension_component_all.json", Manifest::COMPONENT, Extension::NO_FLAGS); - EXPECT_TRUE(Allowed(extension, http_url)); - EXPECT_TRUE(Allowed(extension, https_url)); - EXPECT_TRUE(Allowed(extension, settings_url)); - EXPECT_TRUE(Allowed(extension, about_url)); - EXPECT_TRUE(Allowed(extension, favicon_url)); - EXPECT_TRUE(PermissionsData::HasHostPermission(extension, favicon_url)); + EXPECT_TRUE(Allowed(extension.get(), http_url)); + EXPECT_TRUE(Allowed(extension.get(), https_url)); + EXPECT_TRUE(Allowed(extension.get(), settings_url)); + EXPECT_TRUE(Allowed(extension.get(), about_url)); + EXPECT_TRUE(Allowed(extension.get(), favicon_url)); + EXPECT_TRUE(PermissionsData::HasHostPermission(extension.get(), favicon_url)); // Component extensions should only get access to what they ask for. extension = LoadManifest("script_and_capture", "extension_component_google.json", Manifest::COMPONENT, Extension::NO_FLAGS); - EXPECT_TRUE(Allowed(extension, http_url)); - EXPECT_TRUE(Blocked(extension, https_url)); - EXPECT_TRUE(Blocked(extension, file_url)); - EXPECT_TRUE(Blocked(extension, settings_url)); - EXPECT_TRUE(Blocked(extension, favicon_url)); - EXPECT_TRUE(Blocked(extension, about_url)); - EXPECT_TRUE(Blocked(extension, extension_url)); - EXPECT_FALSE(PermissionsData::HasHostPermission(extension, settings_url)); + EXPECT_TRUE(Allowed(extension.get(), http_url)); + EXPECT_TRUE(Blocked(extension.get(), https_url)); + EXPECT_TRUE(Blocked(extension.get(), file_url)); + EXPECT_TRUE(Blocked(extension.get(), settings_url)); + EXPECT_TRUE(Blocked(extension.get(), favicon_url)); + EXPECT_TRUE(Blocked(extension.get(), about_url)); + EXPECT_TRUE(Blocked(extension.get(), extension_url)); + EXPECT_FALSE( + PermissionsData::HasHostPermission(extension.get(), settings_url)); } - TEST_F(ExtensionScriptAndCaptureVisibleTest, PermissionsWithChromeURLsEnabled) { CommandLine::ForCurrentProcess()->AppendSwitch( switches::kExtensionsOnChromeURLs); @@ -460,39 +460,40 @@ TEST_F(ExtensionScriptAndCaptureVisibleTest, PermissionsWithChromeURLsEnabled) { // Test <all_urls> for regular extensions. extension = LoadManifestStrict("script_and_capture", "extension_regular_all.json"); - EXPECT_TRUE(Allowed(extension, http_url)); - EXPECT_TRUE(Allowed(extension, https_url)); - EXPECT_TRUE(Blocked(extension, file_url)); - EXPECT_TRUE(Blocked(extension, settings_url)); - EXPECT_TRUE(Allowed(extension, favicon_url)); // chrome:// requested - EXPECT_TRUE(Blocked(extension, about_url)); - EXPECT_TRUE(Blocked(extension, extension_url)); + EXPECT_TRUE(Allowed(extension.get(), http_url)); + EXPECT_TRUE(Allowed(extension.get(), https_url)); + EXPECT_TRUE(Blocked(extension.get(), file_url)); + EXPECT_TRUE(Blocked(extension.get(), settings_url)); + EXPECT_TRUE(Allowed(extension.get(), favicon_url)); // chrome:// requested + EXPECT_TRUE(Blocked(extension.get(), about_url)); + EXPECT_TRUE(Blocked(extension.get(), extension_url)); // Test access to iframed content. GURL within_extension_url = extension->GetResourceURL("page.html"); - EXPECT_TRUE(AllowedScript(extension, http_url, http_url_with_path)); - EXPECT_TRUE(AllowedScript(extension, https_url, http_url_with_path)); - EXPECT_TRUE(AllowedScript(extension, http_url, within_extension_url)); - EXPECT_TRUE(AllowedScript(extension, https_url, within_extension_url)); - EXPECT_TRUE(BlockedScript(extension, http_url, extension_url)); - EXPECT_TRUE(BlockedScript(extension, https_url, extension_url)); - - EXPECT_FALSE(PermissionsData::HasHostPermission(extension, settings_url)); - EXPECT_FALSE(PermissionsData::HasHostPermission(extension, about_url)); - EXPECT_TRUE(PermissionsData::HasHostPermission(extension, favicon_url)); + EXPECT_TRUE(AllowedScript(extension.get(), http_url, http_url_with_path)); + EXPECT_TRUE(AllowedScript(extension.get(), https_url, http_url_with_path)); + EXPECT_TRUE(AllowedScript(extension.get(), http_url, within_extension_url)); + EXPECT_TRUE(AllowedScript(extension.get(), https_url, within_extension_url)); + EXPECT_TRUE(BlockedScript(extension.get(), http_url, extension_url)); + EXPECT_TRUE(BlockedScript(extension.get(), https_url, extension_url)); + + EXPECT_FALSE( + PermissionsData::HasHostPermission(extension.get(), settings_url)); + EXPECT_FALSE(PermissionsData::HasHostPermission(extension.get(), about_url)); + EXPECT_TRUE(PermissionsData::HasHostPermission(extension.get(), favicon_url)); // Test * for scheme, which implies just the http/https schemes. extension = LoadManifestStrict("script_and_capture", "extension_wildcard.json"); - EXPECT_TRUE(Allowed(extension, http_url)); - EXPECT_TRUE(Allowed(extension, https_url)); - EXPECT_TRUE(Blocked(extension, settings_url)); - EXPECT_TRUE(Blocked(extension, about_url)); - EXPECT_TRUE(Blocked(extension, file_url)); - EXPECT_TRUE(Blocked(extension, favicon_url)); - extension = LoadManifest("script_and_capture", - "extension_wildcard_settings.json"); - EXPECT_TRUE(Blocked(extension, settings_url)); + EXPECT_TRUE(Allowed(extension.get(), http_url)); + EXPECT_TRUE(Allowed(extension.get(), https_url)); + EXPECT_TRUE(Blocked(extension.get(), settings_url)); + EXPECT_TRUE(Blocked(extension.get(), about_url)); + EXPECT_TRUE(Blocked(extension.get(), file_url)); + EXPECT_TRUE(Blocked(extension.get(), favicon_url)); + extension = + LoadManifest("script_and_capture", "extension_wildcard_settings.json"); + EXPECT_TRUE(Blocked(extension.get(), settings_url)); // Having chrome://*/ should work for regular extensions with the flag // enabled. @@ -501,65 +502,69 @@ TEST_F(ExtensionScriptAndCaptureVisibleTest, PermissionsWithChromeURLsEnabled) { "extension_wildcard_chrome.json", Manifest::INTERNAL, Extension::NO_FLAGS, &error); - EXPECT_FALSE(extension == NULL); - EXPECT_TRUE(Blocked(extension, http_url)); - EXPECT_TRUE(Blocked(extension, https_url)); - EXPECT_TRUE(Allowed(extension, settings_url)); - EXPECT_TRUE(Blocked(extension, about_url)); - EXPECT_TRUE(Blocked(extension, file_url)); - EXPECT_TRUE(Allowed(extension, favicon_url)); // chrome:// requested + EXPECT_FALSE(extension.get() == NULL); + EXPECT_TRUE(Blocked(extension.get(), http_url)); + EXPECT_TRUE(Blocked(extension.get(), https_url)); + EXPECT_TRUE(Allowed(extension.get(), settings_url)); + EXPECT_TRUE(Blocked(extension.get(), about_url)); + EXPECT_TRUE(Blocked(extension.get(), file_url)); + EXPECT_TRUE(Allowed(extension.get(), favicon_url)); // chrome:// requested // Having chrome://favicon/* should not give you chrome://* extension = LoadManifestStrict("script_and_capture", "extension_chrome_favicon_wildcard.json"); - EXPECT_TRUE(Blocked(extension, settings_url)); - EXPECT_TRUE(Allowed(extension, favicon_url)); // chrome:// requested - EXPECT_TRUE(Blocked(extension, about_url)); - EXPECT_TRUE(PermissionsData::HasHostPermission(extension, favicon_url)); + EXPECT_TRUE(Blocked(extension.get(), settings_url)); + EXPECT_TRUE(Allowed(extension.get(), favicon_url)); // chrome:// requested + EXPECT_TRUE(Blocked(extension.get(), about_url)); + EXPECT_TRUE(PermissionsData::HasHostPermission(extension.get(), favicon_url)); // Having http://favicon should not give you chrome://favicon extension = LoadManifestStrict("script_and_capture", "extension_http_favicon.json"); - EXPECT_TRUE(Blocked(extension, settings_url)); - EXPECT_TRUE(Blocked(extension, favicon_url)); + EXPECT_TRUE(Blocked(extension.get(), settings_url)); + EXPECT_TRUE(Blocked(extension.get(), favicon_url)); // Component extensions with <all_urls> should get everything. extension = LoadManifest("script_and_capture", "extension_component_all.json", Manifest::COMPONENT, Extension::NO_FLAGS); - EXPECT_TRUE(Allowed(extension, http_url)); - EXPECT_TRUE(Allowed(extension, https_url)); - EXPECT_TRUE(Allowed(extension, settings_url)); - EXPECT_TRUE(Allowed(extension, about_url)); - EXPECT_TRUE(Allowed(extension, favicon_url)); - EXPECT_TRUE(PermissionsData::HasHostPermission(extension, favicon_url)); + EXPECT_TRUE(Allowed(extension.get(), http_url)); + EXPECT_TRUE(Allowed(extension.get(), https_url)); + EXPECT_TRUE(Allowed(extension.get(), settings_url)); + EXPECT_TRUE(Allowed(extension.get(), about_url)); + EXPECT_TRUE(Allowed(extension.get(), favicon_url)); + EXPECT_TRUE(PermissionsData::HasHostPermission(extension.get(), favicon_url)); // Component extensions should only get access to what they ask for. extension = LoadManifest("script_and_capture", "extension_component_google.json", Manifest::COMPONENT, Extension::NO_FLAGS); - EXPECT_TRUE(Allowed(extension, http_url)); - EXPECT_TRUE(Blocked(extension, https_url)); - EXPECT_TRUE(Blocked(extension, file_url)); - EXPECT_TRUE(Blocked(extension, settings_url)); - EXPECT_TRUE(Blocked(extension, favicon_url)); - EXPECT_TRUE(Blocked(extension, about_url)); - EXPECT_TRUE(Blocked(extension, extension_url)); - EXPECT_FALSE(PermissionsData::HasHostPermission(extension, settings_url)); + EXPECT_TRUE(Allowed(extension.get(), http_url)); + EXPECT_TRUE(Blocked(extension.get(), https_url)); + EXPECT_TRUE(Blocked(extension.get(), file_url)); + EXPECT_TRUE(Blocked(extension.get(), settings_url)); + EXPECT_TRUE(Blocked(extension.get(), favicon_url)); + EXPECT_TRUE(Blocked(extension.get(), about_url)); + EXPECT_TRUE(Blocked(extension.get(), extension_url)); + EXPECT_FALSE( + PermissionsData::HasHostPermission(extension.get(), settings_url)); } TEST_F(ExtensionScriptAndCaptureVisibleTest, TabSpecific) { scoped_refptr<Extension> extension = LoadManifestStrict("script_and_capture", "tab_specific.json"); - EXPECT_FALSE(PermissionsData::GetTabSpecificPermissions(extension, 0).get()); - EXPECT_FALSE(PermissionsData::GetTabSpecificPermissions(extension, 1).get()); - EXPECT_FALSE(PermissionsData::GetTabSpecificPermissions(extension, 2).get()); + EXPECT_FALSE(PermissionsData::GetTabSpecificPermissions(extension.get(), 0) + .get()); + EXPECT_FALSE(PermissionsData::GetTabSpecificPermissions(extension.get(), 1) + .get()); + EXPECT_FALSE(PermissionsData::GetTabSpecificPermissions(extension.get(), 2) + .get()); std::set<GURL> no_urls; - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 0)); - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 1)); - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 2)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), no_urls, 0)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), no_urls, 1)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), no_urls, 2)); URLPatternSet allowed_hosts; allowed_hosts.AddPattern(URLPattern(URLPattern::SCHEME_ALL, @@ -574,22 +579,24 @@ TEST_F(ExtensionScriptAndCaptureVisibleTest, TabSpecific) { { scoped_refptr<PermissionSet> permissions( new PermissionSet(APIPermissionSet(), allowed_hosts, URLPatternSet())); - PermissionsData::UpdateTabSpecificPermissions(extension, 0, permissions); + PermissionsData::UpdateTabSpecificPermissions( + extension.get(), 0, permissions); EXPECT_EQ(permissions->explicit_hosts(), - PermissionsData::GetTabSpecificPermissions( - extension, 0)->explicit_hosts()); + PermissionsData::GetTabSpecificPermissions(extension.get(), 0) + ->explicit_hosts()); } - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, allowed_urls, 0)); - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 1)); - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 2)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), allowed_urls, 0)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), no_urls, 1)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), no_urls, 2)); - PermissionsData::ClearTabSpecificPermissions(extension, 0); - EXPECT_FALSE(PermissionsData::GetTabSpecificPermissions(extension, 0).get()); + PermissionsData::ClearTabSpecificPermissions(extension.get(), 0); + EXPECT_FALSE(PermissionsData::GetTabSpecificPermissions(extension.get(), 0) + .get()); - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 0)); - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 1)); - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 2)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), no_urls, 0)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), no_urls, 1)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), no_urls, 2)); std::set<GURL> more_allowed_urls = allowed_urls; more_allowed_urls.insert(https_url); @@ -600,37 +607,41 @@ TEST_F(ExtensionScriptAndCaptureVisibleTest, TabSpecific) { { scoped_refptr<PermissionSet> permissions( new PermissionSet(APIPermissionSet(), allowed_hosts, URLPatternSet())); - PermissionsData::UpdateTabSpecificPermissions(extension, 0, permissions); + PermissionsData::UpdateTabSpecificPermissions( + extension.get(), 0, permissions); EXPECT_EQ(permissions->explicit_hosts(), - PermissionsData::GetTabSpecificPermissions( - extension, 0)->explicit_hosts()); + PermissionsData::GetTabSpecificPermissions(extension.get(), 0) + ->explicit_hosts()); permissions = new PermissionSet(APIPermissionSet(), more_allowed_hosts, URLPatternSet()); - PermissionsData::UpdateTabSpecificPermissions(extension, 1, permissions); + PermissionsData::UpdateTabSpecificPermissions( + extension.get(), 1, permissions); EXPECT_EQ(permissions->explicit_hosts(), - PermissionsData::GetTabSpecificPermissions( - extension, 1)->explicit_hosts()); + PermissionsData::GetTabSpecificPermissions(extension.get(), 1) + ->explicit_hosts()); } - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, allowed_urls, 0)); - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, more_allowed_urls, 1)); - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 2)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), allowed_urls, 0)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), more_allowed_urls, 1)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), no_urls, 2)); - PermissionsData::ClearTabSpecificPermissions(extension, 0); - EXPECT_FALSE(PermissionsData::GetTabSpecificPermissions(extension, 0).get()); + PermissionsData::ClearTabSpecificPermissions(extension.get(), 0); + EXPECT_FALSE(PermissionsData::GetTabSpecificPermissions(extension.get(), 0) + .get()); - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 0)); - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, more_allowed_urls, 1)); - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 2)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), no_urls, 0)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), more_allowed_urls, 1)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), no_urls, 2)); - PermissionsData::ClearTabSpecificPermissions(extension, 1); - EXPECT_FALSE(PermissionsData::GetTabSpecificPermissions(extension, 1).get()); + PermissionsData::ClearTabSpecificPermissions(extension.get(), 1); + EXPECT_FALSE(PermissionsData::GetTabSpecificPermissions(extension.get(), 1) + .get()); - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 0)); - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 1)); - EXPECT_TRUE(AllowedExclusivelyOnTab(extension, no_urls, 2)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), no_urls, 0)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), no_urls, 1)); + EXPECT_TRUE(AllowedExclusivelyOnTab(extension.get(), no_urls, 2)); } } // namespace extensions diff --git a/chrome/common/extensions/unpacker.cc b/chrome/common/extensions/unpacker.cc index 0cf8d94..5d055c5 100644 --- a/chrome/common/extensions/unpacker.cc +++ b/chrome/common/extensions/unpacker.cc @@ -197,17 +197,18 @@ bool Unpacker::Run() { // Decode any images that the browser needs to display. std::set<base::FilePath> image_paths = - extension_file_util::GetBrowserImagePaths(extension); + extension_file_util::GetBrowserImagePaths(extension.get()); for (std::set<base::FilePath>::iterator it = image_paths.begin(); - it != image_paths.end(); ++it) { + it != image_paths.end(); + ++it) { if (!AddDecodedImage(*it)) return false; // Error was already reported. } // Parse all message catalogs (if any). parsed_catalogs_.reset(new DictionaryValue); - if (!LocaleInfo::GetDefaultLocale(extension).empty()) { - if (!ReadAllMessageCatalogs(LocaleInfo::GetDefaultLocale(extension))) + if (!LocaleInfo::GetDefaultLocale(extension.get()).empty()) { + if (!ReadAllMessageCatalogs(LocaleInfo::GetDefaultLocale(extension.get()))) return false; // Error was already reported. } diff --git a/chrome/common/net/x509_certificate_model_unittest.cc b/chrome/common/net/x509_certificate_model_unittest.cc index cd305a3..40e2834 100644 --- a/chrome/common/net/x509_certificate_model_unittest.cc +++ b/chrome/common/net/x509_certificate_model_unittest.cc @@ -28,7 +28,7 @@ TEST(X509CertificateModelTest, GetTypeCA) { // Test that explicitly distrusted CA certs are still returned as CA_CERT // type. See http://crbug.com/96654. EXPECT_TRUE(net::NSSCertDatabase::GetInstance()->SetCertTrust( - cert, net::CA_CERT, net::NSSCertDatabase::DISTRUSTED_SSL)); + cert.get(), net::CA_CERT, net::NSSCertDatabase::DISTRUSTED_SSL)); EXPECT_EQ(net::CA_CERT, x509_certificate_model::GetType(cert->os_cert_handle())); @@ -56,14 +56,14 @@ TEST(X509CertificateModelTest, GetTypeServer) { net::NSSCertDatabase* cert_db = net::NSSCertDatabase::GetInstance(); // Test GetCertType with server certs and explicit trust. EXPECT_TRUE(cert_db->SetCertTrust( - cert, net::SERVER_CERT, net::NSSCertDatabase::TRUSTED_SSL)); + cert.get(), net::SERVER_CERT, net::NSSCertDatabase::TRUSTED_SSL)); EXPECT_EQ(net::SERVER_CERT, x509_certificate_model::GetType(cert->os_cert_handle())); // Test GetCertType with server certs and explicit distrust. EXPECT_TRUE(cert_db->SetCertTrust( - cert, net::SERVER_CERT, net::NSSCertDatabase::DISTRUSTED_SSL)); + cert.get(), net::SERVER_CERT, net::NSSCertDatabase::DISTRUSTED_SSL)); EXPECT_EQ(net::SERVER_CERT, x509_certificate_model::GetType(cert->os_cert_handle())); diff --git a/chrome/nacl/nacl_ipc_adapter.cc b/chrome/nacl/nacl_ipc_adapter.cc index 45222ae..664b90c 100644 --- a/chrome/nacl/nacl_ipc_adapter.cc +++ b/chrome/nacl/nacl_ipc_adapter.cc @@ -417,7 +417,7 @@ bool NaClIPCAdapter::OnMessageReceived(const IPC::Message& msg) { IPC::ChannelHandle channel_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); scoped_refptr<NaClIPCAdapter> ipc_adapter( - new NaClIPCAdapter(channel_handle, task_runner_)); + new NaClIPCAdapter(channel_handle, task_runner_.get())); ipc_adapter->ConnectChannel(); #if defined(OS_POSIX) channel_handle.socket = base::FileDescriptor( diff --git a/chrome/nacl/nacl_ipc_adapter_unittest.cc b/chrome/nacl/nacl_ipc_adapter_unittest.cc index 9258bd1..1a2db8b 100644 --- a/chrome/nacl/nacl_ipc_adapter_unittest.cc +++ b/chrome/nacl/nacl_ipc_adapter_unittest.cc @@ -286,7 +286,7 @@ TEST_F(NaClIPCAdapterTest, ReadWithChannelError) { private: scoped_refptr<NaClIPCAdapter> adapter_; }; - MyThread thread(adapter_); + MyThread thread(adapter_.get()); // IMPORTANT: do not return early from here down (including ASSERT_*) because // the thread needs to joined or it will assert. diff --git a/chrome/renderer/extensions/chrome_v8_context.cc b/chrome/renderer/extensions/chrome_v8_context.cc index 47171c8..7930af2 100644 --- a/chrome/renderer/extensions/chrome_v8_context.cc +++ b/chrome/renderer/extensions/chrome_v8_context.cc @@ -64,7 +64,7 @@ void ChromeV8Context::Invalidate() { } std::string ChromeV8Context::GetExtensionID() { - return extension_ ? extension_->id() : std::string(); + return extension_.get() ? extension_->id() : std::string(); } // static @@ -165,7 +165,7 @@ Feature::Availability ChromeV8Context::GetAvailability( const std::string& api_name) { return ExtensionAPI::GetSharedInstance()->IsAvailable( api_name, - extension_, + extension_.get(), context_type_, UserScriptSlave::GetDataSourceURLForFrame(web_frame_)); } diff --git a/chrome/renderer/extensions/dispatcher.cc b/chrome/renderer/extensions/dispatcher.cc index 13778fe..7d0d01f 100644 --- a/chrome/renderer/extensions/dispatcher.cc +++ b/chrome/renderer/extensions/dispatcher.cc @@ -617,7 +617,7 @@ void Dispatcher::OnLoaded( for (i = loaded_extensions.begin(); i != loaded_extensions.end(); ++i) { std::string error; scoped_refptr<const Extension> extension = i->ConvertToExtension(&error); - if (!extension) { + if (!extension.get()) { extension_load_errors_[i->id] = error; continue; } @@ -1272,10 +1272,11 @@ void Dispatcher::OnUpdatePermissions(int reason_id, const PermissionSet* new_active = NULL; switch (reason) { case UpdatedExtensionPermissionsInfo::ADDED: - new_active = PermissionSet::CreateUnion(old_active, delta); + new_active = PermissionSet::CreateUnion(old_active.get(), delta.get()); break; case UpdatedExtensionPermissionsInfo::REMOVED: - new_active = PermissionSet::CreateDifference(old_active, delta); + new_active = + PermissionSet::CreateDifference(old_active.get(), delta.get()); break; } diff --git a/chrome/renderer/extensions/renderer_permissions_policy_delegate_unittest.cc b/chrome/renderer/extensions/renderer_permissions_policy_delegate_unittest.cc index 0da26f3..4d5d003 100644 --- a/chrome/renderer/extensions/renderer_permissions_policy_delegate_unittest.cc +++ b/chrome/renderer/extensions/renderer_permissions_policy_delegate_unittest.cc @@ -56,23 +56,13 @@ TEST_F(RendererPermissionsPolicyDelegateTest, CannotScriptSigninProcess) { scoped_refptr<const Extension> extension(CreateTestExtension("a")); std::string error; - EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage(extension, - kSigninUrl, - kSigninUrl, - -1, - NULL, - -1, - &error)) << error; + EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage( + extension.get(), kSigninUrl, kSigninUrl, -1, NULL, -1, &error)) << error; // Pretend we are in the signin process. We should not be able to execute // script. CommandLine::ForCurrentProcess()->AppendSwitch(switches::kSigninProcess); - EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage(extension, - kSigninUrl, - kSigninUrl, - -1, - NULL, - -1, - &error)) << error; + EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( + extension.get(), kSigninUrl, kSigninUrl, -1, NULL, -1, &error)) << error; } // Tests that CanExecuteScriptOnPage returns false for the any process @@ -82,13 +72,8 @@ TEST_F(RendererPermissionsPolicyDelegateTest, CannotScriptWebstore) { scoped_refptr<const Extension> extension(CreateTestExtension("a")); std::string error; - EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage(extension, - kAnyUrl, - kAnyUrl, - -1, - NULL, - -1, - &error)) << error; + EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage( + extension.get(), kAnyUrl, kAnyUrl, -1, NULL, -1, &error)) << error; // Pretend we are in the webstore process. We should not be able to execute // script. @@ -96,13 +81,8 @@ TEST_F(RendererPermissionsPolicyDelegateTest, CannotScriptWebstore) { CreateTestExtension(extension_misc::kWebStoreAppId)); extension_dispatcher_->OnLoadedInternal(webstore_extension); extension_dispatcher_->OnActivateExtension(extension_misc::kWebStoreAppId); - EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage(extension, - kAnyUrl, - kAnyUrl, - -1, - NULL, - -1, - &error)) << error; + EXPECT_FALSE(PermissionsData::CanExecuteScriptOnPage( + extension.get(), kAnyUrl, kAnyUrl, -1, NULL, -1, &error)) << error; } } // namespace extensions diff --git a/chrome/renderer/mock_printer.cc b/chrome/renderer/mock_printer.cc index 2023e61..bf312b3 100644 --- a/chrome/renderer/mock_printer.cc +++ b/chrome/renderer/mock_printer.cc @@ -250,7 +250,7 @@ int MockPrinter::GetPrintedPages() const { const MockPrinterPage* MockPrinter::GetPrintedPage(unsigned int pageno) const { if (pages_.size() > pageno) - return pages_[pageno]; + return pages_[pageno].get(); else return NULL; } diff --git a/chrome/renderer/pepper/ppb_pdf_impl.cc b/chrome/renderer/pepper/ppb_pdf_impl.cc index 6cb3bbe..e436a5f 100644 --- a/chrome/renderer/pepper/ppb_pdf_impl.cc +++ b/chrome/renderer/pepper/ppb_pdf_impl.cc @@ -203,7 +203,7 @@ PP_Resource GetFontFileWithFallback( scoped_refptr<ppapi::StringVar> face_name(ppapi::StringVar::FromPPVar( description->face)); - if (!face_name) + if (!face_name.get()) return 0; int fd = content::MatchFontWithFallback( @@ -322,7 +322,7 @@ void HistogramPDFPageCount(PP_Instance /*instance*/, int count) { void UserMetricsRecordAction(PP_Instance /*instance*/, PP_Var action) { scoped_refptr<ppapi::StringVar> action_str( ppapi::StringVar::FromPPVar(action)); - if (action_str) + if (action_str.get()) RenderThread::Get()->RecordUserMetrics(action_str->value()); } @@ -403,7 +403,7 @@ PP_Resource GetResourceImageForScale(PP_Instance instance_id, return 0; } - webkit::ppapi::ImageDataAutoMapper mapper(image_data); + webkit::ppapi::ImageDataAutoMapper mapper(image_data.get()); if (!mapper.is_valid()) return 0; diff --git a/chrome/service/cloud_print/cloud_print_proxy_backend.cc b/chrome/service/cloud_print/cloud_print_proxy_backend.cc index 95c30e6..84084f4 100644 --- a/chrome/service/cloud_print/cloud_print_proxy_backend.cc +++ b/chrome/service/cloud_print/cloud_print_proxy_backend.cc @@ -175,9 +175,7 @@ CloudPrintProxyBackend::CloudPrintProxyBackend( core_ = new Core(this, settings, oauth_client_info, enable_job_poll); } -CloudPrintProxyBackend::~CloudPrintProxyBackend() { - DCHECK(!core_); -} +CloudPrintProxyBackend::~CloudPrintProxyBackend() { DCHECK(!core_.get()); } bool CloudPrintProxyBackend::InitializeWithLsid( const std::string& lsid, diff --git a/chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc b/chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc index 27c6b01..1d66991 100644 --- a/chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc +++ b/chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc @@ -220,7 +220,7 @@ void CloudPrintURLFetcherTest::CreateFetcher(const GURL& url, int max_retries) { scoped_refptr<net::URLRequestThrottlerEntry> entry(new net::URLRequestThrottlerEntry( fetcher_->throttler_manager(), std::string(), 200, 3, 1, 2.0, 0.0, 256)); - fetcher_->throttler_manager()->OverrideEntryForTests(url, entry); + fetcher_->throttler_manager()->OverrideEntryForTests(url, entry.get()); max_retries_ = max_retries; start_time_ = Time::Now(); diff --git a/chrome/service/cloud_print/connector_settings_unittest.cc b/chrome/service/cloud_print/connector_settings_unittest.cc index b43ae9a..7616e63 100644 --- a/chrome/service/cloud_print/connector_settings_unittest.cc +++ b/chrome/service/cloud_print/connector_settings_unittest.cc @@ -63,7 +63,7 @@ class ConnectorSettingsTest : public testing::Test { file_util::WriteFile(file_name, content.c_str(), content.size()); } ServiceProcessPrefs* prefs = - new ServiceProcessPrefs(file_name, message_loop_proxy_); + new ServiceProcessPrefs(file_name, message_loop_proxy_.get()); prefs->ReadPrefs(); return prefs; } diff --git a/chrome/service/cloud_print/printer_job_handler.cc b/chrome/service/cloud_print/printer_job_handler.cc index 74542a18..1bc305a 100644 --- a/chrome/service/cloud_print/printer_job_handler.cc +++ b/chrome/service/cloud_print/printer_job_handler.cc @@ -222,7 +222,7 @@ void PrinterJobHandler::OnJobSpoolFailed() { } PrinterJobHandler::~PrinterJobHandler() { - if (printer_watcher_) + if (printer_watcher_.get()) printer_watcher_->StopWatching(); } @@ -538,7 +538,7 @@ void PrinterJobHandler::JobSpooled(PlatformJobId local_job_id) { } bool PrinterJobHandler::UpdatePrinterInfo() { - if (!printer_watcher_) { + if (!printer_watcher_.get()) { LOG(ERROR) << "CP_CONNECTOR: Printer watcher is missing." << " Check printer server url for printer id: " << printer_info_cloud_.printer_id; @@ -583,7 +583,7 @@ void PrinterJobHandler::OnReceivePrinterCaps( const std::string& printer_name, const printing::PrinterCapsAndDefaults& caps_and_defaults) { printing::PrinterBasicInfo printer_info; - if (printer_watcher_) + if (printer_watcher_.get()) printer_watcher_->GetCurrentPrinterInfo(&printer_info); std::string post_data; @@ -666,8 +666,8 @@ void PrinterJobHandler::OnReceivePrinterCaps( void PrinterJobHandler::DoPrint(const JobDetails& job_details, const std::string& printer_name) { job_spooler_ = print_system_->CreateJobSpooler(); - DCHECK(job_spooler_); - if (!job_spooler_) + DCHECK(job_spooler_.get()); + if (!job_spooler_.get()) return; string16 document_name = printing::PrintBackend::SimplifyDocumentTitle( diff --git a/chrome/service/cloud_print/printer_job_handler_unittest.cc b/chrome/service/cloud_print/printer_job_handler_unittest.cc index 2535810..3f21f88 100644 --- a/chrome/service/cloud_print/printer_job_handler_unittest.cc +++ b/chrome/service/cloud_print/printer_job_handler_unittest.cc @@ -385,16 +385,12 @@ class MockPrintSystem : public PrintSystem { return PrintSystem::PrintSystemResult(false, "failure"); } - MockJobSpooler& JobSpooler() { - return *job_spooler_; - } + MockJobSpooler& JobSpooler() { return *job_spooler_.get(); } - MockPrinterWatcher& PrinterWatcher() { - return *printer_watcher_; - } + MockPrinterWatcher& PrinterWatcher() { return *printer_watcher_.get(); } MockPrintServerWatcher& PrintServerWatcher() { - return *print_server_watcher_; + return *print_server_watcher_.get(); } MOCK_METHOD0(Init, PrintSystem::PrintSystemResult()); @@ -491,7 +487,7 @@ void PrinterJobHandlerTest::SetUp() { ON_CALL(print_system_->PrinterWatcher(), GetCurrentPrinterInfo(_)) .WillByDefault(Invoke(this, &PrinterJobHandlerTest::GetPrinterInfo)); - ON_CALL(*print_system_, GetPrinterCapsAndDefaults(_, _)) + ON_CALL(*print_system_.get(), GetPrinterCapsAndDefaults(_, _)) .WillByDefault(Invoke(this, &PrinterJobHandlerTest::SendCapsAndDefaults)); CloudPrintURLFetcher::set_factory(&cloud_print_factory_); @@ -580,9 +576,11 @@ void PrinterJobHandlerTest::SetUpJobSuccessTest(int job_num) { } void PrinterJobHandlerTest::BeginTest(int timeout_seconds) { - job_handler_ = new PrinterJobHandler(basic_info_, info_from_cloud_, + job_handler_ = new PrinterJobHandler(basic_info_, + info_from_cloud_, GURL(kExampleCloudPrintServerURL), - print_system_, &jobhandler_delegate_); + print_system_.get(), + &jobhandler_delegate_); job_handler_->Initialize(); diff --git a/chrome/service/gaia/service_gaia_authenticator.cc b/chrome/service/gaia/service_gaia_authenticator.cc index c2417a2..e46cbc7 100644 --- a/chrome/service/gaia/service_gaia_authenticator.cc +++ b/chrome/service/gaia/service_gaia_authenticator.cc @@ -41,7 +41,7 @@ bool ServiceGaiaAuthenticator::Post(const GURL& url, unsigned long* response_code, std::string* response_body) { DCHECK(url.SchemeIsSecure()); - DCHECK(io_message_loop_proxy_); + DCHECK(io_message_loop_proxy_.get()); io_message_loop_proxy_->PostTask( FROM_HERE, base::Bind(&ServiceGaiaAuthenticator::DoPost, this, url, post_body)); diff --git a/chrome/service/net/service_url_request_context.cc b/chrome/service/net/service_url_request_context.cc index 7d32da9..809c4ed 100644 --- a/chrome/service/net/service_url_request_context.cc +++ b/chrome/service/net/service_url_request_context.cc @@ -129,10 +129,8 @@ ServiceURLRequestContext::ServiceURLRequestContext( session_params.http_server_properties = http_server_properties(); scoped_refptr<net::HttpNetworkSession> network_session( new net::HttpNetworkSession(session_params)); - storage_.set_http_transaction_factory( - new net::HttpCache( - network_session, - net::HttpCache::DefaultBackend::InMemory(0))); + storage_.set_http_transaction_factory(new net::HttpCache( + network_session.get(), net::HttpCache::DefaultBackend::InMemory(0))); // In-memory cookie store. storage_.set_cookie_store(new net::CookieMonster(NULL, NULL)); storage_.set_http_user_agent_settings(new net::StaticHttpUserAgentSettings( diff --git a/chrome/service/service_ipc_server.h b/chrome/service/service_ipc_server.h index 7fd5d61..52a6432 100644 --- a/chrome/service/service_ipc_server.h +++ b/chrome/service/service_ipc_server.h @@ -36,7 +36,9 @@ class ServiceIPCServer : public IPC::Listener, public IPC::Sender { // Safe to call on any thread, as long as it's guaranteed that the thread's // lifetime is less than the main thread. - IPC::SyncMessageFilter* sync_message_filter() { return sync_message_filter_; } + IPC::SyncMessageFilter* sync_message_filter() { + return sync_message_filter_.get(); + } bool is_client_connected() const { return client_connected_; } diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc index 350629d..ab7fa73 100644 --- a/chrome/service/service_process.cc +++ b/chrome/service/service_process.cc @@ -161,10 +161,9 @@ bool ServiceProcess::Initialize(base::MessageLoopForUI* message_loop, PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); base::FilePath pref_path = user_data_dir.Append(chrome::kServiceStateFileName); - service_prefs_.reset( - new ServiceProcessPrefs( - pref_path, - JsonPrefStore::GetTaskRunnerForFile(pref_path, blocking_pool_))); + service_prefs_.reset(new ServiceProcessPrefs( + pref_path, + JsonPrefStore::GetTaskRunnerForFile(pref_path, blocking_pool_.get()))); service_prefs_->ReadPrefs(); // This switch it required to run connector with test gaia. diff --git a/chrome/test/automation/automation_handle_tracker.cc b/chrome/test/automation/automation_handle_tracker.cc index 6f01e7b..09c6750 100644 --- a/chrome/test/automation/automation_handle_tracker.cc +++ b/chrome/test/automation/automation_handle_tracker.cc @@ -68,5 +68,5 @@ AutomationResourceProxy* AutomationHandleTracker::GetResource( return NULL; iter->second->AddRef(); - return iter->second; + return iter->second.get(); } diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc index f4a7475..b3ad1cd 100644 --- a/chrome/test/base/testing_profile.cc +++ b/chrome/test/base/testing_profile.cc @@ -328,7 +328,7 @@ TestingProfile::~TestingProfile() { browser_context_dependency_manager_->DestroyBrowserContextServices(this); - if (host_content_settings_map_) + if (host_content_settings_map_.get()) host_content_settings_map_->ShutdownOnUIThread(); DestroyTopSites(); @@ -616,10 +616,9 @@ net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess( } void TestingProfile::CreateRequestContext() { - if (!request_context_) - request_context_ = - new net::TestURLRequestContextGetter( - BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); + if (!request_context_.get()) + request_context_ = new net::TestURLRequestContextGetter( + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); } void TestingProfile::ResetRequestContext() { @@ -648,7 +647,7 @@ TestingProfile::GetMediaRequestContextForStoragePartition( } net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() { - if (!extensions_request_context_) + if (!extensions_request_context_.get()) extensions_request_context_ = new TestExtensionURLRequestContextGetter(); return extensions_request_context_.get(); } diff --git a/chrome/test/base/web_ui_browsertest.cc b/chrome/test/base/web_ui_browsertest.cc index 3dfb5d8..082338b 100644 --- a/chrome/test/base/web_ui_browsertest.cc +++ b/chrome/test/base/web_ui_browsertest.cc @@ -343,7 +343,7 @@ class MockWebUIDataSource : public content::URLDataSource { std::string dummy_html = "<html><body>Dummy</body></html>"; scoped_refptr<base::RefCountedString> response = base::RefCountedString::TakeString(&dummy_html); - callback.Run(response); + callback.Run(response.get()); } virtual std::string GetMimeType(const std::string& path) const OVERRIDE { diff --git a/chrome/test/chromedriver/chrome/devtools_http_client.cc b/chrome/test/chromedriver/chrome/devtools_http_client.cc index 0d74aff..ce76661 100644 --- a/chrome/test/chromedriver/chrome/devtools_http_client.cc +++ b/chrome/test/chromedriver/chrome/devtools_http_client.cc @@ -78,7 +78,8 @@ DevToolsHttpClient::~DevToolsHttpClient() {} Status DevToolsHttpClient::GetVersion(std::string* version) { std::string data; - if (!FetchUrlAndLog(server_url_ + "/json/version", context_getter_, &data)) + if (!FetchUrlAndLog( + server_url_ + "/json/version", context_getter_.get(), &data)) return Status(kChromeNotReachable); return internal::ParseVersionInfo(data, version); @@ -86,7 +87,7 @@ Status DevToolsHttpClient::GetVersion(std::string* version) { Status DevToolsHttpClient::GetWebViewsInfo(WebViewsInfo* views_info) { std::string data; - if (!FetchUrlAndLog(server_url_ + "/json", context_getter_, &data)) + if (!FetchUrlAndLog(server_url_ + "/json", context_getter_.get(), &data)) return Status(kChromeNotReachable); return internal::ParseWebViewsInfo(data, views_info); @@ -106,7 +107,7 @@ scoped_ptr<DevToolsClient> DevToolsHttpClient::CreateClient( Status DevToolsHttpClient::CloseWebView(const std::string& id) { std::string data; if (!FetchUrlAndLog( - server_url_ + "/json/close/" + id, context_getter_, &data)) { + server_url_ + "/json/close/" + id, context_getter_.get(), &data)) { return Status(kOk); // Closing the last web view leads chrome to quit. } diff --git a/chrome/test/chromedriver/command_executor_impl.cc b/chrome/test/chromedriver/command_executor_impl.cc index 3e8ef99..ea06b7f 100644 --- a/chrome/test/chromedriver/command_executor_impl.cc +++ b/chrome/test/chromedriver/command_executor_impl.cc @@ -50,7 +50,7 @@ void CommandExecutorImpl::Init() { CHECK(io_thread_.StartWithOptions(options)); context_getter_ = new URLRequestContextGetter( io_thread_.message_loop_proxy()); - socket_factory_ = CreateSyncWebSocketFactory(context_getter_); + socket_factory_ = CreateSyncWebSocketFactory(context_getter_.get()); adb_.reset(new AdbImpl(io_thread_.message_loop_proxy(), log_)); device_manager_.reset(new DeviceManager(adb_.get())); diff --git a/chrome/test/chromedriver/commands.cc b/chrome/test/chromedriver/commands.cc index fbf1bf96..5c41228 100644 --- a/chrome/test/chromedriver/commands.cc +++ b/chrome/test/chromedriver/commands.cc @@ -88,7 +88,7 @@ Status ExecuteNewSession( return status; scoped_ptr<Chrome> chrome; - status = LaunchChrome(bound_params.context_getter, + status = LaunchChrome(bound_params.context_getter.get(), port, bound_params.socket_factory, bound_params.log, diff --git a/chrome/test/chromedriver/net/adb_client_socket.cc b/chrome/test/chromedriver/net/adb_client_socket.cc index 144fa79..41b6d6b 100644 --- a/chrome/test/chromedriver/net/adb_client_socket.cc +++ b/chrome/test/chromedriver/net/adb_client_socket.cc @@ -141,7 +141,9 @@ class HttpOverAdbSocket { scoped_refptr<net::StringIOBuffer> request_buffer = new net::StringIOBuffer(request_); - result = socket_->Write(request_buffer, request_buffer->size(), + result = socket_->Write( + request_buffer.get(), + request_buffer->size(), base::Bind(&HttpOverAdbSocket::ReadResponse, base::Unretained(this))); if (result != net::ERR_IO_PENDING) ReadResponse(result); @@ -154,9 +156,12 @@ class HttpOverAdbSocket { scoped_refptr<net::IOBuffer> response_buffer = new net::IOBuffer(kBufferSize); - result = socket_->Read(response_buffer, kBufferSize, - base::Bind(&HttpOverAdbSocket::OnResponseData, base::Unretained(this), - response_buffer, -1)); + result = socket_->Read(response_buffer.get(), + kBufferSize, + base::Bind(&HttpOverAdbSocket::OnResponseData, + base::Unretained(this), + response_buffer, + -1)); if (result != net::ERR_IO_PENDING) OnResponseData(response_buffer, -1, result); } @@ -204,9 +209,12 @@ class HttpOverAdbSocket { return; } - result = socket_->Read(response_buffer, kBufferSize, - base::Bind(&HttpOverAdbSocket::OnResponseData, base::Unretained(this), - response_buffer, bytes_total)); + result = socket_->Read(response_buffer.get(), + kBufferSize, + base::Bind(&HttpOverAdbSocket::OnResponseData, + base::Unretained(this), + response_buffer, + bytes_total)); if (result != net::ERR_IO_PENDING) OnResponseData(response_buffer, bytes_total, result); } @@ -376,9 +384,12 @@ void AdbClientSocket::SendCommand(const std::string& command, const CommandCallback& callback) { scoped_refptr<net::StringIOBuffer> request_buffer = new net::StringIOBuffer(EncodeMessage(command)); - int result = socket_->Write(request_buffer, request_buffer->size(), - base::Bind(&AdbClientSocket::ReadResponse, base::Unretained(this), - callback, is_void)); + int result = socket_->Write(request_buffer.get(), + request_buffer->size(), + base::Bind(&AdbClientSocket::ReadResponse, + base::Unretained(this), + callback, + is_void)); if (result != net::ERR_IO_PENDING) ReadResponse(callback, is_void, result); } @@ -392,9 +403,13 @@ void AdbClientSocket::ReadResponse(const CommandCallback& callback, } scoped_refptr<net::IOBuffer> response_buffer = new net::IOBuffer(kBufferSize); - result = socket_->Read(response_buffer, kBufferSize, - base::Bind(&AdbClientSocket::OnResponseHeader, base::Unretained(this), - callback, is_void, response_buffer)); + result = socket_->Read(response_buffer.get(), + kBufferSize, + base::Bind(&AdbClientSocket::OnResponseHeader, + base::Unretained(this), + callback, + is_void, + response_buffer)); if (result != net::ERR_IO_PENDING) OnResponseHeader(callback, is_void, response_buffer, result); } @@ -460,9 +475,14 @@ void AdbClientSocket::OnResponseData( } // Read tail - result = socket_->Read(response_buffer, kBufferSize, - base::Bind(&AdbClientSocket::OnResponseData, base::Unretained(this), - callback, new_response, response_buffer, bytes_left)); + result = socket_->Read(response_buffer.get(), + kBufferSize, + base::Bind(&AdbClientSocket::OnResponseData, + base::Unretained(this), + callback, + new_response, + response_buffer, + bytes_left)); if (result > 0) OnResponseData(callback, new_response, response_buffer, bytes_left, result); else if (result != net::ERR_IO_PENDING) diff --git a/chrome/test/chromedriver/net/net_util_unittest.cc b/chrome/test/chromedriver/net/net_util_unittest.cc index f057390..480768d 100644 --- a/chrome/test/chromedriver/net/net_util_unittest.cc +++ b/chrome/test/chromedriver/net/net_util_unittest.cc @@ -113,26 +113,27 @@ class FetchUrlTest : public testing::Test, TEST_F(FetchUrlTest, Http200) { std::string response("stuff"); - ASSERT_TRUE(FetchUrl(server_url_, context_getter_, &response)); + ASSERT_TRUE(FetchUrl(server_url_, context_getter_.get(), &response)); ASSERT_STREQ("hello", response.c_str()); } TEST_F(FetchUrlTest, HttpNon200) { response_ = kSend404; std::string response("stuff"); - ASSERT_FALSE(FetchUrl(server_url_, context_getter_, &response)); + ASSERT_FALSE(FetchUrl(server_url_, context_getter_.get(), &response)); ASSERT_STREQ("stuff", response.c_str()); } TEST_F(FetchUrlTest, ConnectionClose) { response_ = kClose; std::string response("stuff"); - ASSERT_FALSE(FetchUrl(server_url_, context_getter_, &response)); + ASSERT_FALSE(FetchUrl(server_url_, context_getter_.get(), &response)); ASSERT_STREQ("stuff", response.c_str()); } TEST_F(FetchUrlTest, NoServer) { std::string response("stuff"); - ASSERT_FALSE(FetchUrl("http://localhost:33333", context_getter_, &response)); + ASSERT_FALSE( + FetchUrl("http://localhost:33333", context_getter_.get(), &response)); ASSERT_STREQ("stuff", response.c_str()); } diff --git a/chrome/test/chromedriver/net/sync_websocket_factory.cc b/chrome/test/chromedriver/net/sync_websocket_factory.cc index 8759cbb..77c31f0 100644 --- a/chrome/test/chromedriver/net/sync_websocket_factory.cc +++ b/chrome/test/chromedriver/net/sync_websocket_factory.cc @@ -13,7 +13,7 @@ namespace { scoped_ptr<SyncWebSocket> CreateSyncWebSocket( scoped_refptr<URLRequestContextGetter> context_getter) { - return scoped_ptr<SyncWebSocket>(new SyncWebSocketImpl(context_getter)); + return scoped_ptr<SyncWebSocket>(new SyncWebSocketImpl(context_getter.get())); } } // namespace diff --git a/chrome/test/chromedriver/net/sync_websocket_impl_unittest.cc b/chrome/test/chromedriver/net/sync_websocket_impl_unittest.cc index 8ec017c..5438a93 100644 --- a/chrome/test/chromedriver/net/sync_websocket_impl_unittest.cc +++ b/chrome/test/chromedriver/net/sync_websocket_impl_unittest.cc @@ -47,21 +47,21 @@ class SyncWebSocketImplTest : public testing::Test { } // namespace TEST_F(SyncWebSocketImplTest, CreateDestroy) { - SyncWebSocketImpl sock(context_getter_); + SyncWebSocketImpl sock(context_getter_.get()); } TEST_F(SyncWebSocketImplTest, Connect) { - SyncWebSocketImpl sock(context_getter_); + SyncWebSocketImpl sock(context_getter_.get()); ASSERT_TRUE(sock.Connect(server_.web_socket_url())); } TEST_F(SyncWebSocketImplTest, ConnectFail) { - SyncWebSocketImpl sock(context_getter_); + SyncWebSocketImpl sock(context_getter_.get()); ASSERT_FALSE(sock.Connect(GURL("ws://127.0.0.1:33333"))); } TEST_F(SyncWebSocketImplTest, SendReceive) { - SyncWebSocketImpl sock(context_getter_); + SyncWebSocketImpl sock(context_getter_.get()); ASSERT_TRUE(sock.Connect(server_.web_socket_url())); ASSERT_TRUE(sock.Send("hi")); std::string message; @@ -70,7 +70,7 @@ TEST_F(SyncWebSocketImplTest, SendReceive) { } TEST_F(SyncWebSocketImplTest, SendReceiveLarge) { - SyncWebSocketImpl sock(context_getter_); + SyncWebSocketImpl sock(context_getter_.get()); ASSERT_TRUE(sock.Connect(server_.web_socket_url())); std::string wrote_message(10 << 20, 'a'); ASSERT_TRUE(sock.Send(wrote_message)); @@ -81,7 +81,7 @@ TEST_F(SyncWebSocketImplTest, SendReceiveLarge) { } TEST_F(SyncWebSocketImplTest, SendReceiveMany) { - SyncWebSocketImpl sock(context_getter_); + SyncWebSocketImpl sock(context_getter_.get()); ASSERT_TRUE(sock.Connect(server_.web_socket_url())); ASSERT_TRUE(sock.Send("1")); ASSERT_TRUE(sock.Send("2")); @@ -97,7 +97,7 @@ TEST_F(SyncWebSocketImplTest, SendReceiveMany) { TEST_F(SyncWebSocketImplTest, CloseOnReceive) { server_.SetMessageAction(TestHttpServer::kCloseOnMessage); - SyncWebSocketImpl sock(context_getter_); + SyncWebSocketImpl sock(context_getter_.get()); ASSERT_TRUE(sock.Connect(server_.web_socket_url())); ASSERT_TRUE(sock.Send("1")); std::string message; @@ -106,14 +106,14 @@ TEST_F(SyncWebSocketImplTest, CloseOnReceive) { } TEST_F(SyncWebSocketImplTest, CloseOnSend) { - SyncWebSocketImpl sock(context_getter_); + SyncWebSocketImpl sock(context_getter_.get()); ASSERT_TRUE(sock.Connect(server_.web_socket_url())); server_.Stop(); ASSERT_FALSE(sock.Send("1")); } TEST_F(SyncWebSocketImplTest, Reconnect) { - SyncWebSocketImpl sock(context_getter_); + SyncWebSocketImpl sock(context_getter_.get()); ASSERT_TRUE(sock.Connect(server_.web_socket_url())); ASSERT_TRUE(sock.Send("1")); // Wait for SyncWebSocket to receive the response from the server. diff --git a/chrome/test/chromedriver/net/test_http_server.cc b/chrome/test/chromedriver/net/test_http_server.cc index a71d87f..17686bd 100644 --- a/chrome/test/chromedriver/net/test_http_server.cc +++ b/chrome/test/chromedriver/net/test_http_server.cc @@ -141,12 +141,12 @@ void TestHttpServer::StartOnServerThread(bool* success, } else { server_ = NULL; } - *success = server_; + *success = server_.get(); event->Signal(); } void TestHttpServer::StopOnServerThread(base::WaitableEvent* event) { - if (server_) + if (server_.get()) server_ = NULL; event->Signal(); } diff --git a/chrome/test/chromedriver/net/websocket.cc b/chrome/test/chromedriver/net/websocket.cc index b48c6a3..82bab3c 100644 --- a/chrome/test/chromedriver/net/websocket.cc +++ b/chrome/test/chromedriver/net/websocket.cc @@ -128,19 +128,19 @@ void WebSocket::ContinueWritingIfNecessary() { pending_write_.length()); pending_write_.clear(); } - int code = socket_->Write( - write_buffer_, - write_buffer_->BytesRemaining(), - base::Bind(&WebSocket::OnWrite, base::Unretained(this))); + int code = + socket_->Write(write_buffer_.get(), + write_buffer_->BytesRemaining(), + base::Bind(&WebSocket::OnWrite, base::Unretained(this))); if (code != net::ERR_IO_PENDING) OnWrite(code); } void WebSocket::Read() { - int code = socket_->Read( - read_buffer_, - read_buffer_->size(), - base::Bind(&WebSocket::OnRead, base::Unretained(this))); + int code = + socket_->Read(read_buffer_.get(), + read_buffer_->size(), + base::Bind(&WebSocket::OnRead, base::Unretained(this))); if (code != net::ERR_IO_PENDING) OnRead(code); } @@ -196,7 +196,7 @@ void WebSocket::OnReadDuringOpen(const char* data, int len) { CHECK(parser_.Decode(data, len, &frame_chunks)); for (size_t i = 0; i < frame_chunks.size(); ++i) { scoped_refptr<net::IOBufferWithSize> buffer = frame_chunks[i]->data; - if (buffer) + if (buffer.get()) next_message_ += std::string(buffer->data(), buffer->size()); if (frame_chunks[i]->final_chunk) { listener_->OnMessageReceived(next_message_); diff --git a/chrome/test/perf/frame_rate/frame_rate_tests.cc b/chrome/test/perf/frame_rate/frame_rate_tests.cc index 7b36b27..d34388e 100644 --- a/chrome/test/perf/frame_rate/frame_rate_tests.cc +++ b/chrome/test/perf/frame_rate/frame_rate_tests.cc @@ -196,7 +196,7 @@ class FrameRateTest // race condition caused by an html redirect. If that is the case, verify // that flag kHasRedirect is enabled for the current test. ASSERT_TRUE(WaitUntilJavaScriptCondition( - tab, + tab.get(), std::wstring(), L"window.domAutomationController.send(__initialized);", TestTimeouts::large_test_timeout())); @@ -211,7 +211,7 @@ class FrameRateTest // Block until the tests completes. ASSERT_TRUE(WaitUntilJavaScriptCondition( - tab, + tab.get(), std::wstring(), L"window.domAutomationController.send(!__running_all);", TestTimeouts::large_test_timeout())); diff --git a/chrome/test/perf/perf_ui_test_suite.cc b/chrome/test/perf/perf_ui_test_suite.cc index 1f15015..0c6312d 100644 --- a/chrome/test/perf/perf_ui_test_suite.cc +++ b/chrome/test/perf/perf_ui_test_suite.cc @@ -153,7 +153,7 @@ void PerfUITestSuite::BuildCachedThemePakIn( *valid_value, Extension::NO_FLAGS, &error); - if (!extension) + if (!extension.get()) LOG(FATAL) << "Error loading theme extension: " << error; // Build the "Cached Theme.pak" file in the template. (It's not committed @@ -166,8 +166,8 @@ void PerfUITestSuite::BuildCachedThemePakIn( &message_loop_); scoped_refptr<BrowserThemePack> theme( - BrowserThemePack::BuildFromExtension(extension)); - if (!theme) + BrowserThemePack::BuildFromExtension(extension.get())); + if (!theme.get()) LOG(FATAL) << "Failed to load theme from extension"; theme->WriteToDisk(extension_base.AppendASCII("Cached Theme.pak")); diff --git a/chrome/test/reliability/automated_ui_test_base.cc b/chrome/test/reliability/automated_ui_test_base.cc index 426f0ae..541a0c6 100644 --- a/chrome/test/reliability/automated_ui_test_base.cc +++ b/chrome/test/reliability/automated_ui_test_base.cc @@ -74,7 +74,7 @@ bool AutomatedUITestBase::CloseActiveWindow() { scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(i)); Browser::Type type; if (browser->GetType(&type) && type == Browser::TYPE_TABBED) { - set_active_browser(browser); + set_active_browser(browser.get()); return true; } } diff --git a/chrome/test/reliability/page_load_test.cc b/chrome/test/reliability/page_load_test.cc index 158c01a..ac04c4b 100644 --- a/chrome/test/reliability/page_load_test.cc +++ b/chrome/test/reliability/page_load_test.cc @@ -748,7 +748,7 @@ class PageLoadTest : public UITest { registry->RegisterIntegerPref(prefs::kStabilityCrashCount, 0); registry->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); - scoped_ptr<PrefService> local_state(GetLocalState(registry)); + scoped_ptr<PrefService> local_state(GetLocalState(registry.get())); if (!local_state.get()) return; diff --git a/chrome/test/webdriver/webdriver_automation.cc b/chrome/test/webdriver/webdriver_automation.cc index 2715293..807c7d8 100644 --- a/chrome/test/webdriver/webdriver_automation.cc +++ b/chrome/test/webdriver/webdriver_automation.cc @@ -792,12 +792,12 @@ void Automation::NavigateToURLAsync(const WebViewId& view_id, } else { scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(view_locator.browser_index()); - if (!browser) { + if (!browser.get()) { *error = new Error(kUnknownError, "Couldn't obtain browser proxy"); return; } scoped_refptr<TabProxy> tab = browser->GetTab(view_locator.tab_index()); - if (!tab) { + if (!tab.get()) { *error = new Error(kUnknownError, "Couldn't obtain tab proxy"); return; } diff --git a/chrome/utility/profile_import_handler.cc b/chrome/utility/profile_import_handler.cc index f90b128..c1119ef 100644 --- a/chrome/utility/profile_import_handler.cc +++ b/chrome/utility/profile_import_handler.cc @@ -39,9 +39,9 @@ void ProfileImportHandler::OnImportStart( localized_strings, content::UtilityThread::Get(), base::MessageLoopProxy::current()); importer_ = importer::CreateImporterByType(source_profile.importer_type); - if (!importer_) { - Send(new ProfileImportProcessHostMsg_Import_Finished(false, - "Importer could not be created.")); + if (!importer_.get()) { + Send(new ProfileImportProcessHostMsg_Import_Finished( + false, "Importer could not be created.")); return; } |