Revert 113047 - Make ExtensionService use ExtensionSet.
It broke ExtensionManagementApiBrowserTest.LaunchApp. Make ExtensionSet iterate like a set instead of a map. BUG=104091 TEST=existing tests Review URL: http://codereview.chromium.org/8733004 TBR=yoz@chromium.org Review URL: http://codereview.chromium.org/8789018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113071 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
chrome
browser
autocomplete
automation
background
background_application_list_model.ccbackground_application_list_model_unittest.ccbackground_contents_service.cc
debugger
extensions
browser_action_apitest.cccomponent_loader_unittest.ccextension_apitest.ccextension_browsertest.ccextension_browsertests_misc.ccextension_context_menu_browsertest.ccextension_crash_recovery_browsertest.ccextension_file_browser_private_api.ccextension_info_map.ccextension_management_api.ccextension_management_browsertest.ccextension_override_apitest.ccextension_preference_api.ccextension_process_manager.ccextension_service.ccextension_service.hextension_service_unittest.ccextension_startup_browsertest.ccextension_tab_helper.ccextension_toolbar_model.ccextension_tts_engine_api.ccextension_updater.ccextension_updater_unittest.ccextension_webrequest_api.ccinstalled_loader.ccnetwork_delay_listener_unittest.cctest_extension_service.cctest_extension_service.hunpacked_installer.ccuser_script_listener.ccuser_script_listener_unittest.cc
intents
sync
test
integration
themes
ui
common
extensions
renderer
extensions
@ -98,9 +98,9 @@ void ExtensionAppProvider::RefreshAppList() {
|
|||||||
ExtensionService* extension_service = profile_->GetExtensionService();
|
ExtensionService* extension_service = profile_->GetExtensionService();
|
||||||
if (!extension_service)
|
if (!extension_service)
|
||||||
return; // During testing, there is no extension service.
|
return; // During testing, there is no extension service.
|
||||||
const ExtensionSet* extensions = extension_service->extensions();
|
const ExtensionList* extensions = extension_service->extensions();
|
||||||
extension_apps_.clear();
|
extension_apps_.clear();
|
||||||
for (ExtensionSet::const_iterator app = extensions->begin();
|
for (ExtensionList::const_iterator app = extensions->begin();
|
||||||
app != extensions->end(); ++app) {
|
app != extensions->end(); ++app) {
|
||||||
if ((*app)->is_app() && (*app)->GetFullLaunchURL().is_valid()) {
|
if ((*app)->is_app() && (*app)->GetFullLaunchURL().is_valid()) {
|
||||||
if (profile_->IsOffTheRecord() &&
|
if (profile_->IsOffTheRecord() &&
|
||||||
|
@ -2017,11 +2017,11 @@ namespace {
|
|||||||
// as identified from a given list of extensions. The caller takes ownership
|
// as identified from a given list of extensions. The caller takes ownership
|
||||||
// of the created vector.
|
// of the created vector.
|
||||||
std::vector<DictionaryValue*>* GetAppInfoFromExtensions(
|
std::vector<DictionaryValue*>* GetAppInfoFromExtensions(
|
||||||
const ExtensionSet* extensions,
|
const ExtensionList* extensions,
|
||||||
ExtensionService* ext_service) {
|
ExtensionService* ext_service) {
|
||||||
std::vector<DictionaryValue*>* apps_list =
|
std::vector<DictionaryValue*>* apps_list =
|
||||||
new std::vector<DictionaryValue*>();
|
new std::vector<DictionaryValue*>();
|
||||||
for (ExtensionSet::const_iterator ext = extensions->begin();
|
for (ExtensionList::const_iterator ext = extensions->begin();
|
||||||
ext != extensions->end(); ++ext) {
|
ext != extensions->end(); ++ext) {
|
||||||
// Only return information about extensions that are actually apps.
|
// Only return information about extensions that are actually apps.
|
||||||
if ((*ext)->is_app()) {
|
if ((*ext)->is_app()) {
|
||||||
@ -2089,7 +2089,7 @@ NTPInfoObserver::NTPInfoObserver(
|
|||||||
}
|
}
|
||||||
// Process enabled extensions.
|
// Process enabled extensions.
|
||||||
ListValue* apps_list = new ListValue();
|
ListValue* apps_list = new ListValue();
|
||||||
const ExtensionSet* extensions = ext_service->extensions();
|
const ExtensionList* extensions = ext_service->extensions();
|
||||||
std::vector<DictionaryValue*>* enabled_apps = GetAppInfoFromExtensions(
|
std::vector<DictionaryValue*>* enabled_apps = GetAppInfoFromExtensions(
|
||||||
extensions, ext_service);
|
extensions, ext_service);
|
||||||
for (std::vector<DictionaryValue*>::const_iterator app =
|
for (std::vector<DictionaryValue*>::const_iterator app =
|
||||||
@ -2099,7 +2099,7 @@ NTPInfoObserver::NTPInfoObserver(
|
|||||||
}
|
}
|
||||||
delete enabled_apps;
|
delete enabled_apps;
|
||||||
// Process disabled extensions.
|
// Process disabled extensions.
|
||||||
const ExtensionSet* disabled_extensions = ext_service->disabled_extensions();
|
const ExtensionList* disabled_extensions = ext_service->disabled_extensions();
|
||||||
std::vector<DictionaryValue*>* disabled_apps = GetAppInfoFromExtensions(
|
std::vector<DictionaryValue*>* disabled_apps = GetAppInfoFromExtensions(
|
||||||
disabled_extensions, ext_service);
|
disabled_extensions, ext_service);
|
||||||
for (std::vector<DictionaryValue*>::const_iterator app =
|
for (std::vector<DictionaryValue*>::const_iterator app =
|
||||||
@ -2109,7 +2109,7 @@ NTPInfoObserver::NTPInfoObserver(
|
|||||||
}
|
}
|
||||||
delete disabled_apps;
|
delete disabled_apps;
|
||||||
// Process terminated extensions.
|
// Process terminated extensions.
|
||||||
const ExtensionSet* terminated_extensions =
|
const ExtensionList* terminated_extensions =
|
||||||
ext_service->terminated_extensions();
|
ext_service->terminated_extensions();
|
||||||
std::vector<DictionaryValue*>* terminated_apps = GetAppInfoFromExtensions(
|
std::vector<DictionaryValue*>* terminated_apps = GetAppInfoFromExtensions(
|
||||||
terminated_extensions, ext_service);
|
terminated_extensions, ext_service);
|
||||||
|
@ -4379,8 +4379,8 @@ void TestingAutomationProvider::GetExtensionsInfo(
|
|||||||
}
|
}
|
||||||
scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
|
scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
|
||||||
ListValue* extensions_values = new ListValue;
|
ListValue* extensions_values = new ListValue;
|
||||||
const ExtensionSet* extensions = service->extensions();
|
const ExtensionList* extensions = service->extensions();
|
||||||
const ExtensionSet* disabled_extensions = service->disabled_extensions();
|
const ExtensionList* disabled_extensions = service->disabled_extensions();
|
||||||
ExtensionList all;
|
ExtensionList all;
|
||||||
all.insert(all.end(),
|
all.insert(all.end(),
|
||||||
extensions->begin(),
|
extensions->begin(),
|
||||||
|
@ -71,9 +71,9 @@ class BackgroundApplicationListModel::Application
|
|||||||
namespace {
|
namespace {
|
||||||
void GetServiceApplications(ExtensionService* service,
|
void GetServiceApplications(ExtensionService* service,
|
||||||
ExtensionList* applications_result) {
|
ExtensionList* applications_result) {
|
||||||
const ExtensionSet* extensions = service->extensions();
|
const ExtensionList* extensions = service->extensions();
|
||||||
|
|
||||||
for (ExtensionSet::const_iterator cursor = extensions->begin();
|
for (ExtensionList::const_iterator cursor = extensions->begin();
|
||||||
cursor != extensions->end();
|
cursor != extensions->end();
|
||||||
++cursor) {
|
++cursor) {
|
||||||
const Extension* extension = *cursor;
|
const Extension* extension = *cursor;
|
||||||
@ -84,7 +84,7 @@ void GetServiceApplications(ExtensionService* service,
|
|||||||
// Walk the list of terminated extensions also (just because an extension
|
// Walk the list of terminated extensions also (just because an extension
|
||||||
// crashed doesn't mean we should ignore it).
|
// crashed doesn't mean we should ignore it).
|
||||||
extensions = service->terminated_extensions();
|
extensions = service->terminated_extensions();
|
||||||
for (ExtensionSet::const_iterator cursor = extensions->begin();
|
for (ExtensionList::const_iterator cursor = extensions->begin();
|
||||||
cursor != extensions->end();
|
cursor != extensions->end();
|
||||||
++cursor) {
|
++cursor) {
|
||||||
const Extension* extension = *cursor;
|
const Extension* extension = *cursor;
|
||||||
|
@ -60,11 +60,8 @@ static scoped_refptr<Extension> CreateExtension(const std::string& name,
|
|||||||
}
|
}
|
||||||
std::string error;
|
std::string error;
|
||||||
scoped_refptr<Extension> extension = Extension::Create(
|
scoped_refptr<Extension> extension = Extension::Create(
|
||||||
bogus_file_path().AppendASCII(name),
|
bogus_file_path().AppendASCII(name), Extension::INVALID, manifest,
|
||||||
Extension::INVALID,
|
Extension::STRICT_ERROR_CHECKS, &error);
|
||||||
manifest,
|
|
||||||
Extension::STRICT_ERROR_CHECKS,
|
|
||||||
&error);
|
|
||||||
// Cannot ASSERT_* here because that attempts an illegitimate return.
|
// Cannot ASSERT_* here because that attempts an illegitimate return.
|
||||||
// Cannot EXPECT_NE here because that assumes non-pointers unlike EXPECT_EQ
|
// Cannot EXPECT_NE here because that assumes non-pointers unlike EXPECT_EQ
|
||||||
EXPECT_TRUE(extension.get() != NULL) << error;
|
EXPECT_TRUE(extension.get() != NULL) << error;
|
||||||
@ -108,7 +105,7 @@ TEST_F(BackgroundApplicationListModelTest, ExplicitTest) {
|
|||||||
ASSERT_TRUE(service);
|
ASSERT_TRUE(service);
|
||||||
ASSERT_TRUE(service->is_ready());
|
ASSERT_TRUE(service->is_ready());
|
||||||
ASSERT_TRUE(service->extensions());
|
ASSERT_TRUE(service->extensions());
|
||||||
ASSERT_TRUE(service->extensions()->is_empty());
|
ASSERT_TRUE(service->extensions()->empty());
|
||||||
scoped_ptr<BackgroundApplicationListModel> model(
|
scoped_ptr<BackgroundApplicationListModel> model(
|
||||||
new BackgroundApplicationListModel(profile_.get()));
|
new BackgroundApplicationListModel(profile_.get()));
|
||||||
ASSERT_EQ(0U, model->size());
|
ASSERT_EQ(0U, model->size());
|
||||||
@ -174,7 +171,7 @@ TEST_F(BackgroundApplicationListModelTest, AddRemovePermissionsTest) {
|
|||||||
ASSERT_TRUE(service);
|
ASSERT_TRUE(service);
|
||||||
ASSERT_TRUE(service->is_ready());
|
ASSERT_TRUE(service->is_ready());
|
||||||
ASSERT_TRUE(service->extensions());
|
ASSERT_TRUE(service->extensions());
|
||||||
ASSERT_TRUE(service->extensions()->is_empty());
|
ASSERT_TRUE(service->extensions()->empty());
|
||||||
scoped_ptr<BackgroundApplicationListModel> model(
|
scoped_ptr<BackgroundApplicationListModel> model(
|
||||||
new BackgroundApplicationListModel(profile_.get()));
|
new BackgroundApplicationListModel(profile_.get()));
|
||||||
ASSERT_EQ(0U, model->size());
|
ASSERT_EQ(0U, model->size());
|
||||||
@ -313,7 +310,7 @@ TEST_F(BackgroundApplicationListModelTest, RandomTest) {
|
|||||||
ASSERT_TRUE(service);
|
ASSERT_TRUE(service);
|
||||||
ASSERT_TRUE(service->is_ready());
|
ASSERT_TRUE(service->is_ready());
|
||||||
ASSERT_TRUE(service->extensions());
|
ASSERT_TRUE(service->extensions());
|
||||||
ASSERT_TRUE(service->extensions()->is_empty());
|
ASSERT_TRUE(service->extensions()->empty());
|
||||||
scoped_ptr<BackgroundApplicationListModel> model(
|
scoped_ptr<BackgroundApplicationListModel> model(
|
||||||
new BackgroundApplicationListModel(profile_.get()));
|
new BackgroundApplicationListModel(profile_.get()));
|
||||||
ASSERT_EQ(0U, model->size());
|
ASSERT_EQ(0U, model->size());
|
||||||
|
@ -418,9 +418,9 @@ void BackgroundContentsService::LoadBackgroundContentsFromDictionary(
|
|||||||
|
|
||||||
void BackgroundContentsService::LoadBackgroundContentsFromManifests(
|
void BackgroundContentsService::LoadBackgroundContentsFromManifests(
|
||||||
Profile* profile) {
|
Profile* profile) {
|
||||||
const ExtensionSet* extensions =
|
const ExtensionList* extensions =
|
||||||
profile->GetExtensionService()->extensions();
|
profile->GetExtensionService()->extensions();
|
||||||
ExtensionSet::const_iterator iter = extensions->begin();
|
ExtensionList::const_iterator iter = extensions->begin();
|
||||||
for (; iter != extensions->end(); ++iter) {
|
for (; iter != extensions->end(); ++iter) {
|
||||||
const Extension* extension = *iter;
|
const Extension* extension = *iter;
|
||||||
if (extension->is_hosted_app() &&
|
if (extension->is_hosted_app() &&
|
||||||
|
@ -414,9 +414,9 @@ void DevToolsWindow::AddDevToolsExtensionsToClient() {
|
|||||||
if (!extension_service)
|
if (!extension_service)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const ExtensionSet* extensions = extension_service->extensions();
|
const ExtensionList* extensions = extension_service->extensions();
|
||||||
|
|
||||||
for (ExtensionSet::const_iterator extension = extensions->begin();
|
for (ExtensionList::const_iterator extension = extensions->begin();
|
||||||
extension != extensions->end(); ++extension) {
|
extension != extensions->end(); ++extension) {
|
||||||
if ((*extension)->devtools_url().is_empty())
|
if ((*extension)->devtools_url().is_empty())
|
||||||
continue;
|
continue;
|
||||||
|
@ -316,15 +316,12 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoDragging) {
|
|||||||
|
|
||||||
const size_t size_before = service->extensions()->size();
|
const size_t size_before = service->extensions()->size();
|
||||||
|
|
||||||
const Extension* extension_a = LoadExtension(test_data_dir_.AppendASCII(
|
ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
|
||||||
"browser_action/basics"));
|
"browser_action/basics")));
|
||||||
const Extension* extension_b = LoadExtension(test_data_dir_.AppendASCII(
|
ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
|
||||||
"browser_action/popup"));
|
"browser_action/popup")));
|
||||||
const Extension* extension_c = LoadExtension(test_data_dir_.AppendASCII(
|
ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
|
||||||
"browser_action/add_popup"));
|
"browser_action/add_popup")));
|
||||||
ASSERT_TRUE(extension_a);
|
|
||||||
ASSERT_TRUE(extension_b);
|
|
||||||
ASSERT_TRUE(extension_c);
|
|
||||||
|
|
||||||
// Test that there are 3 browser actions in the toolbar.
|
// Test that there are 3 browser actions in the toolbar.
|
||||||
ASSERT_EQ(size_before + 3, service->extensions()->size());
|
ASSERT_EQ(size_before + 3, service->extensions()->size());
|
||||||
@ -332,8 +329,10 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoDragging) {
|
|||||||
|
|
||||||
// Now enable 2 of the extensions in incognito mode, and test that the browser
|
// Now enable 2 of the extensions in incognito mode, and test that the browser
|
||||||
// actions show up.
|
// actions show up.
|
||||||
service->extension_prefs()->SetIsIncognitoEnabled(extension_a->id(), true);
|
service->extension_prefs()->SetIsIncognitoEnabled(
|
||||||
service->extension_prefs()->SetIsIncognitoEnabled(extension_c->id(), true);
|
service->extensions()->at(size_before)->id(), true);
|
||||||
|
service->extension_prefs()->SetIsIncognitoEnabled(
|
||||||
|
service->extensions()->at(size_before + 2)->id(), true);
|
||||||
|
|
||||||
Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile();
|
Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile();
|
||||||
Browser* incognito_browser = Browser::Create(incognito_profile);
|
Browser* incognito_browser = Browser::Create(incognito_profile);
|
||||||
@ -356,7 +355,8 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoDragging) {
|
|||||||
// regular and incognito mode.
|
// regular and incognito mode.
|
||||||
|
|
||||||
// ABC -> CAB
|
// ABC -> CAB
|
||||||
service->toolbar_model()->MoveBrowserAction(extension_c, 0);
|
service->toolbar_model()->MoveBrowserAction(
|
||||||
|
service->extensions()->at(size_before + 2), 0);
|
||||||
|
|
||||||
EXPECT_EQ(kTooltipC, GetBrowserActionsBar().GetTooltip(0));
|
EXPECT_EQ(kTooltipC, GetBrowserActionsBar().GetTooltip(0));
|
||||||
EXPECT_EQ(kTooltipA, GetBrowserActionsBar().GetTooltip(1));
|
EXPECT_EQ(kTooltipA, GetBrowserActionsBar().GetTooltip(1));
|
||||||
@ -366,7 +366,8 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoDragging) {
|
|||||||
EXPECT_EQ(kTooltipA, incognito_bar.GetTooltip(1));
|
EXPECT_EQ(kTooltipA, incognito_bar.GetTooltip(1));
|
||||||
|
|
||||||
// CAB -> CBA
|
// CAB -> CBA
|
||||||
service->toolbar_model()->MoveBrowserAction(extension_b, 1);
|
service->toolbar_model()->MoveBrowserAction(
|
||||||
|
service->extensions()->at(size_before + 1), 1);
|
||||||
|
|
||||||
EXPECT_EQ(kTooltipC, GetBrowserActionsBar().GetTooltip(0));
|
EXPECT_EQ(kTooltipC, GetBrowserActionsBar().GetTooltip(0));
|
||||||
EXPECT_EQ(kTooltipB, GetBrowserActionsBar().GetTooltip(1));
|
EXPECT_EQ(kTooltipB, GetBrowserActionsBar().GetTooltip(1));
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "chrome/browser/extensions/test_extension_service.h"
|
#include "chrome/browser/extensions/test_extension_service.h"
|
||||||
#include "chrome/common/chrome_paths.h"
|
#include "chrome/common/chrome_paths.h"
|
||||||
#include "chrome/common/extensions/extension.h"
|
#include "chrome/common/extensions/extension.h"
|
||||||
#include "chrome/common/extensions/extension_set.h"
|
|
||||||
#include "chrome/common/pref_names.h"
|
#include "chrome/common/pref_names.h"
|
||||||
#include "chrome/test/base/testing_pref_service.h"
|
#include "chrome/test/base/testing_pref_service.h"
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
@ -21,7 +20,7 @@ namespace {
|
|||||||
class MockExtensionService : public TestExtensionService {
|
class MockExtensionService : public TestExtensionService {
|
||||||
private:
|
private:
|
||||||
bool ready_;
|
bool ready_;
|
||||||
ExtensionSet extension_set_;
|
ExtensionList extension_list_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MockExtensionService() : ready_(false) {
|
MockExtensionService() : ready_(false) {
|
||||||
@ -29,30 +28,37 @@ class MockExtensionService : public TestExtensionService {
|
|||||||
|
|
||||||
virtual void AddExtension(const Extension* extension) OVERRIDE {
|
virtual void AddExtension(const Extension* extension) OVERRIDE {
|
||||||
// ExtensionService must become the owner of the extension object.
|
// ExtensionService must become the owner of the extension object.
|
||||||
extension_set_.Insert(extension);
|
extension_list_.push_back(extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void UnloadExtension(
|
virtual void UnloadExtension(
|
||||||
const std::string& extension_id,
|
const std::string& extension_id,
|
||||||
extension_misc::UnloadedExtensionReason reason) OVERRIDE {
|
extension_misc::UnloadedExtensionReason reason) OVERRIDE {
|
||||||
// Remove the extension with the matching id.
|
// Remove the extension with the matching id.
|
||||||
extension_set_.Remove(extension_id);
|
for (ExtensionList::iterator it = extension_list_.begin();
|
||||||
|
it != extension_list_.end();
|
||||||
|
++it) {
|
||||||
|
if ((*it)->id() == extension_id) {
|
||||||
|
extension_list_.erase(it);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool is_ready() OVERRIDE {
|
virtual bool is_ready() OVERRIDE {
|
||||||
return ready_;
|
return ready_;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const ExtensionSet* extensions() const OVERRIDE {
|
virtual const ExtensionList* extensions() const OVERRIDE {
|
||||||
return &extension_set_;
|
return &extension_list_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_ready(bool ready) {
|
void set_ready(bool ready) {
|
||||||
ready_ = ready;
|
ready_ = ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_extensions() {
|
void clear_extension_list() {
|
||||||
extension_set_.Clear();
|
extension_list_.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -211,7 +217,7 @@ TEST_F(ComponentLoaderTest, LoadAll) {
|
|||||||
unsigned int default_count = extension_service_.extensions()->size();
|
unsigned int default_count = extension_service_.extensions()->size();
|
||||||
|
|
||||||
// Clear the list of loaded extensions, and reload with one more.
|
// Clear the list of loaded extensions, and reload with one more.
|
||||||
extension_service_.clear_extensions();
|
extension_service_.clear_extension_list();
|
||||||
component_loader_.Add(manifest_contents_, extension_path_);
|
component_loader_.Add(manifest_contents_, extension_path_);
|
||||||
component_loader_.LoadAll();
|
component_loader_.LoadAll();
|
||||||
|
|
||||||
@ -231,7 +237,7 @@ TEST_F(ComponentLoaderTest, EnterpriseWebStore) {
|
|||||||
|
|
||||||
// Now that the pref is set, check if it's added by default.
|
// Now that the pref is set, check if it's added by default.
|
||||||
extension_service_.set_ready(false);
|
extension_service_.set_ready(false);
|
||||||
extension_service_.clear_extensions();
|
extension_service_.clear_extension_list();
|
||||||
component_loader_.ClearAllRegistered();
|
component_loader_.ClearAllRegistered();
|
||||||
component_loader_.AddDefaultComponentExtensions();
|
component_loader_.AddDefaultComponentExtensions();
|
||||||
component_loader_.LoadAll();
|
component_loader_.LoadAll();
|
||||||
|
@ -202,29 +202,28 @@ bool ExtensionApiTest::RunExtensionTestImpl(const char* extension_name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that exactly one extension is loaded, and return it.
|
// Test that exactly one extension loaded.
|
||||||
const Extension* ExtensionApiTest::GetSingleLoadedExtension() {
|
const Extension* ExtensionApiTest::GetSingleLoadedExtension() {
|
||||||
ExtensionService* service = browser()->profile()->GetExtensionService();
|
ExtensionService* service = browser()->profile()->GetExtensionService();
|
||||||
|
|
||||||
const Extension* extension = NULL;
|
int found_extension_index = -1;
|
||||||
for (ExtensionSet::const_iterator it = service->extensions()->begin();
|
for (size_t i = 0; i < service->extensions()->size(); ++i) {
|
||||||
it != service->extensions()->end(); ++it) {
|
|
||||||
// Ignore any component extensions. They are automatically loaded into all
|
// Ignore any component extensions. They are automatically loaded into all
|
||||||
// profiles and aren't the extension we're looking for here.
|
// profiles and aren't the extension we're looking for here.
|
||||||
if ((*it)->location() == Extension::COMPONENT)
|
if (service->extensions()->at(i)->location() == Extension::COMPONENT)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (extension != NULL) {
|
if (found_extension_index != -1) {
|
||||||
// TODO(yoz): this is misleading; it counts component extensions.
|
|
||||||
message_ = base::StringPrintf(
|
message_ = base::StringPrintf(
|
||||||
"Expected only one extension to be present. Found %u.",
|
"Expected only one extension to be present. Found %u.",
|
||||||
static_cast<unsigned>(service->extensions()->size()));
|
static_cast<unsigned>(service->extensions()->size()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
extension = *it;
|
found_extension_index = static_cast<int>(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Extension* extension = service->extensions()->at(found_extension_index);
|
||||||
if (!extension) {
|
if (!extension) {
|
||||||
message_ = "extension pointer is NULL.";
|
message_ = "extension pointer is NULL.";
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -72,13 +72,13 @@ const Extension* ExtensionBrowserTest::LoadExtensionWithOptions(
|
|||||||
ui_test_utils::RunMessageLoop();
|
ui_test_utils::RunMessageLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the loaded extension by its path. See crbug.com/59531 for why
|
// Find the extension by iterating backwards since it is likely last.
|
||||||
// we cannot just use last_loaded_extension_id_.
|
|
||||||
FilePath extension_path = path;
|
FilePath extension_path = path;
|
||||||
file_util::AbsolutePath(&extension_path);
|
file_util::AbsolutePath(&extension_path);
|
||||||
const Extension* extension = NULL;
|
const Extension* extension = NULL;
|
||||||
for (ExtensionSet::const_iterator iter = service->extensions()->begin();
|
for (ExtensionList::const_reverse_iterator iter =
|
||||||
iter != service->extensions()->end(); ++iter) {
|
service->extensions()->rbegin();
|
||||||
|
iter != service->extensions()->rend(); ++iter) {
|
||||||
if ((*iter)->path() == extension_path) {
|
if ((*iter)->path() == extension_path) {
|
||||||
extension = *iter;
|
extension = *iter;
|
||||||
break;
|
break;
|
||||||
@ -296,9 +296,8 @@ const Extension* ExtensionBrowserTest::InstallOrUpdateExtension(
|
|||||||
<< " num after: " << base::IntToString(num_after)
|
<< " num after: " << base::IntToString(num_after)
|
||||||
<< " Installed extensions follow:";
|
<< " Installed extensions follow:";
|
||||||
|
|
||||||
for (ExtensionSet::const_iterator it = service->extensions()->begin();
|
for (size_t i = 0; i < service->extensions()->size(); ++i)
|
||||||
it != service->extensions()->end(); ++it)
|
VLOG(1) << " " << (*service->extensions())[i]->id();
|
||||||
VLOG(1) << " " << (*it)->id();
|
|
||||||
|
|
||||||
VLOG(1) << "Errors follow:";
|
VLOG(1) << "Errors follow:";
|
||||||
const std::vector<std::string>* errors =
|
const std::vector<std::string>* errors =
|
||||||
|
@ -212,30 +212,29 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PageActionRefreshCrash) {
|
|||||||
FilePath base_path = test_data_dir_.AppendASCII("browsertest")
|
FilePath base_path = test_data_dir_.AppendASCII("browsertest")
|
||||||
.AppendASCII("crash_44415");
|
.AppendASCII("crash_44415");
|
||||||
// Load extension A.
|
// Load extension A.
|
||||||
const Extension* extensionA = LoadExtension(base_path.AppendASCII("ExtA"));
|
ASSERT_TRUE(LoadExtension(base_path.AppendASCII("ExtA")));
|
||||||
ASSERT_TRUE(extensionA);
|
|
||||||
ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
|
ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
|
||||||
ASSERT_EQ(size_before + 1, service->extensions()->size());
|
ASSERT_EQ(size_before + 1, service->extensions()->size());
|
||||||
|
const Extension* extensionA = service->extensions()->at(size_before);
|
||||||
|
|
||||||
LOG(INFO) << "Load extension A done : "
|
LOG(INFO) << "Load extension A done : "
|
||||||
<< (base::TimeTicks::Now() - start_time).InMilliseconds()
|
<< (base::TimeTicks::Now() - start_time).InMilliseconds()
|
||||||
<< " ms" << std::flush;
|
<< " ms" << std::flush;
|
||||||
|
|
||||||
// Load extension B.
|
// Load extension B.
|
||||||
const Extension* extensionB = LoadExtension(base_path.AppendASCII("ExtB"));
|
ASSERT_TRUE(LoadExtension(base_path.AppendASCII("ExtB")));
|
||||||
ASSERT_TRUE(extensionB);
|
|
||||||
ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(2));
|
ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(2));
|
||||||
ASSERT_EQ(size_before + 2, service->extensions()->size());
|
ASSERT_EQ(size_before + 2, service->extensions()->size());
|
||||||
|
const Extension* extensionB = service->extensions()->at(size_before + 1);
|
||||||
|
|
||||||
LOG(INFO) << "Load extension B done : "
|
LOG(INFO) << "Load extension B done : "
|
||||||
<< (base::TimeTicks::Now() - start_time).InMilliseconds()
|
<< (base::TimeTicks::Now() - start_time).InMilliseconds()
|
||||||
<< " ms" << std::flush;
|
<< " ms" << std::flush;
|
||||||
|
|
||||||
std::string idA = extensionA->id();
|
|
||||||
ReloadExtension(extensionA->id());
|
ReloadExtension(extensionA->id());
|
||||||
// ExtensionA has changed, so refetch it.
|
// ExtensionA has changed, so refetch it.
|
||||||
ASSERT_EQ(size_before + 2, service->extensions()->size());
|
ASSERT_EQ(size_before + 2, service->extensions()->size());
|
||||||
extensionA = service->extensions()->GetByID(idA);
|
extensionA = service->extensions()->at(size_before + 1);
|
||||||
|
|
||||||
LOG(INFO) << "Reload extension A done: "
|
LOG(INFO) << "Reload extension A done: "
|
||||||
<< (base::TimeTicks::Now() - start_time).InMilliseconds()
|
<< (base::TimeTicks::Now() - start_time).InMilliseconds()
|
||||||
@ -279,10 +278,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationBrowserAction) {
|
|||||||
const size_t size_before = service->extensions()->size();
|
const size_t size_before = service->extensions()->size();
|
||||||
FilePath extension_path(test_data_dir_.AppendASCII("browsertest")
|
FilePath extension_path(test_data_dir_.AppendASCII("browsertest")
|
||||||
.AppendASCII("title_localized"));
|
.AppendASCII("title_localized"));
|
||||||
const Extension* extension = LoadExtension(extension_path);
|
ASSERT_TRUE(LoadExtension(extension_path));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
|
|
||||||
ASSERT_EQ(size_before + 1, service->extensions()->size());
|
ASSERT_EQ(size_before + 1, service->extensions()->size());
|
||||||
|
const Extension* extension = service->extensions()->at(size_before);
|
||||||
|
|
||||||
EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n browser action").c_str(),
|
EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n browser action").c_str(),
|
||||||
extension->description().c_str());
|
extension->description().c_str());
|
||||||
@ -303,8 +302,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationPageAction) {
|
|||||||
|
|
||||||
FilePath extension_path(test_data_dir_.AppendASCII("browsertest")
|
FilePath extension_path(test_data_dir_.AppendASCII("browsertest")
|
||||||
.AppendASCII("title_localized_pa"));
|
.AppendASCII("title_localized_pa"));
|
||||||
const Extension* extension = LoadExtension(extension_path);
|
ASSERT_TRUE(LoadExtension(extension_path));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
|
|
||||||
// Any navigation prompts the location bar to load the page action.
|
// Any navigation prompts the location bar to load the page action.
|
||||||
GURL url = test_server()->GetURL(kLocalization);
|
GURL url = test_server()->GetURL(kLocalization);
|
||||||
@ -312,6 +310,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationPageAction) {
|
|||||||
ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
|
ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
|
||||||
|
|
||||||
ASSERT_EQ(size_before + 1, service->extensions()->size());
|
ASSERT_EQ(size_before + 1, service->extensions()->size());
|
||||||
|
const Extension* extension = service->extensions()->at(size_before);
|
||||||
|
|
||||||
EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n page action").c_str(),
|
EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n page action").c_str(),
|
||||||
extension->description().c_str());
|
extension->description().c_str());
|
||||||
@ -388,7 +387,6 @@ bool ValidatePageElement(TabContents* tab,
|
|||||||
void NavigateToFeedAndValidate(net::TestServer* server,
|
void NavigateToFeedAndValidate(net::TestServer* server,
|
||||||
const std::string& url,
|
const std::string& url,
|
||||||
Browser* browser,
|
Browser* browser,
|
||||||
std::string extension_id,
|
|
||||||
bool sniff_xml_type,
|
bool sniff_xml_type,
|
||||||
const std::string& expected_feed_title,
|
const std::string& expected_feed_title,
|
||||||
const std::string& expected_item_title,
|
const std::string& expected_item_title,
|
||||||
@ -398,9 +396,12 @@ void NavigateToFeedAndValidate(net::TestServer* server,
|
|||||||
// TODO(finnur): Implement this is a non-flaky way.
|
// TODO(finnur): Implement this is a non-flaky way.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExtensionService* service = browser->profile()->GetExtensionService();
|
||||||
|
const Extension* extension = service->extensions()->back();
|
||||||
|
std::string id = extension->id();
|
||||||
|
|
||||||
// Navigate to the subscribe page directly.
|
// Navigate to the subscribe page directly.
|
||||||
ui_test_utils::NavigateToURL(browser,
|
ui_test_utils::NavigateToURL(browser, GetFeedUrl(server, url, true, id));
|
||||||
GetFeedUrl(server, url, true, extension_id));
|
|
||||||
|
|
||||||
TabContents* tab = browser->GetSelectedTabContents();
|
TabContents* tab = browser->GetSelectedTabContents();
|
||||||
ASSERT_TRUE(ValidatePageElement(tab,
|
ASSERT_TRUE(ValidatePageElement(tab,
|
||||||
@ -424,12 +425,10 @@ void NavigateToFeedAndValidate(net::TestServer* server,
|
|||||||
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed1) {
|
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed1) {
|
||||||
ASSERT_TRUE(test_server()->Start());
|
ASSERT_TRUE(test_server()->Start());
|
||||||
|
|
||||||
const Extension* extension = LoadExtension(
|
ASSERT_TRUE(LoadExtension(
|
||||||
test_data_dir_.AppendASCII("subscribe_page_action"));
|
test_data_dir_.AppendASCII("subscribe_page_action")));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
std::string id = extension->id();
|
|
||||||
|
|
||||||
NavigateToFeedAndValidate(test_server(), kValidFeed1, browser(), id, true,
|
NavigateToFeedAndValidate(test_server(), kValidFeed1, browser(), true,
|
||||||
"Feed for MyFeedTitle",
|
"Feed for MyFeedTitle",
|
||||||
"Title 1",
|
"Title 1",
|
||||||
"Desc",
|
"Desc",
|
||||||
@ -439,12 +438,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed1) {
|
|||||||
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed2) {
|
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed2) {
|
||||||
ASSERT_TRUE(test_server()->Start());
|
ASSERT_TRUE(test_server()->Start());
|
||||||
|
|
||||||
const Extension* extension = LoadExtension(
|
ASSERT_TRUE(LoadExtension(
|
||||||
test_data_dir_.AppendASCII("subscribe_page_action"));
|
test_data_dir_.AppendASCII("subscribe_page_action")));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
std::string id = extension->id();
|
|
||||||
|
|
||||||
NavigateToFeedAndValidate(test_server(), kValidFeed2, browser(), id, true,
|
NavigateToFeedAndValidate(test_server(), kValidFeed2, browser(), true,
|
||||||
"Feed for MyFeed2",
|
"Feed for MyFeed2",
|
||||||
"My item title1",
|
"My item title1",
|
||||||
"This is a summary.",
|
"This is a summary.",
|
||||||
@ -454,12 +451,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed2) {
|
|||||||
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed3) {
|
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed3) {
|
||||||
ASSERT_TRUE(test_server()->Start());
|
ASSERT_TRUE(test_server()->Start());
|
||||||
|
|
||||||
const Extension* extension = LoadExtension(
|
ASSERT_TRUE(LoadExtension(
|
||||||
test_data_dir_.AppendASCII("subscribe_page_action"));
|
test_data_dir_.AppendASCII("subscribe_page_action")));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
std::string id = extension->id();
|
|
||||||
|
|
||||||
NavigateToFeedAndValidate(test_server(), kValidFeed3, browser(), id, true,
|
NavigateToFeedAndValidate(test_server(), kValidFeed3, browser(), true,
|
||||||
"Feed for Google Code buglist rss feed",
|
"Feed for Google Code buglist rss feed",
|
||||||
"My dear title",
|
"My dear title",
|
||||||
"My dear content",
|
"My dear content",
|
||||||
@ -469,12 +464,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed3) {
|
|||||||
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed4) {
|
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed4) {
|
||||||
ASSERT_TRUE(test_server()->Start());
|
ASSERT_TRUE(test_server()->Start());
|
||||||
|
|
||||||
const Extension* extension = LoadExtension(
|
ASSERT_TRUE(LoadExtension(
|
||||||
test_data_dir_.AppendASCII("subscribe_page_action"));
|
test_data_dir_.AppendASCII("subscribe_page_action")));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
std::string id = extension->id();
|
|
||||||
|
|
||||||
NavigateToFeedAndValidate(test_server(), kValidFeed4, browser(), id, true,
|
NavigateToFeedAndValidate(test_server(), kValidFeed4, browser(), true,
|
||||||
"Feed for Title chars <script> %23 stop",
|
"Feed for Title chars <script> %23 stop",
|
||||||
"Title chars %23 stop",
|
"Title chars %23 stop",
|
||||||
"My dear content %23 stop",
|
"My dear content %23 stop",
|
||||||
@ -484,14 +477,12 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed4) {
|
|||||||
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed0) {
|
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed0) {
|
||||||
ASSERT_TRUE(test_server()->Start());
|
ASSERT_TRUE(test_server()->Start());
|
||||||
|
|
||||||
const Extension* extension = LoadExtension(
|
ASSERT_TRUE(LoadExtension(
|
||||||
test_data_dir_.AppendASCII("subscribe_page_action"));
|
test_data_dir_.AppendASCII("subscribe_page_action")));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
std::string id = extension->id();
|
|
||||||
|
|
||||||
// Try a feed with a link with an onclick handler (before r27440 this would
|
// Try a feed with a link with an onclick handler (before r27440 this would
|
||||||
// trigger a NOTREACHED).
|
// trigger a NOTREACHED).
|
||||||
NavigateToFeedAndValidate(test_server(), kValidFeed0, browser(), id, true,
|
NavigateToFeedAndValidate(test_server(), kValidFeed0, browser(), true,
|
||||||
"Feed for MyFeedTitle",
|
"Feed for MyFeedTitle",
|
||||||
"Title 1",
|
"Title 1",
|
||||||
"Desc VIDEO",
|
"Desc VIDEO",
|
||||||
@ -501,13 +492,11 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed0) {
|
|||||||
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed5) {
|
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed5) {
|
||||||
ASSERT_TRUE(test_server()->Start());
|
ASSERT_TRUE(test_server()->Start());
|
||||||
|
|
||||||
const Extension* extension = LoadExtension(
|
ASSERT_TRUE(LoadExtension(
|
||||||
test_data_dir_.AppendASCII("subscribe_page_action"));
|
test_data_dir_.AppendASCII("subscribe_page_action")));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
std::string id = extension->id();
|
|
||||||
|
|
||||||
// Feed with valid but mostly empty xml.
|
// Feed with valid but mostly empty xml.
|
||||||
NavigateToFeedAndValidate(test_server(), kValidFeed5, browser(), id, true,
|
NavigateToFeedAndValidate(test_server(), kValidFeed5, browser(), true,
|
||||||
"Feed for Unknown feed name",
|
"Feed for Unknown feed name",
|
||||||
"element 'anchor_0' not found",
|
"element 'anchor_0' not found",
|
||||||
"element 'desc_0' not found",
|
"element 'desc_0' not found",
|
||||||
@ -517,13 +506,11 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed5) {
|
|||||||
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed6) {
|
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed6) {
|
||||||
ASSERT_TRUE(test_server()->Start());
|
ASSERT_TRUE(test_server()->Start());
|
||||||
|
|
||||||
const Extension* extension = LoadExtension(
|
ASSERT_TRUE(LoadExtension(
|
||||||
test_data_dir_.AppendASCII("subscribe_page_action"));
|
test_data_dir_.AppendASCII("subscribe_page_action")));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
std::string id = extension->id();
|
|
||||||
|
|
||||||
// Feed that is technically invalid but still parseable.
|
// Feed that is technically invalid but still parseable.
|
||||||
NavigateToFeedAndValidate(test_server(), kValidFeed6, browser(), id, true,
|
NavigateToFeedAndValidate(test_server(), kValidFeed6, browser(), true,
|
||||||
"Feed for MyFeedTitle",
|
"Feed for MyFeedTitle",
|
||||||
"Title 1",
|
"Title 1",
|
||||||
"Desc",
|
"Desc",
|
||||||
@ -533,13 +520,11 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed6) {
|
|||||||
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed1) {
|
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed1) {
|
||||||
ASSERT_TRUE(test_server()->Start());
|
ASSERT_TRUE(test_server()->Start());
|
||||||
|
|
||||||
const Extension* extension = LoadExtension(
|
ASSERT_TRUE(LoadExtension(
|
||||||
test_data_dir_.AppendASCII("subscribe_page_action"));
|
test_data_dir_.AppendASCII("subscribe_page_action")));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
std::string id = extension->id();
|
|
||||||
|
|
||||||
// Try an empty feed.
|
// Try an empty feed.
|
||||||
NavigateToFeedAndValidate(test_server(), kInvalidFeed1, browser(), id, false,
|
NavigateToFeedAndValidate(test_server(), kInvalidFeed1, browser(), false,
|
||||||
"Feed for Unknown feed name",
|
"Feed for Unknown feed name",
|
||||||
"element 'anchor_0' not found",
|
"element 'anchor_0' not found",
|
||||||
"element 'desc_0' not found",
|
"element 'desc_0' not found",
|
||||||
@ -549,13 +534,11 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed1) {
|
|||||||
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed2) {
|
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed2) {
|
||||||
ASSERT_TRUE(test_server()->Start());
|
ASSERT_TRUE(test_server()->Start());
|
||||||
|
|
||||||
const Extension* extension = LoadExtension(
|
ASSERT_TRUE(LoadExtension(
|
||||||
test_data_dir_.AppendASCII("subscribe_page_action"));
|
test_data_dir_.AppendASCII("subscribe_page_action")));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
std::string id = extension->id();
|
|
||||||
|
|
||||||
// Try a garbage feed.
|
// Try a garbage feed.
|
||||||
NavigateToFeedAndValidate(test_server(), kInvalidFeed2, browser(), id, false,
|
NavigateToFeedAndValidate(test_server(), kInvalidFeed2, browser(), false,
|
||||||
"Feed for Unknown feed name",
|
"Feed for Unknown feed name",
|
||||||
"element 'anchor_0' not found",
|
"element 'anchor_0' not found",
|
||||||
"element 'desc_0' not found",
|
"element 'desc_0' not found",
|
||||||
@ -565,13 +548,11 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed2) {
|
|||||||
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed3) {
|
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed3) {
|
||||||
ASSERT_TRUE(test_server()->Start());
|
ASSERT_TRUE(test_server()->Start());
|
||||||
|
|
||||||
const Extension* extension = LoadExtension(
|
ASSERT_TRUE(LoadExtension(
|
||||||
test_data_dir_.AppendASCII("subscribe_page_action"));
|
test_data_dir_.AppendASCII("subscribe_page_action")));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
std::string id = extension->id();
|
|
||||||
|
|
||||||
// Try a feed that doesn't exist.
|
// Try a feed that doesn't exist.
|
||||||
NavigateToFeedAndValidate(test_server(), "foo.xml", browser(), id, false,
|
NavigateToFeedAndValidate(test_server(), "foo.xml", browser(), false,
|
||||||
"Feed for Unknown feed name",
|
"Feed for Unknown feed name",
|
||||||
"element 'anchor_0' not found",
|
"element 'anchor_0' not found",
|
||||||
"element 'desc_0' not found",
|
"element 'desc_0' not found",
|
||||||
@ -581,10 +562,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed3) {
|
|||||||
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed4) {
|
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed4) {
|
||||||
ASSERT_TRUE(test_server()->Start());
|
ASSERT_TRUE(test_server()->Start());
|
||||||
|
|
||||||
const Extension* extension = LoadExtension(
|
ASSERT_TRUE(LoadExtension(
|
||||||
test_data_dir_.AppendASCII("subscribe_page_action"));
|
test_data_dir_.AppendASCII("subscribe_page_action")));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
std::string id = extension->id();
|
|
||||||
|
|
||||||
// subscribe.js shouldn't double-decode the URL passed in. Otherwise feed
|
// subscribe.js shouldn't double-decode the URL passed in. Otherwise feed
|
||||||
// links such as http://search.twitter.com/search.atom?lang=en&q=%23chrome
|
// links such as http://search.twitter.com/search.atom?lang=en&q=%23chrome
|
||||||
@ -593,29 +572,25 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed4) {
|
|||||||
// uses an underscore instead of a hash, but the principle is the same. If
|
// uses an underscore instead of a hash, but the principle is the same. If
|
||||||
// we start erroneously double decoding again, the path (and the feed) will
|
// we start erroneously double decoding again, the path (and the feed) will
|
||||||
// become valid resulting in a failure for this test.
|
// become valid resulting in a failure for this test.
|
||||||
NavigateToFeedAndValidate(
|
NavigateToFeedAndValidate(test_server(), kFeedTripleEncoded, browser(), true,
|
||||||
test_server(), kFeedTripleEncoded, browser(), id, true,
|
"Feed for Unknown feed name",
|
||||||
"Feed for Unknown feed name",
|
"element 'anchor_0' not found",
|
||||||
"element 'anchor_0' not found",
|
"element 'desc_0' not found",
|
||||||
"element 'desc_0' not found",
|
"This feed contains no entries.");
|
||||||
"This feed contains no entries.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeedNoLinks) {
|
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeedNoLinks) {
|
||||||
ASSERT_TRUE(test_server()->Start());
|
ASSERT_TRUE(test_server()->Start());
|
||||||
|
|
||||||
const Extension* extension = LoadExtension(
|
ASSERT_TRUE(LoadExtension(
|
||||||
test_data_dir_.AppendASCII("subscribe_page_action"));
|
test_data_dir_.AppendASCII("subscribe_page_action")));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
std::string id = extension->id();
|
|
||||||
|
|
||||||
// Valid feed but containing no links.
|
// Valid feed but containing no links.
|
||||||
NavigateToFeedAndValidate(
|
NavigateToFeedAndValidate(test_server(), kValidFeedNoLinks, browser(), true,
|
||||||
test_server(), kValidFeedNoLinks, browser(), id, true,
|
"Feed for MyFeedTitle",
|
||||||
"Feed for MyFeedTitle",
|
"Title with no link",
|
||||||
"Title with no link",
|
"Desc",
|
||||||
"Desc",
|
"No error");
|
||||||
"No error");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that an error raised during an async function still fires
|
// Tests that an error raised during an async function still fires
|
||||||
@ -747,8 +722,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, MAYBE_PluginLoadUnload) {
|
|||||||
ExtensionService* service = browser()->profile()->GetExtensionService();
|
ExtensionService* service = browser()->profile()->GetExtensionService();
|
||||||
service->set_show_extensions_prompts(false);
|
service->set_show_extensions_prompts(false);
|
||||||
const size_t size_before = service->extensions()->size();
|
const size_t size_before = service->extensions()->size();
|
||||||
const Extension* extension = LoadExtension(extension_dir);
|
ASSERT_TRUE(LoadExtension(extension_dir));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
EXPECT_EQ(size_before + 1, service->extensions()->size());
|
EXPECT_EQ(size_before + 1, service->extensions()->size());
|
||||||
// Now the plugin should be in the cache, but we have to reload the page for
|
// Now the plugin should be in the cache, but we have to reload the page for
|
||||||
// it to work.
|
// it to work.
|
||||||
@ -768,7 +742,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, MAYBE_PluginLoadUnload) {
|
|||||||
EXPECT_TRUE(result);
|
EXPECT_TRUE(result);
|
||||||
|
|
||||||
EXPECT_EQ(size_before + 1, service->extensions()->size());
|
EXPECT_EQ(size_before + 1, service->extensions()->size());
|
||||||
UnloadExtension(extension->id());
|
UnloadExtension(service->extensions()->at(size_before)->id());
|
||||||
EXPECT_EQ(size_before, service->extensions()->size());
|
EXPECT_EQ(size_before, service->extensions()->size());
|
||||||
|
|
||||||
// Now the plugin should be unloaded, and the page should be broken.
|
// Now the plugin should be unloaded, and the page should be broken.
|
||||||
@ -810,11 +784,11 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, MAYBE_PluginPrivate) {
|
|||||||
ExtensionService* service = browser()->profile()->GetExtensionService();
|
ExtensionService* service = browser()->profile()->GetExtensionService();
|
||||||
service->set_show_extensions_prompts(false);
|
service->set_show_extensions_prompts(false);
|
||||||
const size_t size_before = service->extensions()->size();
|
const size_t size_before = service->extensions()->size();
|
||||||
const Extension* extension = LoadExtension(extension_dir);
|
ASSERT_TRUE(LoadExtension(extension_dir));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
EXPECT_EQ(size_before + 1, service->extensions()->size());
|
EXPECT_EQ(size_before + 1, service->extensions()->size());
|
||||||
|
|
||||||
// Load the test page through the extension URL, and the plugin should work.
|
// Load the test page through the extension URL, and the plugin should work.
|
||||||
|
const Extension* extension = service->extensions()->back();
|
||||||
ui_test_utils::NavigateToURL(browser(),
|
ui_test_utils::NavigateToURL(browser(),
|
||||||
extension->GetResourceURL("test.html"));
|
extension->GetResourceURL("test.html"));
|
||||||
TabContents* tab = browser()->GetSelectedTabContents();
|
TabContents* tab = browser()->GetSelectedTabContents();
|
||||||
@ -851,11 +825,11 @@ static const wchar_t* jscript_click_option_button =
|
|||||||
// Disabled. See http://crbug.com/26948 for details.
|
// Disabled. See http://crbug.com/26948 for details.
|
||||||
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, DISABLED_OptionsPage) {
|
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, DISABLED_OptionsPage) {
|
||||||
// Install an extension with an options page.
|
// Install an extension with an options page.
|
||||||
const Extension* extension =
|
ASSERT_TRUE(InstallExtension(test_data_dir_.AppendASCII("options.crx"), 1));
|
||||||
InstallExtension(test_data_dir_.AppendASCII("options.crx"), 1);
|
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
ExtensionService* service = browser()->profile()->GetExtensionService();
|
ExtensionService* service = browser()->profile()->GetExtensionService();
|
||||||
ASSERT_EQ(1u, service->extensions()->size());
|
const ExtensionList* extensions = service->extensions();
|
||||||
|
ASSERT_EQ(1u, extensions->size());
|
||||||
|
const Extension* extension = extensions->at(0);
|
||||||
|
|
||||||
// Go to the Extension Settings page and click the Options button.
|
// Go to the Extension Settings page and click the Options button.
|
||||||
ui_test_utils::NavigateToURL(
|
ui_test_utils::NavigateToURL(
|
||||||
|
@ -156,9 +156,9 @@ class ExtensionContextMenuBrowserTest : public ExtensionBrowserTest {
|
|||||||
// Returns a pointer to the currently loaded extension with |name|, or null
|
// Returns a pointer to the currently loaded extension with |name|, or null
|
||||||
// if not found.
|
// if not found.
|
||||||
const Extension* GetExtensionNamed(std::string name) {
|
const Extension* GetExtensionNamed(std::string name) {
|
||||||
const ExtensionSet* extensions =
|
const ExtensionList* extensions =
|
||||||
browser()->profile()->GetExtensionService()->extensions();
|
browser()->profile()->GetExtensionService()->extensions();
|
||||||
ExtensionSet::const_iterator i;
|
ExtensionList::const_iterator i;
|
||||||
for (i = extensions->begin(); i != extensions->end(); ++i) {
|
for (i = extensions->begin(); i != extensions->end(); ++i) {
|
||||||
if ((*i)->name() == name) {
|
if ((*i)->name() == name) {
|
||||||
return *i;
|
return *i;
|
||||||
|
@ -62,10 +62,12 @@ class ExtensionCrashRecoveryTest : public ExtensionBrowserTest {
|
|||||||
return balloons.size();
|
return balloons.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrashExtension(std::string extension_id) {
|
void CrashExtension(size_t index) {
|
||||||
|
ASSERT_LT(index, GetExtensionService()->extensions()->size());
|
||||||
const Extension* extension =
|
const Extension* extension =
|
||||||
GetExtensionService()->extensions()->GetByID(extension_id);
|
GetExtensionService()->extensions()->at(index);
|
||||||
ASSERT_TRUE(extension);
|
ASSERT_TRUE(extension);
|
||||||
|
std::string extension_id(extension->id());
|
||||||
ExtensionHost* extension_host = GetExtensionProcessManager()->
|
ExtensionHost* extension_host = GetExtensionProcessManager()->
|
||||||
GetBackgroundHostForExtension(extension_id);
|
GetBackgroundHostForExtension(extension_id);
|
||||||
ASSERT_TRUE(extension_host);
|
ASSERT_TRUE(extension_host);
|
||||||
@ -79,36 +81,43 @@ class ExtensionCrashRecoveryTest : public ExtensionBrowserTest {
|
|||||||
GetBackgroundHostForExtension(extension_id));
|
GetBackgroundHostForExtension(extension_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckExtensionConsistency(std::string extension_id) {
|
void CheckExtensionConsistency(size_t index) {
|
||||||
|
ASSERT_LT(index, GetExtensionService()->extensions()->size());
|
||||||
const Extension* extension =
|
const Extension* extension =
|
||||||
GetExtensionService()->extensions()->GetByID(extension_id);
|
GetExtensionService()->extensions()->at(index);
|
||||||
ASSERT_TRUE(extension);
|
ASSERT_TRUE(extension);
|
||||||
ExtensionHost* extension_host = GetExtensionProcessManager()->
|
ExtensionHost* extension_host = GetExtensionProcessManager()->
|
||||||
GetBackgroundHostForExtension(extension_id);
|
GetBackgroundHostForExtension(extension->id());
|
||||||
ASSERT_TRUE(extension_host);
|
ASSERT_TRUE(extension_host);
|
||||||
ASSERT_TRUE(GetExtensionProcessManager()->HasExtensionHost(extension_host));
|
ASSERT_TRUE(GetExtensionProcessManager()->HasExtensionHost(extension_host));
|
||||||
ASSERT_TRUE(extension_host->IsRenderViewLive());
|
ASSERT_TRUE(extension_host->IsRenderViewLive());
|
||||||
extensions::ProcessMap* process_map =
|
extensions::ProcessMap* process_map =
|
||||||
browser()->profile()->GetExtensionService()->process_map();
|
browser()->profile()->GetExtensionService()->process_map();
|
||||||
ASSERT_TRUE(process_map->Contains(
|
ASSERT_TRUE(process_map->Contains(
|
||||||
extension_id, extension_host->render_view_host()->process()->GetID()));
|
extension->id(), extension_host->render_view_host()->process()->
|
||||||
|
GetID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadTestExtension() {
|
void LoadTestExtension() {
|
||||||
ExtensionBrowserTest::SetUpInProcessBrowserTestFixture();
|
ExtensionBrowserTest::SetUpInProcessBrowserTestFixture();
|
||||||
const Extension* extension = LoadExtension(
|
const size_t size_before = GetExtensionService()->extensions()->size();
|
||||||
test_data_dir_.AppendASCII("common").AppendASCII("background_page"));
|
ASSERT_TRUE(LoadExtension(
|
||||||
|
test_data_dir_.AppendASCII("common").AppendASCII("background_page")));
|
||||||
|
const Extension* extension = GetExtensionService()->extensions()->back();
|
||||||
ASSERT_TRUE(extension);
|
ASSERT_TRUE(extension);
|
||||||
first_extension_id_ = extension->id();
|
first_extension_id_ = extension->id();
|
||||||
CheckExtensionConsistency(first_extension_id_);
|
CheckExtensionConsistency(size_before);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadSecondExtension() {
|
void LoadSecondExtension() {
|
||||||
const Extension* extension = LoadExtension(
|
int offset = GetExtensionService()->extensions()->size();
|
||||||
test_data_dir_.AppendASCII("install").AppendASCII("install"));
|
ASSERT_TRUE(LoadExtension(
|
||||||
|
test_data_dir_.AppendASCII("install").AppendASCII("install")));
|
||||||
|
const Extension* extension =
|
||||||
|
GetExtensionService()->extensions()->at(offset);
|
||||||
ASSERT_TRUE(extension);
|
ASSERT_TRUE(extension);
|
||||||
second_extension_id_ = extension->id();
|
second_extension_id_ = extension->id();
|
||||||
CheckExtensionConsistency(second_extension_id_);
|
CheckExtensionConsistency(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string first_extension_id_;
|
std::string first_extension_id_;
|
||||||
@ -120,14 +129,14 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, Basic) {
|
|||||||
const size_t crash_size_before =
|
const size_t crash_size_before =
|
||||||
GetExtensionService()->terminated_extensions()->size();
|
GetExtensionService()->terminated_extensions()->size();
|
||||||
LoadTestExtension();
|
LoadTestExtension();
|
||||||
CrashExtension(first_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
||||||
ASSERT_EQ(crash_size_before + 1,
|
ASSERT_EQ(crash_size_before + 1,
|
||||||
GetExtensionService()->terminated_extensions()->size());
|
GetExtensionService()->terminated_extensions()->size());
|
||||||
AcceptNotification(0);
|
AcceptNotification(0);
|
||||||
|
|
||||||
SCOPED_TRACE("after clicking the balloon");
|
SCOPED_TRACE("after clicking the balloon");
|
||||||
CheckExtensionConsistency(first_extension_id_);
|
CheckExtensionConsistency(size_before);
|
||||||
ASSERT_EQ(crash_size_before,
|
ASSERT_EQ(crash_size_before,
|
||||||
GetExtensionService()->terminated_extensions()->size());
|
GetExtensionService()->terminated_extensions()->size());
|
||||||
}
|
}
|
||||||
@ -137,7 +146,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, CloseAndReload) {
|
|||||||
const size_t crash_size_before =
|
const size_t crash_size_before =
|
||||||
GetExtensionService()->terminated_extensions()->size();
|
GetExtensionService()->terminated_extensions()->size();
|
||||||
LoadTestExtension();
|
LoadTestExtension();
|
||||||
CrashExtension(first_extension_id_);
|
CrashExtension(size_before);
|
||||||
|
|
||||||
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
||||||
ASSERT_EQ(crash_size_before + 1,
|
ASSERT_EQ(crash_size_before + 1,
|
||||||
@ -147,7 +156,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, CloseAndReload) {
|
|||||||
ReloadExtension(first_extension_id_);
|
ReloadExtension(first_extension_id_);
|
||||||
|
|
||||||
SCOPED_TRACE("after reloading");
|
SCOPED_TRACE("after reloading");
|
||||||
CheckExtensionConsistency(first_extension_id_);
|
CheckExtensionConsistency(size_before);
|
||||||
ASSERT_EQ(crash_size_before,
|
ASSERT_EQ(crash_size_before,
|
||||||
GetExtensionService()->terminated_extensions()->size());
|
GetExtensionService()->terminated_extensions()->size());
|
||||||
}
|
}
|
||||||
@ -155,13 +164,13 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, CloseAndReload) {
|
|||||||
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, ReloadIndependently) {
|
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, ReloadIndependently) {
|
||||||
const size_t size_before = GetExtensionService()->extensions()->size();
|
const size_t size_before = GetExtensionService()->extensions()->size();
|
||||||
LoadTestExtension();
|
LoadTestExtension();
|
||||||
CrashExtension(first_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
||||||
|
|
||||||
ReloadExtension(first_extension_id_);
|
ReloadExtension(first_extension_id_);
|
||||||
|
|
||||||
SCOPED_TRACE("after reloading");
|
SCOPED_TRACE("after reloading");
|
||||||
CheckExtensionConsistency(first_extension_id_);
|
CheckExtensionConsistency(size_before);
|
||||||
|
|
||||||
TabContents* current_tab = browser()->GetSelectedTabContents();
|
TabContents* current_tab = browser()->GetSelectedTabContents();
|
||||||
ASSERT_TRUE(current_tab);
|
ASSERT_TRUE(current_tab);
|
||||||
@ -175,7 +184,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
|||||||
ReloadIndependentlyChangeTabs) {
|
ReloadIndependentlyChangeTabs) {
|
||||||
const size_t size_before = GetExtensionService()->extensions()->size();
|
const size_t size_before = GetExtensionService()->extensions()->size();
|
||||||
LoadTestExtension();
|
LoadTestExtension();
|
||||||
CrashExtension(first_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
||||||
|
|
||||||
TabContents* original_tab = browser()->GetSelectedTabContents();
|
TabContents* original_tab = browser()->GetSelectedTabContents();
|
||||||
@ -192,7 +201,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
|||||||
ReloadExtension(first_extension_id_);
|
ReloadExtension(first_extension_id_);
|
||||||
|
|
||||||
SCOPED_TRACE("after reloading");
|
SCOPED_TRACE("after reloading");
|
||||||
CheckExtensionConsistency(first_extension_id_);
|
CheckExtensionConsistency(size_before);
|
||||||
|
|
||||||
// The balloon should automatically hide after the extension is successfully
|
// The balloon should automatically hide after the extension is successfully
|
||||||
// reloaded.
|
// reloaded.
|
||||||
@ -203,7 +212,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
|||||||
ReloadIndependentlyNavigatePage) {
|
ReloadIndependentlyNavigatePage) {
|
||||||
const size_t size_before = GetExtensionService()->extensions()->size();
|
const size_t size_before = GetExtensionService()->extensions()->size();
|
||||||
LoadTestExtension();
|
LoadTestExtension();
|
||||||
CrashExtension(first_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
||||||
|
|
||||||
TabContents* current_tab = browser()->GetSelectedTabContents();
|
TabContents* current_tab = browser()->GetSelectedTabContents();
|
||||||
@ -219,7 +228,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
|||||||
ReloadExtension(first_extension_id_);
|
ReloadExtension(first_extension_id_);
|
||||||
|
|
||||||
SCOPED_TRACE("after reloading");
|
SCOPED_TRACE("after reloading");
|
||||||
CheckExtensionConsistency(first_extension_id_);
|
CheckExtensionConsistency(size_before);
|
||||||
|
|
||||||
// The balloon should automatically hide after the extension is successfully
|
// The balloon should automatically hide after the extension is successfully
|
||||||
// reloaded.
|
// reloaded.
|
||||||
@ -240,7 +249,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
|||||||
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, MAYBE_ShutdownWhileCrashed) {
|
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, MAYBE_ShutdownWhileCrashed) {
|
||||||
const size_t size_before = GetExtensionService()->extensions()->size();
|
const size_t size_before = GetExtensionService()->extensions()->size();
|
||||||
LoadTestExtension();
|
LoadTestExtension();
|
||||||
CrashExtension(first_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,26 +257,26 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, TwoExtensionsCrashFirst) {
|
|||||||
const size_t size_before = GetExtensionService()->extensions()->size();
|
const size_t size_before = GetExtensionService()->extensions()->size();
|
||||||
LoadTestExtension();
|
LoadTestExtension();
|
||||||
LoadSecondExtension();
|
LoadSecondExtension();
|
||||||
CrashExtension(first_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
||||||
AcceptNotification(0);
|
AcceptNotification(0);
|
||||||
|
|
||||||
SCOPED_TRACE("after clicking the balloon");
|
SCOPED_TRACE("after clicking the balloon");
|
||||||
CheckExtensionConsistency(first_extension_id_);
|
CheckExtensionConsistency(size_before);
|
||||||
CheckExtensionConsistency(second_extension_id_);
|
CheckExtensionConsistency(size_before + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, TwoExtensionsCrashSecond) {
|
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, TwoExtensionsCrashSecond) {
|
||||||
const size_t size_before = GetExtensionService()->extensions()->size();
|
const size_t size_before = GetExtensionService()->extensions()->size();
|
||||||
LoadTestExtension();
|
LoadTestExtension();
|
||||||
LoadSecondExtension();
|
LoadSecondExtension();
|
||||||
CrashExtension(second_extension_id_);
|
CrashExtension(size_before + 1);
|
||||||
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
||||||
AcceptNotification(0);
|
AcceptNotification(0);
|
||||||
|
|
||||||
SCOPED_TRACE("after clicking the balloon");
|
SCOPED_TRACE("after clicking the balloon");
|
||||||
CheckExtensionConsistency(first_extension_id_);
|
CheckExtensionConsistency(size_before);
|
||||||
CheckExtensionConsistency(second_extension_id_);
|
CheckExtensionConsistency(size_before + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
||||||
@ -277,11 +286,11 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
|||||||
GetExtensionService()->terminated_extensions()->size();
|
GetExtensionService()->terminated_extensions()->size();
|
||||||
LoadTestExtension();
|
LoadTestExtension();
|
||||||
LoadSecondExtension();
|
LoadSecondExtension();
|
||||||
CrashExtension(first_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
||||||
ASSERT_EQ(crash_size_before + 1,
|
ASSERT_EQ(crash_size_before + 1,
|
||||||
GetExtensionService()->terminated_extensions()->size());
|
GetExtensionService()->terminated_extensions()->size());
|
||||||
CrashExtension(second_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
||||||
ASSERT_EQ(crash_size_before + 2,
|
ASSERT_EQ(crash_size_before + 2,
|
||||||
GetExtensionService()->terminated_extensions()->size());
|
GetExtensionService()->terminated_extensions()->size());
|
||||||
@ -289,37 +298,37 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
|||||||
{
|
{
|
||||||
SCOPED_TRACE("first balloon");
|
SCOPED_TRACE("first balloon");
|
||||||
AcceptNotification(0);
|
AcceptNotification(0);
|
||||||
CheckExtensionConsistency(first_extension_id_);
|
CheckExtensionConsistency(size_before);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SCOPED_TRACE("second balloon");
|
SCOPED_TRACE("second balloon");
|
||||||
AcceptNotification(0);
|
AcceptNotification(0);
|
||||||
CheckExtensionConsistency(first_extension_id_);
|
CheckExtensionConsistency(size_before);
|
||||||
CheckExtensionConsistency(second_extension_id_);
|
CheckExtensionConsistency(size_before + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, TwoExtensionsOneByOne) {
|
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, TwoExtensionsOneByOne) {
|
||||||
const size_t size_before = GetExtensionService()->extensions()->size();
|
const size_t size_before = GetExtensionService()->extensions()->size();
|
||||||
LoadTestExtension();
|
LoadTestExtension();
|
||||||
CrashExtension(first_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
||||||
LoadSecondExtension();
|
LoadSecondExtension();
|
||||||
CrashExtension(second_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
||||||
|
|
||||||
{
|
{
|
||||||
SCOPED_TRACE("first balloon");
|
SCOPED_TRACE("first balloon");
|
||||||
AcceptNotification(0);
|
AcceptNotification(0);
|
||||||
CheckExtensionConsistency(first_extension_id_);
|
CheckExtensionConsistency(size_before);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SCOPED_TRACE("second balloon");
|
SCOPED_TRACE("second balloon");
|
||||||
AcceptNotification(0);
|
AcceptNotification(0);
|
||||||
CheckExtensionConsistency(first_extension_id_);
|
CheckExtensionConsistency(size_before);
|
||||||
CheckExtensionConsistency(second_extension_id_);
|
CheckExtensionConsistency(size_before + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,10 +348,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
|||||||
MAYBE_TwoExtensionsShutdownWhileCrashed) {
|
MAYBE_TwoExtensionsShutdownWhileCrashed) {
|
||||||
const size_t size_before = GetExtensionService()->extensions()->size();
|
const size_t size_before = GetExtensionService()->extensions()->size();
|
||||||
LoadTestExtension();
|
LoadTestExtension();
|
||||||
CrashExtension(first_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
||||||
LoadSecondExtension();
|
LoadSecondExtension();
|
||||||
CrashExtension(second_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,9 +360,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
|||||||
const size_t size_before = GetExtensionService()->extensions()->size();
|
const size_t size_before = GetExtensionService()->extensions()->size();
|
||||||
LoadTestExtension();
|
LoadTestExtension();
|
||||||
LoadSecondExtension();
|
LoadSecondExtension();
|
||||||
CrashExtension(first_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
||||||
CrashExtension(second_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
||||||
|
|
||||||
// Accept notification 1 before canceling notification 0.
|
// Accept notification 1 before canceling notification 0.
|
||||||
@ -364,7 +373,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
|||||||
|
|
||||||
SCOPED_TRACE("balloons done");
|
SCOPED_TRACE("balloons done");
|
||||||
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
||||||
CheckExtensionConsistency(second_extension_id_);
|
EXPECT_EQ(second_extension_id_,
|
||||||
|
GetExtensionService()->extensions()->at(size_before)->id());
|
||||||
|
CheckExtensionConsistency(size_before);
|
||||||
}
|
}
|
||||||
|
|
||||||
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
||||||
@ -372,9 +383,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
|||||||
const size_t size_before = GetExtensionService()->extensions()->size();
|
const size_t size_before = GetExtensionService()->extensions()->size();
|
||||||
LoadTestExtension();
|
LoadTestExtension();
|
||||||
LoadSecondExtension();
|
LoadSecondExtension();
|
||||||
CrashExtension(first_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
||||||
CrashExtension(second_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -386,14 +397,14 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
|||||||
ReloadExtension(first_extension_id_);
|
ReloadExtension(first_extension_id_);
|
||||||
// One of the balloons should hide after the extension is reloaded.
|
// One of the balloons should hide after the extension is reloaded.
|
||||||
ASSERT_EQ(1U, CountBalloons());
|
ASSERT_EQ(1U, CountBalloons());
|
||||||
CheckExtensionConsistency(first_extension_id_);
|
CheckExtensionConsistency(size_before);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SCOPED_TRACE("second: balloon");
|
SCOPED_TRACE("second: balloon");
|
||||||
AcceptNotification(0);
|
AcceptNotification(0);
|
||||||
CheckExtensionConsistency(first_extension_id_);
|
CheckExtensionConsistency(size_before);
|
||||||
CheckExtensionConsistency(second_extension_id_);
|
CheckExtensionConsistency(size_before + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +414,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, CrashAndUninstall) {
|
|||||||
GetExtensionService()->terminated_extensions()->size();
|
GetExtensionService()->terminated_extensions()->size();
|
||||||
LoadTestExtension();
|
LoadTestExtension();
|
||||||
LoadSecondExtension();
|
LoadSecondExtension();
|
||||||
CrashExtension(first_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
||||||
ASSERT_EQ(crash_size_before + 1,
|
ASSERT_EQ(crash_size_before + 1,
|
||||||
GetExtensionService()->terminated_extensions()->size());
|
GetExtensionService()->terminated_extensions()->size());
|
||||||
@ -432,7 +443,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, MAYBE_CrashAndUnloadAll) {
|
|||||||
GetExtensionService()->terminated_extensions()->size();
|
GetExtensionService()->terminated_extensions()->size();
|
||||||
LoadTestExtension();
|
LoadTestExtension();
|
||||||
LoadSecondExtension();
|
LoadSecondExtension();
|
||||||
CrashExtension(first_extension_id_);
|
CrashExtension(size_before);
|
||||||
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
||||||
ASSERT_EQ(crash_size_before + 1,
|
ASSERT_EQ(crash_size_before + 1,
|
||||||
GetExtensionService()->terminated_extensions()->size());
|
GetExtensionService()->terminated_extensions()->size());
|
||||||
@ -460,7 +471,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
|||||||
GURL("chrome-extension://" + first_extension_id_ + "/background.html"));
|
GURL("chrome-extension://" + first_extension_id_ + "/background.html"));
|
||||||
|
|
||||||
const int tabs_before = tab_strip->count();
|
const int tabs_before = tab_strip->count();
|
||||||
CrashExtension(first_extension_id_);
|
CrashExtension(size_before);
|
||||||
|
|
||||||
// Tab should still be open, and extension should be crashed.
|
// Tab should still be open, and extension should be crashed.
|
||||||
EXPECT_EQ(tabs_before, tab_strip->count());
|
EXPECT_EQ(tabs_before, tab_strip->count());
|
||||||
@ -477,8 +488,6 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
|
|||||||
observer.Wait();
|
observer.Wait();
|
||||||
}
|
}
|
||||||
// Extension should now be loaded.
|
// Extension should now be loaded.
|
||||||
SCOPED_TRACE("after reloading the tab");
|
|
||||||
CheckExtensionConsistency(first_extension_id_);
|
|
||||||
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
|
||||||
ASSERT_EQ(0U, CountBalloons());
|
ASSERT_EQ(0U, CountBalloons());
|
||||||
}
|
}
|
||||||
|
@ -130,10 +130,10 @@ bool GetFileBrowserHandlers(Profile* profile,
|
|||||||
if (!service)
|
if (!service)
|
||||||
return false; // In unit-tests, we may not have an ExtensionService.
|
return false; // In unit-tests, we may not have an ExtensionService.
|
||||||
|
|
||||||
for (ExtensionSet::const_iterator iter = service->extensions()->begin();
|
for (ExtensionList::const_iterator iter = service->extensions()->begin();
|
||||||
iter != service->extensions()->end();
|
iter != service->extensions()->end();
|
||||||
++iter) {
|
++iter) {
|
||||||
const Extension* extension = *iter;
|
const Extension* extension = iter->get();
|
||||||
if (!extension->file_browser_handlers())
|
if (!extension->file_browser_handlers())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -138,11 +138,11 @@ bool ExtensionInfoMap::SecurityOriginHasAPIPermission(
|
|||||||
process_map_.Contains(id, process_id);
|
process_map_.Contains(id, process_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtensionSet::const_iterator i = extensions_.begin();
|
ExtensionSet::ExtensionMap::const_iterator i = extensions_.begin();
|
||||||
for (; i != extensions_.end(); ++i) {
|
for (; i != extensions_.end(); ++i) {
|
||||||
if ((*i)->web_extent().MatchesSecurityOrigin(origin) &&
|
if (i->second->web_extent().MatchesSecurityOrigin(origin) &&
|
||||||
process_map_.Contains((*i)->id(), process_id) &&
|
process_map_.Contains(i->first, process_id) &&
|
||||||
(*i)->HasAPIPermission(permission)) {
|
i->second->HasAPIPermission(permission)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,10 +123,10 @@ static DictionaryValue* CreateExtensionInfo(const Extension& extension,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void AddExtensionInfo(ListValue* list,
|
static void AddExtensionInfo(ListValue* list,
|
||||||
const ExtensionSet& extensions,
|
const ExtensionList& extensions,
|
||||||
bool enabled,
|
bool enabled,
|
||||||
ExtensionPrefs* prefs) {
|
ExtensionPrefs* prefs) {
|
||||||
for (ExtensionSet::const_iterator i = extensions.begin();
|
for (ExtensionList::const_iterator i = extensions.begin();
|
||||||
i != extensions.end(); ++i) {
|
i != extensions.end(); ++i) {
|
||||||
const Extension& extension = **i;
|
const Extension& extension = **i;
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, AutoUpdate) {
|
|||||||
ExtensionTestMessageListener listener1("v1 installed", false);
|
ExtensionTestMessageListener listener1("v1 installed", false);
|
||||||
ExtensionService* service = browser()->profile()->GetExtensionService();
|
ExtensionService* service = browser()->profile()->GetExtensionService();
|
||||||
const size_t size_before = service->extensions()->size();
|
const size_t size_before = service->extensions()->size();
|
||||||
ASSERT_TRUE(service->disabled_extensions()->is_empty());
|
ASSERT_TRUE(service->disabled_extensions()->empty());
|
||||||
const Extension* extension =
|
const Extension* extension =
|
||||||
InstallExtension(basedir.AppendASCII("v1.crx"), 1);
|
InstallExtension(basedir.AppendASCII("v1.crx"), 1);
|
||||||
ASSERT_TRUE(extension);
|
ASSERT_TRUE(extension);
|
||||||
@ -382,7 +382,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalUrlUpdate) {
|
|||||||
basedir.AppendASCII("v2.crx"));
|
basedir.AppendASCII("v2.crx"));
|
||||||
|
|
||||||
const size_t size_before = service->extensions()->size();
|
const size_t size_before = service->extensions()->size();
|
||||||
ASSERT_TRUE(service->disabled_extensions()->is_empty());
|
ASSERT_TRUE(service->disabled_extensions()->empty());
|
||||||
|
|
||||||
PendingExtensionManager* pending_extension_manager =
|
PendingExtensionManager* pending_extension_manager =
|
||||||
service->pending_extension_manager();
|
service->pending_extension_manager();
|
||||||
@ -465,7 +465,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalPolicyRefresh) {
|
|||||||
basedir.AppendASCII("v2.crx"));
|
basedir.AppendASCII("v2.crx"));
|
||||||
|
|
||||||
const size_t size_before = service->extensions()->size();
|
const size_t size_before = service->extensions()->size();
|
||||||
ASSERT_TRUE(service->disabled_extensions()->is_empty());
|
ASSERT_TRUE(service->disabled_extensions()->empty());
|
||||||
|
|
||||||
PrefService* prefs = browser()->profile()->GetPrefs();
|
PrefService* prefs = browser()->profile()->GetPrefs();
|
||||||
const ListValue* forcelist =
|
const ListValue* forcelist =
|
||||||
@ -520,7 +520,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, PolicyOverridesUserInstall) {
|
|||||||
service->updater()->set_blacklist_checks_enabled(false);
|
service->updater()->set_blacklist_checks_enabled(false);
|
||||||
const size_t size_before = service->extensions()->size();
|
const size_t size_before = service->extensions()->size();
|
||||||
FilePath basedir = test_data_dir_.AppendASCII("autoupdate");
|
FilePath basedir = test_data_dir_.AppendASCII("autoupdate");
|
||||||
ASSERT_TRUE(service->disabled_extensions()->is_empty());
|
ASSERT_TRUE(service->disabled_extensions()->empty());
|
||||||
|
|
||||||
// Note: This interceptor gets requests on the IO thread.
|
// Note: This interceptor gets requests on the IO thread.
|
||||||
scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor());
|
scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor());
|
||||||
@ -581,7 +581,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, PolicyOverridesUserInstall) {
|
|||||||
ASSERT_TRUE(extension);
|
ASSERT_TRUE(extension);
|
||||||
EXPECT_EQ(Extension::INTERNAL, extension->location());
|
EXPECT_EQ(Extension::INTERNAL, extension->location());
|
||||||
EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
|
EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
|
||||||
EXPECT_TRUE(service->disabled_extensions()->is_empty());
|
EXPECT_TRUE(service->disabled_extensions()->empty());
|
||||||
|
|
||||||
service->DisableExtension(kExtensionId);
|
service->DisableExtension(kExtensionId);
|
||||||
EXPECT_EQ(1u, service->disabled_extensions()->size());
|
EXPECT_EQ(1u, service->disabled_extensions()->size());
|
||||||
@ -604,5 +604,5 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, PolicyOverridesUserInstall) {
|
|||||||
ASSERT_TRUE(extension);
|
ASSERT_TRUE(extension);
|
||||||
EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, extension->location());
|
EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, extension->location());
|
||||||
EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
|
EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
|
||||||
EXPECT_TRUE(service->disabled_extensions()->is_empty());
|
EXPECT_TRUE(service->disabled_extensions()->empty());
|
||||||
}
|
}
|
||||||
|
@ -114,16 +114,15 @@ IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, MAYBE_OverrideHistory) {
|
|||||||
|
|
||||||
// Regression test for http://crbug.com/41442.
|
// Regression test for http://crbug.com/41442.
|
||||||
IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldNotCreateDuplicateEntries) {
|
IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldNotCreateDuplicateEntries) {
|
||||||
const Extension* extension =
|
ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history")));
|
||||||
LoadExtension(test_data_dir_.AppendASCII("override/history"));
|
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
|
|
||||||
// Simulate several LoadExtension() calls happening over the lifetime of
|
// Simulate several LoadExtension() calls happening over the lifetime of
|
||||||
// a preferences file without corresponding UnloadExtension() calls.
|
// a preferences file without corresponding UnloadExtension() calls.
|
||||||
for (size_t i = 0; i < 3; ++i) {
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
ExtensionWebUI::RegisterChromeURLOverrides(
|
ExtensionWebUI::RegisterChromeURLOverrides(
|
||||||
browser()->profile(),
|
browser()->profile(),
|
||||||
extension->GetChromeURLOverrides());
|
browser()->profile()->GetExtensionService()->extensions()->back()->
|
||||||
|
GetChromeURLOverrides());
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes());
|
ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes());
|
||||||
@ -161,9 +160,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideKeyboard) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load the failing version. This should take precedence.
|
// Load the failing version. This should take precedence.
|
||||||
const Extension* extension = LoadExtension(
|
ASSERT_TRUE(LoadExtension(
|
||||||
test_data_dir_.AppendASCII("override").AppendASCII("keyboard_fails"));
|
test_data_dir_.AppendASCII("override").AppendASCII("keyboard_fails")));
|
||||||
ASSERT_TRUE(extension);
|
|
||||||
{
|
{
|
||||||
ResultCatcher catcher;
|
ResultCatcher catcher;
|
||||||
NavigateToKeyboard();
|
NavigateToKeyboard();
|
||||||
@ -171,7 +169,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideKeyboard) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unload the failing version. We should be back to passing now.
|
// Unload the failing version. We should be back to passing now.
|
||||||
UnloadExtension(extension->id());
|
const ExtensionList *extensions =
|
||||||
|
browser()->profile()->GetExtensionService()->extensions();
|
||||||
|
UnloadExtension((*extensions->rbegin())->id());
|
||||||
{
|
{
|
||||||
ResultCatcher catcher;
|
ResultCatcher catcher;
|
||||||
NavigateToKeyboard();
|
NavigateToKeyboard();
|
||||||
|
@ -309,8 +309,8 @@ void ExtensionPreferenceEventRouter::OnPrefChanged(
|
|||||||
ExtensionEventRouter* router = profile_->GetExtensionEventRouter();
|
ExtensionEventRouter* router = profile_->GetExtensionEventRouter();
|
||||||
if (!router || !router->HasEventListener(event_name))
|
if (!router || !router->HasEventListener(event_name))
|
||||||
return;
|
return;
|
||||||
const ExtensionSet* extensions = extension_service->extensions();
|
const ExtensionList* extensions = extension_service->extensions();
|
||||||
for (ExtensionSet::const_iterator it = extensions->begin();
|
for (ExtensionList::const_iterator it = extensions->begin();
|
||||||
it != extensions->end(); ++it) {
|
it != extensions->end(); ++it) {
|
||||||
std::string extension_id = (*it)->id();
|
std::string extension_id = (*it)->id();
|
||||||
// TODO(bauerb): Only iterate over registered event listeners.
|
// TODO(bauerb): Only iterate over registered event listeners.
|
||||||
|
@ -74,8 +74,8 @@ static void CreateBackgroundHostForExtensionLoad(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void CreateBackgroundHostsForProfileStartup(
|
static void CreateBackgroundHostsForProfileStartup(
|
||||||
ExtensionProcessManager* manager, const ExtensionSet* extensions) {
|
ExtensionProcessManager* manager, const ExtensionList* extensions) {
|
||||||
for (ExtensionSet::const_iterator extension = extensions->begin();
|
for (ExtensionList::const_iterator extension = extensions->begin();
|
||||||
extension != extensions->end(); ++extension) {
|
extension != extensions->end(); ++extension) {
|
||||||
CreateBackgroundHostForExtensionLoad(manager, *extension);
|
CreateBackgroundHostForExtensionLoad(manager, *extension);
|
||||||
}
|
}
|
||||||
|
@ -444,15 +444,15 @@ ExtensionService::ExtensionService(Profile* profile,
|
|||||||
install_directory_.value().length(), 0, 500, 100);
|
install_directory_.value().length(), 0, 500, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExtensionSet* ExtensionService::extensions() const {
|
const ExtensionList* ExtensionService::extensions() const {
|
||||||
return &extensions_;
|
return &extensions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExtensionSet* ExtensionService::disabled_extensions() const {
|
const ExtensionList* ExtensionService::disabled_extensions() const {
|
||||||
return &disabled_extensions_;
|
return &disabled_extensions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExtensionSet* ExtensionService::terminated_extensions() const {
|
const ExtensionList* ExtensionService::terminated_extensions() const {
|
||||||
return &terminated_extensions_;
|
return &terminated_extensions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -766,11 +766,14 @@ bool ExtensionService::UninstallExtension(
|
|||||||
|
|
||||||
bool ExtensionService::IsExtensionEnabled(
|
bool ExtensionService::IsExtensionEnabled(
|
||||||
const std::string& extension_id) const {
|
const std::string& extension_id) const {
|
||||||
if (extensions_.Contains(extension_id) ||
|
const Extension* extension =
|
||||||
terminated_extensions_.Contains(extension_id))
|
GetExtensionByIdInternal(extension_id, true, false, true);
|
||||||
|
if (extension)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (disabled_extensions_.Contains(extension_id))
|
extension =
|
||||||
|
GetExtensionByIdInternal(extension_id, false, true, false);
|
||||||
|
if (extension)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If the extension hasn't been loaded yet, check the prefs for it. Assume
|
// If the extension hasn't been loaded yet, check the prefs for it. Assume
|
||||||
@ -800,8 +803,11 @@ void ExtensionService::EnableExtension(const std::string& extension_id) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Move it over to the enabled list.
|
// Move it over to the enabled list.
|
||||||
extensions_.Insert(make_scoped_refptr(extension));
|
extensions_.push_back(make_scoped_refptr(extension));
|
||||||
disabled_extensions_.Remove(extension->id());
|
ExtensionList::iterator iter = std::find(disabled_extensions_.begin(),
|
||||||
|
disabled_extensions_.end(),
|
||||||
|
extension);
|
||||||
|
disabled_extensions_.erase(iter);
|
||||||
|
|
||||||
// Make sure any browser action contained within it is not hidden.
|
// Make sure any browser action contained within it is not hidden.
|
||||||
extension_prefs_->SetBrowserActionVisibility(extension, true);
|
extension_prefs_->SetBrowserActionVisibility(extension, true);
|
||||||
@ -831,11 +837,18 @@ void ExtensionService::DisableExtension(const std::string& extension_id) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Move it over to the disabled list.
|
// Move it over to the disabled list.
|
||||||
disabled_extensions_.Insert(make_scoped_refptr(extension));
|
disabled_extensions_.push_back(make_scoped_refptr(extension));
|
||||||
if (extensions_.Contains(extension->id()))
|
ExtensionList::iterator iter = std::find(extensions_.begin(),
|
||||||
extensions_.Remove(extension->id());
|
extensions_.end(),
|
||||||
else
|
extension);
|
||||||
terminated_extensions_.Remove(extension->id());
|
if (iter != extensions_.end()) {
|
||||||
|
extensions_.erase(iter);
|
||||||
|
} else {
|
||||||
|
iter = std::find(terminated_extensions_.begin(),
|
||||||
|
terminated_extensions_.end(),
|
||||||
|
extension);
|
||||||
|
terminated_extensions_.erase(iter);
|
||||||
|
}
|
||||||
|
|
||||||
NotifyExtensionUnloaded(extension, extension_misc::UNLOAD_REASON_DISABLE);
|
NotifyExtensionUnloaded(extension, extension_misc::UNLOAD_REASON_DISABLE);
|
||||||
|
|
||||||
@ -1102,7 +1115,7 @@ void ExtensionService::UpdateExtensionBlacklist(
|
|||||||
extension_prefs_->UpdateBlacklist(blacklist_set);
|
extension_prefs_->UpdateBlacklist(blacklist_set);
|
||||||
std::vector<std::string> to_be_removed;
|
std::vector<std::string> to_be_removed;
|
||||||
// Loop current extensions, unload installed extensions.
|
// Loop current extensions, unload installed extensions.
|
||||||
for (ExtensionSet::const_iterator iter = extensions_.begin();
|
for (ExtensionList::const_iterator iter = extensions_.begin();
|
||||||
iter != extensions_.end(); ++iter) {
|
iter != extensions_.end(); ++iter) {
|
||||||
const Extension* extension = (*iter);
|
const Extension* extension = (*iter);
|
||||||
if (blacklist_set.find(extension->id()) != blacklist_set.end()) {
|
if (blacklist_set.find(extension->id()) != blacklist_set.end()) {
|
||||||
@ -1145,7 +1158,7 @@ ExtensionUpdater* ExtensionService::updater() {
|
|||||||
void ExtensionService::CheckAdminBlacklist() {
|
void ExtensionService::CheckAdminBlacklist() {
|
||||||
std::vector<std::string> to_be_removed;
|
std::vector<std::string> to_be_removed;
|
||||||
// Loop through extensions list, unload installed extensions.
|
// Loop through extensions list, unload installed extensions.
|
||||||
for (ExtensionSet::const_iterator iter = extensions_.begin();
|
for (ExtensionList::const_iterator iter = extensions_.begin();
|
||||||
iter != extensions_.end(); ++iter) {
|
iter != extensions_.end(); ++iter) {
|
||||||
const Extension* extension = (*iter);
|
const Extension* extension = (*iter);
|
||||||
if (!extension_prefs_->IsExtensionAllowedByPolicy(extension->id(),
|
if (!extension_prefs_->IsExtensionAllowedByPolicy(extension->id(),
|
||||||
@ -1346,10 +1359,10 @@ SyncError ExtensionService::ProcessSyncChanges(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ExtensionService::GetSyncDataListHelper(
|
void ExtensionService::GetSyncDataListHelper(
|
||||||
const ExtensionSet& extensions,
|
const ExtensionList& extensions,
|
||||||
const SyncBundle& bundle,
|
const SyncBundle& bundle,
|
||||||
std::vector<ExtensionSyncData>* sync_data_list) const {
|
std::vector<ExtensionSyncData>* sync_data_list) const {
|
||||||
for (ExtensionSet::const_iterator it = extensions.begin();
|
for (ExtensionList::const_iterator it = extensions.begin();
|
||||||
it != extensions.end(); ++it) {
|
it != extensions.end(); ++it) {
|
||||||
const Extension& extension = **it;
|
const Extension& extension = **it;
|
||||||
if (bundle.filter(extension) &&
|
if (bundle.filter(extension) &&
|
||||||
@ -1480,7 +1493,8 @@ void ExtensionService::SetIsIncognitoEnabled(
|
|||||||
|
|
||||||
extension_prefs_->SetIsIncognitoEnabled(extension_id, enabled);
|
extension_prefs_->SetIsIncognitoEnabled(extension_id, enabled);
|
||||||
|
|
||||||
bool extension_is_enabled = extensions_.Contains(extension->id());
|
bool extension_is_enabled = std::find(extensions_.begin(), extensions_.end(),
|
||||||
|
extension) != extensions_.end();
|
||||||
|
|
||||||
// When we reload the extension the ID may be invalidated if we've passed it
|
// When we reload the extension the ID may be invalidated if we've passed it
|
||||||
// by const ref everywhere. Make a copy to be safe.
|
// by const ref everywhere. Make a copy to be safe.
|
||||||
@ -1557,7 +1571,8 @@ void ExtensionService::SetAllowFileAccess(const Extension* extension,
|
|||||||
|
|
||||||
extension_prefs_->SetAllowFileAccess(extension->id(), allow);
|
extension_prefs_->SetAllowFileAccess(extension->id(), allow);
|
||||||
|
|
||||||
bool extension_is_enabled = extensions_.Contains(extension->id());
|
bool extension_is_enabled = std::find(extensions_.begin(), extensions_.end(),
|
||||||
|
extension) != extensions_.end();
|
||||||
if (extension_is_enabled)
|
if (extension_is_enabled)
|
||||||
ReloadExtension(extension->id());
|
ReloadExtension(extension->id());
|
||||||
}
|
}
|
||||||
@ -1661,9 +1676,12 @@ void ExtensionService::IdentifyAlertableExtensions() {
|
|||||||
scoped_ptr<ExtensionGlobalError> global_error(
|
scoped_ptr<ExtensionGlobalError> global_error(
|
||||||
new ExtensionGlobalError(AsWeakPtr()));
|
new ExtensionGlobalError(AsWeakPtr()));
|
||||||
bool needs_alert = false;
|
bool needs_alert = false;
|
||||||
for (ExtensionSet::const_iterator iter = extensions_.begin();
|
for (ExtensionList::const_iterator iter = extensions_.begin();
|
||||||
iter != extensions_.end(); ++iter) {
|
iter != extensions_.end(); ++iter) {
|
||||||
const Extension* e = *iter;
|
const Extension* e = *iter;
|
||||||
|
if (!IsExtensionEnabled(e->id())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (Extension::IsExternalLocation(e->location())) {
|
if (Extension::IsExternalLocation(e->location())) {
|
||||||
if (!extension_prefs_->IsExternalExtensionAcknowledged(e->id())) {
|
if (!extension_prefs_->IsExternalExtensionAcknowledged(e->id())) {
|
||||||
global_error->AddExternalExtension(e->id());
|
global_error->AddExternalExtension(e->id());
|
||||||
@ -1763,10 +1781,13 @@ void ExtensionService::UnloadExtension(
|
|||||||
// Clean up runtime data.
|
// Clean up runtime data.
|
||||||
extension_runtime_data_.erase(extension_id);
|
extension_runtime_data_.erase(extension_id);
|
||||||
|
|
||||||
if (disabled_extensions_.Contains(extension->id())) {
|
ExtensionList::iterator iter = std::find(disabled_extensions_.begin(),
|
||||||
|
disabled_extensions_.end(),
|
||||||
|
extension.get());
|
||||||
|
if (iter != disabled_extensions_.end()) {
|
||||||
UnloadedExtensionInfo details(extension, reason);
|
UnloadedExtensionInfo details(extension, reason);
|
||||||
details.already_disabled = true;
|
details.already_disabled = true;
|
||||||
disabled_extensions_.Remove(extension->id());
|
disabled_extensions_.erase(iter);
|
||||||
content::NotificationService::current()->Notify(
|
content::NotificationService::current()->Notify(
|
||||||
chrome::NOTIFICATION_EXTENSION_UNLOADED,
|
chrome::NOTIFICATION_EXTENSION_UNLOADED,
|
||||||
content::Source<Profile>(profile_),
|
content::Source<Profile>(profile_),
|
||||||
@ -1778,8 +1799,10 @@ if (disabled_extensions_.Contains(extension->id())) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the extension from our list.
|
iter = std::find(extensions_.begin(), extensions_.end(), extension.get());
|
||||||
extensions_.Remove(extension->id());
|
|
||||||
|
// Remove the extension from our list.
|
||||||
|
extensions_.erase(iter);
|
||||||
|
|
||||||
NotifyExtensionUnloaded(extension.get(), reason);
|
NotifyExtensionUnloaded(extension.get(), reason);
|
||||||
}
|
}
|
||||||
@ -1788,9 +1811,10 @@ void ExtensionService::UnloadAllExtensions() {
|
|||||||
profile_->GetExtensionSpecialStoragePolicy()->
|
profile_->GetExtensionSpecialStoragePolicy()->
|
||||||
RevokeRightsForAllExtensions();
|
RevokeRightsForAllExtensions();
|
||||||
|
|
||||||
extensions_.Clear();
|
extensions_.clear();
|
||||||
disabled_extensions_.Clear();
|
disabled_extensions_.clear();
|
||||||
terminated_extensions_.Clear();
|
terminated_extension_ids_.clear();
|
||||||
|
terminated_extensions_.clear();
|
||||||
extension_runtime_data_.clear();
|
extension_runtime_data_.clear();
|
||||||
|
|
||||||
// TODO(erikkay) should there be a notification for this? We can't use
|
// TODO(erikkay) should there be a notification for this? We can't use
|
||||||
@ -1874,10 +1898,10 @@ void ExtensionService::AddExtension(const Extension* extension) {
|
|||||||
|
|
||||||
bool disabled = extension_prefs_->IsExtensionDisabled(extension->id());
|
bool disabled = extension_prefs_->IsExtensionDisabled(extension->id());
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
disabled_extensions_.Insert(scoped_extension);
|
disabled_extensions_.push_back(scoped_extension);
|
||||||
// TODO(aa): This seems dodgy. AddExtension() could get called with a
|
// TODO(aa): This seems dodgy. It seems that AddExtension() could get called
|
||||||
// disabled extension for other reasons other than that an update was
|
// with a disabled extension for other reasons other than that an update was
|
||||||
// disabled, e.g. as in ExtensionManagementTest.InstallRequiresConfirm.
|
// disabled.
|
||||||
content::NotificationService::current()->Notify(
|
content::NotificationService::current()->Notify(
|
||||||
chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
|
chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
|
||||||
content::Source<Profile>(profile_),
|
content::Source<Profile>(profile_),
|
||||||
@ -1886,7 +1910,7 @@ void ExtensionService::AddExtension(const Extension* extension) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
extensions_.Insert(scoped_extension);
|
extensions_.push_back(scoped_extension);
|
||||||
SyncExtensionChangeIfNeeded(*extension);
|
SyncExtensionChangeIfNeeded(*extension);
|
||||||
NotifyExtensionLoaded(extension);
|
NotifyExtensionLoaded(extension);
|
||||||
IdentifyAlertableExtensions();
|
IdentifyAlertableExtensions();
|
||||||
@ -1998,11 +2022,10 @@ void ExtensionService::InitializePermissions(const Extension* extension) {
|
|||||||
|
|
||||||
void ExtensionService::UpdateActiveExtensionsInCrashReporter() {
|
void ExtensionService::UpdateActiveExtensionsInCrashReporter() {
|
||||||
std::set<std::string> extension_ids;
|
std::set<std::string> extension_ids;
|
||||||
for (ExtensionSet::const_iterator iter = extensions_.begin();
|
for (size_t i = 0; i < extensions_.size(); ++i) {
|
||||||
iter != extensions_.end(); ++iter) {
|
if (!extensions_[i]->is_theme() &&
|
||||||
const Extension* extension = *iter;
|
extensions_[i]->location() != Extension::COMPONENT)
|
||||||
if (!extension->is_theme() && extension->location() != Extension::COMPONENT)
|
extension_ids.insert(extensions_[i]->id());
|
||||||
extension_ids.insert(extension->id());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
child_process_logging::SetActiveExtensions(extension_ids);
|
child_process_logging::SetActiveExtensions(extension_ids);
|
||||||
@ -2095,33 +2118,51 @@ const Extension* ExtensionService::GetExtensionByIdInternal(
|
|||||||
bool include_terminated) const {
|
bool include_terminated) const {
|
||||||
std::string lowercase_id = StringToLowerASCII(id);
|
std::string lowercase_id = StringToLowerASCII(id);
|
||||||
if (include_enabled) {
|
if (include_enabled) {
|
||||||
const Extension* extension = extensions_.GetByID(lowercase_id);
|
for (ExtensionList::const_iterator iter = extensions_.begin();
|
||||||
if (extension)
|
iter != extensions_.end(); ++iter) {
|
||||||
return extension;
|
if ((*iter)->id() == lowercase_id)
|
||||||
|
return *iter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (include_disabled) {
|
if (include_disabled) {
|
||||||
const Extension* extension = disabled_extensions_.GetByID(lowercase_id);
|
for (ExtensionList::const_iterator iter = disabled_extensions_.begin();
|
||||||
if (extension)
|
iter != disabled_extensions_.end(); ++iter) {
|
||||||
return extension;
|
if ((*iter)->id() == lowercase_id)
|
||||||
|
return *iter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (include_terminated) {
|
if (include_terminated) {
|
||||||
const Extension* extension = terminated_extensions_.GetByID(lowercase_id);
|
for (ExtensionList::const_iterator iter = terminated_extensions_.begin();
|
||||||
if (extension)
|
iter != terminated_extensions_.end(); ++iter) {
|
||||||
return extension;
|
if ((*iter)->id() == lowercase_id)
|
||||||
|
return *iter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtensionService::TrackTerminatedExtension(const Extension* extension) {
|
void ExtensionService::TrackTerminatedExtension(const Extension* extension) {
|
||||||
if (!terminated_extensions_.Contains(extension->id()))
|
if (terminated_extension_ids_.insert(extension->id()).second)
|
||||||
terminated_extensions_.Insert(make_scoped_refptr(extension));
|
terminated_extensions_.push_back(make_scoped_refptr(extension));
|
||||||
|
|
||||||
|
// TODO(yoz): Listen to navcontrollers for that extension. Is this a todo?
|
||||||
|
|
||||||
|
// TODO(yoz): make sure this is okay in *ALL* the listeners!
|
||||||
UnloadExtension(extension->id(), extension_misc::UNLOAD_REASON_TERMINATE);
|
UnloadExtension(extension->id(), extension_misc::UNLOAD_REASON_TERMINATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtensionService::UntrackTerminatedExtension(const std::string& id) {
|
void ExtensionService::UntrackTerminatedExtension(const std::string& id) {
|
||||||
std::string lowercase_id = StringToLowerASCII(id);
|
std::string lowercase_id = StringToLowerASCII(id);
|
||||||
terminated_extensions_.Remove(lowercase_id);
|
if (terminated_extension_ids_.erase(lowercase_id) <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (ExtensionList::iterator iter = terminated_extensions_.begin();
|
||||||
|
iter != terminated_extensions_.end(); ++iter) {
|
||||||
|
if ((*iter)->id() == lowercase_id) {
|
||||||
|
terminated_extensions_.erase(iter);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Extension* ExtensionService::GetTerminatedExtension(
|
const Extension* ExtensionService::GetTerminatedExtension(
|
||||||
@ -2144,22 +2185,18 @@ const Extension* ExtensionService::GetExtensionByURL(const GURL& url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Extension* ExtensionService::GetExtensionByWebExtent(const GURL& url) {
|
const Extension* ExtensionService::GetExtensionByWebExtent(const GURL& url) {
|
||||||
// TODO(yoz): Should be ExtensionSet::GetByURL.
|
for (size_t i = 0; i < extensions_.size(); ++i) {
|
||||||
for (ExtensionSet::const_iterator iter = extensions_.begin();
|
if (extensions_[i]->web_extent().MatchesURL(url))
|
||||||
iter != extensions_.end(); ++iter) {
|
return extensions_[i];
|
||||||
if ((*iter)->web_extent().MatchesURL(url))
|
|
||||||
return *iter;
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Extension* ExtensionService::GetDisabledExtensionByWebExtent(
|
const Extension* ExtensionService::GetDisabledExtensionByWebExtent(
|
||||||
const GURL& url) {
|
const GURL& url) {
|
||||||
// TODO(yoz): Should be ExtensionSet::GetByURL.
|
for (size_t i = 0; i < disabled_extensions_.size(); ++i) {
|
||||||
for (ExtensionSet::const_iterator iter = disabled_extensions_.begin();
|
if (disabled_extensions_[i]->web_extent().MatchesURL(url))
|
||||||
iter != disabled_extensions_.end(); ++iter) {
|
return disabled_extensions_[i];
|
||||||
if ((*iter)->web_extent().MatchesURL(url))
|
|
||||||
return *iter;
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2180,11 +2217,9 @@ bool ExtensionService::ExtensionBindingsAllowed(const GURL& url) {
|
|||||||
|
|
||||||
const Extension* ExtensionService::GetExtensionByOverlappingWebExtent(
|
const Extension* ExtensionService::GetExtensionByOverlappingWebExtent(
|
||||||
const URLPatternSet& extent) {
|
const URLPatternSet& extent) {
|
||||||
// TODO(yoz): Should be in ExtensionSet.
|
for (size_t i = 0; i < extensions_.size(); ++i) {
|
||||||
for (ExtensionSet::const_iterator iter = extensions_.begin();
|
if (extensions_[i]->web_extent().OverlapsWith(extent))
|
||||||
iter != extensions_.end(); ++iter) {
|
return extensions_[i];
|
||||||
if ((*iter)->web_extent().OverlapsWith(extent))
|
|
||||||
return *iter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -2319,9 +2354,9 @@ void ExtensionService::Observe(int type,
|
|||||||
|
|
||||||
// Loaded extensions.
|
// Loaded extensions.
|
||||||
std::vector<ExtensionMsg_Loaded_Params> loaded_extensions;
|
std::vector<ExtensionMsg_Loaded_Params> loaded_extensions;
|
||||||
for (ExtensionSet::const_iterator iter = extensions_.begin();
|
for (size_t i = 0; i < extensions_.size(); ++i) {
|
||||||
iter != extensions_.end(); ++iter) {
|
loaded_extensions.push_back(
|
||||||
loaded_extensions.push_back(ExtensionMsg_Loaded_Params(*iter));
|
ExtensionMsg_Loaded_Params(extensions_[i]));
|
||||||
}
|
}
|
||||||
process->Send(new ExtensionMsg_Loaded(loaded_extensions));
|
process->Send(new ExtensionMsg_Loaded(loaded_extensions));
|
||||||
break;
|
break;
|
||||||
@ -2372,7 +2407,7 @@ bool ExtensionService::HasApps() const {
|
|||||||
|
|
||||||
ExtensionIdSet ExtensionService::GetAppIds() const {
|
ExtensionIdSet ExtensionService::GetAppIds() const {
|
||||||
ExtensionIdSet result;
|
ExtensionIdSet result;
|
||||||
for (ExtensionSet::const_iterator it = extensions_.begin();
|
for (ExtensionList::const_iterator it = extensions_.begin();
|
||||||
it != extensions_.end(); ++it) {
|
it != extensions_.end(); ++it) {
|
||||||
if ((*it)->is_app() && (*it)->location() != Extension::COMPONENT)
|
if ((*it)->is_app() && (*it)->location() != Extension::COMPONENT)
|
||||||
result.insert((*it)->id());
|
result.insert((*it)->id());
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
#include "chrome/browser/sync/api/syncable_service.h"
|
#include "chrome/browser/sync/api/syncable_service.h"
|
||||||
#include "chrome/common/extensions/extension.h"
|
#include "chrome/common/extensions/extension.h"
|
||||||
#include "chrome/common/extensions/extension_constants.h"
|
#include "chrome/common/extensions/extension_constants.h"
|
||||||
#include "chrome/common/extensions/extension_set.h"
|
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "content/public/browser/notification_observer.h"
|
#include "content/public/browser/notification_observer.h"
|
||||||
#include "content/public/browser/notification_registrar.h"
|
#include "content/public/browser/notification_registrar.h"
|
||||||
@ -87,7 +86,7 @@ class ExtensionServiceInterface : public SyncableService {
|
|||||||
typedef bool (*ExtensionFilter)(const Extension&);
|
typedef bool (*ExtensionFilter)(const Extension&);
|
||||||
|
|
||||||
virtual ~ExtensionServiceInterface() {}
|
virtual ~ExtensionServiceInterface() {}
|
||||||
virtual const ExtensionSet* extensions() const = 0;
|
virtual const ExtensionList* extensions() const = 0;
|
||||||
virtual PendingExtensionManager* pending_extension_manager() = 0;
|
virtual PendingExtensionManager* pending_extension_manager() = 0;
|
||||||
|
|
||||||
// Install an update. Return true if the install can be started.
|
// Install an update. Return true if the install can be started.
|
||||||
@ -193,9 +192,9 @@ class ExtensionService
|
|||||||
virtual ~ExtensionService();
|
virtual ~ExtensionService();
|
||||||
|
|
||||||
// Gets the list of currently installed extensions.
|
// Gets the list of currently installed extensions.
|
||||||
virtual const ExtensionSet* extensions() const OVERRIDE;
|
virtual const ExtensionList* extensions() const OVERRIDE;
|
||||||
const ExtensionSet* disabled_extensions() const;
|
const ExtensionList* disabled_extensions() const;
|
||||||
const ExtensionSet* terminated_extensions() const;
|
const ExtensionList* terminated_extensions() const;
|
||||||
|
|
||||||
// Gets the object managing the set of pending extensions.
|
// Gets the object managing the set of pending extensions.
|
||||||
virtual PendingExtensionManager* pending_extension_manager() OVERRIDE;
|
virtual PendingExtensionManager* pending_extension_manager() OVERRIDE;
|
||||||
@ -631,7 +630,7 @@ class ExtensionService
|
|||||||
// Appends sync data objects for every extension in |extensions|
|
// Appends sync data objects for every extension in |extensions|
|
||||||
// that passes |filter|.
|
// that passes |filter|.
|
||||||
void GetSyncDataListHelper(
|
void GetSyncDataListHelper(
|
||||||
const ExtensionSet& extensions,
|
const ExtensionList& extensions,
|
||||||
const SyncBundle& bundle,
|
const SyncBundle& bundle,
|
||||||
std::vector<ExtensionSyncData>* sync_data_list) const;
|
std::vector<ExtensionSyncData>* sync_data_list) const;
|
||||||
|
|
||||||
@ -691,13 +690,16 @@ class ExtensionService
|
|||||||
|
|
||||||
// The current list of installed extensions.
|
// The current list of installed extensions.
|
||||||
// TODO(aa): This should use chrome/common/extensions/extension_set.h.
|
// TODO(aa): This should use chrome/common/extensions/extension_set.h.
|
||||||
ExtensionSet extensions_;
|
ExtensionList extensions_;
|
||||||
|
|
||||||
// The list of installed extensions that have been disabled.
|
// The list of installed extensions that have been disabled.
|
||||||
ExtensionSet disabled_extensions_;
|
ExtensionList disabled_extensions_;
|
||||||
|
|
||||||
// The list of installed extensions that have been terminated.
|
// The list of installed extensions that have been terminated.
|
||||||
ExtensionSet terminated_extensions_;
|
ExtensionList terminated_extensions_;
|
||||||
|
|
||||||
|
// Used to quickly check if an extension was terminated.
|
||||||
|
std::set<std::string> terminated_extension_ids_;
|
||||||
|
|
||||||
// Hold the set of pending extensions.
|
// Hold the set of pending extensions.
|
||||||
PendingExtensionManager pending_extension_manager_;
|
PendingExtensionManager pending_extension_manager_;
|
||||||
|
@ -1874,7 +1874,7 @@ TEST_F(ExtensionServiceTest, UpdateApps) {
|
|||||||
TEST_F(ExtensionServiceTest, InstallAppsWithUnlimitedStorage) {
|
TEST_F(ExtensionServiceTest, InstallAppsWithUnlimitedStorage) {
|
||||||
InitializeEmptyExtensionService();
|
InitializeEmptyExtensionService();
|
||||||
InitializeRequestContext();
|
InitializeRequestContext();
|
||||||
EXPECT_TRUE(service_->extensions()->is_empty());
|
EXPECT_TRUE(service_->extensions()->empty());
|
||||||
|
|
||||||
int pref_count = 0;
|
int pref_count = 0;
|
||||||
|
|
||||||
@ -1925,7 +1925,7 @@ TEST_F(ExtensionServiceTest, InstallAppsWithUnlimitedStorage) {
|
|||||||
TEST_F(ExtensionServiceTest, InstallAppsAndCheckStorageProtection) {
|
TEST_F(ExtensionServiceTest, InstallAppsAndCheckStorageProtection) {
|
||||||
InitializeEmptyExtensionService();
|
InitializeEmptyExtensionService();
|
||||||
InitializeRequestContext();
|
InitializeRequestContext();
|
||||||
EXPECT_TRUE(service_->extensions()->is_empty());
|
EXPECT_TRUE(service_->extensions()->empty());
|
||||||
|
|
||||||
int pref_count = 0;
|
int pref_count = 0;
|
||||||
|
|
||||||
@ -1954,7 +1954,7 @@ TEST_F(ExtensionServiceTest, InstallAppsAndCheckStorageProtection) {
|
|||||||
|
|
||||||
UninstallExtension(id2, false);
|
UninstallExtension(id2, false);
|
||||||
|
|
||||||
EXPECT_TRUE(service_->extensions()->is_empty());
|
EXPECT_TRUE(service_->extensions()->empty());
|
||||||
EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->
|
EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->
|
||||||
IsStorageProtected(origin1));
|
IsStorageProtected(origin1));
|
||||||
EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->
|
EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->
|
||||||
@ -2675,18 +2675,18 @@ TEST_F(ExtensionServiceTest, DisableExtension) {
|
|||||||
InitializeEmptyExtensionService();
|
InitializeEmptyExtensionService();
|
||||||
|
|
||||||
InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
|
InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
|
||||||
EXPECT_FALSE(service_->extensions()->is_empty());
|
EXPECT_FALSE(service_->extensions()->empty());
|
||||||
EXPECT_TRUE(service_->GetExtensionById(good_crx, true));
|
EXPECT_TRUE(service_->GetExtensionById(good_crx, true));
|
||||||
EXPECT_TRUE(service_->GetExtensionById(good_crx, false));
|
EXPECT_TRUE(service_->GetExtensionById(good_crx, false));
|
||||||
EXPECT_TRUE(service_->disabled_extensions()->is_empty());
|
EXPECT_TRUE(service_->disabled_extensions()->empty());
|
||||||
|
|
||||||
// Disable it.
|
// Disable it.
|
||||||
service_->DisableExtension(good_crx);
|
service_->DisableExtension(good_crx);
|
||||||
|
|
||||||
EXPECT_TRUE(service_->extensions()->is_empty());
|
EXPECT_TRUE(service_->extensions()->empty());
|
||||||
EXPECT_TRUE(service_->GetExtensionById(good_crx, true));
|
EXPECT_TRUE(service_->GetExtensionById(good_crx, true));
|
||||||
EXPECT_FALSE(service_->GetExtensionById(good_crx, false));
|
EXPECT_FALSE(service_->GetExtensionById(good_crx, false));
|
||||||
EXPECT_FALSE(service_->disabled_extensions()->is_empty());
|
EXPECT_FALSE(service_->disabled_extensions()->empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ExtensionServiceTest, DisableTerminatedExtension) {
|
TEST_F(ExtensionServiceTest, DisableTerminatedExtension) {
|
||||||
@ -2701,7 +2701,7 @@ TEST_F(ExtensionServiceTest, DisableTerminatedExtension) {
|
|||||||
|
|
||||||
EXPECT_FALSE(service_->GetTerminatedExtension(good_crx));
|
EXPECT_FALSE(service_->GetTerminatedExtension(good_crx));
|
||||||
EXPECT_TRUE(service_->GetExtensionById(good_crx, true));
|
EXPECT_TRUE(service_->GetExtensionById(good_crx, true));
|
||||||
EXPECT_FALSE(service_->disabled_extensions()->is_empty());
|
EXPECT_FALSE(service_->disabled_extensions()->empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests disabling all extensions (simulating --disable-extensions flag).
|
// Tests disabling all extensions (simulating --disable-extensions flag).
|
||||||
|
@ -83,9 +83,8 @@ class ExtensionStartupTestBase : public InProcessBrowserTest {
|
|||||||
|
|
||||||
// Count the number of non-component extensions.
|
// Count the number of non-component extensions.
|
||||||
int found_extensions = 0;
|
int found_extensions = 0;
|
||||||
for (ExtensionSet::const_iterator it = service->extensions()->begin();
|
for (size_t i = 0; i < service->extensions()->size(); i++)
|
||||||
it != service->extensions()->end(); ++it)
|
if (service->extensions()->at(i)->location() != Extension::COMPONENT)
|
||||||
if ((*it)->location() != Extension::COMPONENT)
|
|
||||||
found_extensions++;
|
found_extensions++;
|
||||||
|
|
||||||
ASSERT_EQ(static_cast<uint32>(num_expected_extensions),
|
ASSERT_EQ(static_cast<uint32>(num_expected_extensions),
|
||||||
@ -164,25 +163,17 @@ IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, Test) {
|
|||||||
IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, MAYBE_NoFileAccess) {
|
IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, MAYBE_NoFileAccess) {
|
||||||
WaitForServicesToStart(num_expected_extensions_, true);
|
WaitForServicesToStart(num_expected_extensions_, true);
|
||||||
|
|
||||||
// Keep a separate list of extensions for which to disable file access, since
|
|
||||||
// doing so reloads them.
|
|
||||||
std::vector<const Extension*> extension_list;
|
|
||||||
|
|
||||||
ExtensionService* service = browser()->profile()->GetExtensionService();
|
ExtensionService* service = browser()->profile()->GetExtensionService();
|
||||||
for (ExtensionSet::const_iterator it = service->extensions()->begin();
|
for (size_t i = 0; i < service->extensions()->size(); ++i) {
|
||||||
it != service->extensions()->end(); ++it) {
|
if (service->extensions()->at(i)->location() == Extension::COMPONENT)
|
||||||
if ((*it)->location() == Extension::COMPONENT)
|
|
||||||
continue;
|
continue;
|
||||||
if (service->AllowFileAccess(*it))
|
if (service->AllowFileAccess(service->extensions()->at(i))) {
|
||||||
extension_list.push_back(*it);
|
ui_test_utils::WindowedNotificationObserver user_scripts_observer(
|
||||||
}
|
chrome::NOTIFICATION_USER_SCRIPTS_UPDATED,
|
||||||
|
content::NotificationService::AllSources());
|
||||||
for (size_t i = 0; i < extension_list.size(); ++i) {
|
service->SetAllowFileAccess(service->extensions()->at(i), false);
|
||||||
ui_test_utils::WindowedNotificationObserver user_scripts_observer(
|
user_scripts_observer.Wait();
|
||||||
chrome::NOTIFICATION_USER_SCRIPTS_UPDATED,
|
}
|
||||||
content::NotificationService::AllSources());
|
|
||||||
service->SetAllowFileAccess(extension_list[i], false);
|
|
||||||
user_scripts_observer.Wait();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TestInjection(false, false);
|
TestInjection(false, false);
|
||||||
|
@ -98,9 +98,9 @@ void ExtensionTabHelper::DidNavigateMainFrame(
|
|||||||
if (!service)
|
if (!service)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (ExtensionSet::const_iterator it = service->extensions()->begin();
|
for (size_t i = 0; i < service->extensions()->size(); ++i) {
|
||||||
it != service->extensions()->end(); ++it) {
|
ExtensionAction* browser_action =
|
||||||
ExtensionAction* browser_action = (*it)->browser_action();
|
service->extensions()->at(i)->browser_action();
|
||||||
if (browser_action) {
|
if (browser_action) {
|
||||||
browser_action->ClearAllValuesForTab(
|
browser_action->ClearAllValuesForTab(
|
||||||
wrapper_->restore_tab_helper()->session_id().id());
|
wrapper_->restore_tab_helper()->session_id().id());
|
||||||
@ -110,7 +110,8 @@ void ExtensionTabHelper::DidNavigateMainFrame(
|
|||||||
content::NotificationService::NoDetails());
|
content::NotificationService::NoDetails());
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtensionAction* page_action = (*it)->page_action();
|
ExtensionAction* page_action =
|
||||||
|
service->extensions()->at(i)->page_action();
|
||||||
if (page_action) {
|
if (page_action) {
|
||||||
page_action->ClearAllValuesForTab(
|
page_action->ClearAllValuesForTab(
|
||||||
wrapper_->restore_tab_helper()->session_id().id());
|
wrapper_->restore_tab_helper()->session_id().id());
|
||||||
|
@ -181,9 +181,8 @@ void ExtensionToolbarModel::InitializeExtensionList() {
|
|||||||
ExtensionList unsorted;
|
ExtensionList unsorted;
|
||||||
|
|
||||||
// Create the lists.
|
// Create the lists.
|
||||||
for (ExtensionSet::const_iterator it = service_->extensions()->begin();
|
for (size_t i = 0; i < service_->extensions()->size(); ++i) {
|
||||||
it != service_->extensions()->end(); ++it) {
|
const Extension* extension = service_->extensions()->at(i);
|
||||||
const Extension* extension = *it;
|
|
||||||
if (!extension->browser_action())
|
if (!extension->browser_action())
|
||||||
continue;
|
continue;
|
||||||
if (!service_->GetBrowserActionVisibility(extension))
|
if (!service_->GetBrowserActionVisibility(extension))
|
||||||
|
@ -28,8 +28,8 @@ void GetExtensionVoices(Profile* profile, ListValue* result_voices) {
|
|||||||
ExtensionEventRouter* event_router = profile->GetExtensionEventRouter();
|
ExtensionEventRouter* event_router = profile->GetExtensionEventRouter();
|
||||||
DCHECK(event_router);
|
DCHECK(event_router);
|
||||||
|
|
||||||
const ExtensionSet* extensions = service->extensions();
|
const ExtensionList* extensions = service->extensions();
|
||||||
ExtensionSet::const_iterator iter;
|
ExtensionList::const_iterator iter;
|
||||||
for (iter = extensions->begin(); iter != extensions->end(); ++iter) {
|
for (iter = extensions->begin(); iter != extensions->end(); ++iter) {
|
||||||
const Extension* extension = *iter;
|
const Extension* extension = *iter;
|
||||||
|
|
||||||
@ -93,8 +93,8 @@ bool GetMatchingExtensionVoice(
|
|||||||
|
|
||||||
*matching_extension = NULL;
|
*matching_extension = NULL;
|
||||||
*voice_index = -1;
|
*voice_index = -1;
|
||||||
const ExtensionSet* extensions = service->extensions();
|
const ExtensionList* extensions = service->extensions();
|
||||||
ExtensionSet::const_iterator iter;
|
ExtensionList::const_iterator iter;
|
||||||
for (iter = extensions->begin(); iter != extensions->end(); ++iter) {
|
for (iter = extensions->begin(); iter != extensions->end(); ++iter) {
|
||||||
const Extension* extension = *iter;
|
const Extension* extension = *iter;
|
||||||
|
|
||||||
|
@ -1025,8 +1025,8 @@ void ExtensionUpdater::CheckNow() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExtensionSet* extensions = service_->extensions();
|
const ExtensionList* extensions = service_->extensions();
|
||||||
for (ExtensionSet::const_iterator iter = extensions->begin();
|
for (ExtensionList::const_iterator iter = extensions->begin();
|
||||||
iter != extensions->end(); ++iter) {
|
iter != extensions->end(); ++iter) {
|
||||||
// An extension might be overwritten by policy, and have its update url
|
// An extension might be overwritten by policy, and have its update url
|
||||||
// changed. Make sure existing extensions aren't fetched again, if a
|
// changed. Make sure existing extensions aren't fetched again, if a
|
||||||
|
@ -153,10 +153,16 @@ class ServiceForManifestTests : public MockService {
|
|||||||
|
|
||||||
virtual const Extension* GetExtensionById(
|
virtual const Extension* GetExtensionById(
|
||||||
const std::string& id, bool include_disabled) const OVERRIDE {
|
const std::string& id, bool include_disabled) const OVERRIDE {
|
||||||
return extensions_.GetByID(id);
|
for (ExtensionList::const_iterator iter = extensions_.begin();
|
||||||
|
iter != extensions_.end(); ++iter) {
|
||||||
|
if ((*iter)->id() == id) {
|
||||||
|
return *iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const ExtensionSet* extensions() const OVERRIDE {
|
virtual const ExtensionList* extensions() const OVERRIDE {
|
||||||
return &extensions_;
|
return &extensions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,14 +171,11 @@ class ServiceForManifestTests : public MockService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void set_extensions(ExtensionList extensions) {
|
void set_extensions(ExtensionList extensions) {
|
||||||
for (ExtensionList::const_iterator it = extensions.begin();
|
extensions_ = extensions;
|
||||||
it != extensions.end(); ++it) {
|
|
||||||
extensions_.Insert(*it);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ExtensionSet extensions_;
|
ExtensionList extensions_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ServiceForDownloadTests : public MockService {
|
class ServiceForDownloadTests : public MockService {
|
||||||
|
@ -1697,9 +1697,9 @@ void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host) {
|
|||||||
bool adblock = false;
|
bool adblock = false;
|
||||||
bool adblock_plus = false;
|
bool adblock_plus = false;
|
||||||
bool other = false;
|
bool other = false;
|
||||||
const ExtensionSet* extensions =
|
const ExtensionList* extensions =
|
||||||
profile->GetExtensionService()->extensions();
|
profile->GetExtensionService()->extensions();
|
||||||
for (ExtensionSet::const_iterator it = extensions->begin();
|
for (ExtensionList::const_iterator it = extensions->begin();
|
||||||
it != extensions->end(); ++it) {
|
it != extensions->end(); ++it) {
|
||||||
if (profile->GetExtensionService()->HasUsedWebRequest(*it)) {
|
if (profile->GetExtensionService()->HasUsedWebRequest(*it)) {
|
||||||
if ((*it)->name().find("Adblock Plus") != std::string::npos) {
|
if ((*it)->name().find("Adblock Plus") != std::string::npos) {
|
||||||
|
@ -181,8 +181,8 @@ void InstalledLoader::LoadAllExtensions() {
|
|||||||
int theme_count = 0;
|
int theme_count = 0;
|
||||||
int page_action_count = 0;
|
int page_action_count = 0;
|
||||||
int browser_action_count = 0;
|
int browser_action_count = 0;
|
||||||
const ExtensionSet* extensions = extension_service_->extensions();
|
const ExtensionList* extensions = extension_service_->extensions();
|
||||||
ExtensionSet::const_iterator ex;
|
ExtensionList::const_iterator ex;
|
||||||
for (ex = extensions->begin(); ex != extensions->end(); ++ex) {
|
for (ex = extensions->begin(); ex != extensions->end(); ++ex) {
|
||||||
Extension::Location location = (*ex)->location();
|
Extension::Location location = (*ex)->location();
|
||||||
Extension::Type type = (*ex)->GetType();
|
Extension::Type type = (*ex)->GetType();
|
||||||
@ -246,7 +246,7 @@ void InstalledLoader::LoadAllExtensions() {
|
|||||||
++browser_action_count;
|
++browser_action_count;
|
||||||
|
|
||||||
extension_service_->RecordPermissionMessagesHistogram(
|
extension_service_->RecordPermissionMessagesHistogram(
|
||||||
*ex, "Extensions.Permissions_Load");
|
ex->get(), "Extensions.Permissions_Load");
|
||||||
}
|
}
|
||||||
UMA_HISTOGRAM_COUNTS_100("Extensions.LoadApp",
|
UMA_HISTOGRAM_COUNTS_100("Extensions.LoadApp",
|
||||||
app_user_count + app_external_count);
|
app_user_count + app_external_count);
|
||||||
|
@ -127,9 +127,9 @@ class NetworkDelayListenerTest
|
|||||||
|
|
||||||
void LoadTestExtension1() {
|
void LoadTestExtension1() {
|
||||||
LoadTestExtension(kTestExtensionId1);
|
LoadTestExtension(kTestExtensionId1);
|
||||||
ASSERT_FALSE(service_->extensions()->is_empty());
|
ASSERT_FALSE(service_->extensions()->empty());
|
||||||
extension1_ = service_->extensions()->GetByID(kTestExtensionId1);
|
extension1_ = service_->extensions()->at(0).get();
|
||||||
ASSERT_TRUE(extension1_);
|
ASSERT_FALSE(extension1_ == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendExtensionLoadedNotification(const Extension* extension) {
|
void SendExtensionLoadedNotification(const Extension* extension) {
|
||||||
@ -197,9 +197,8 @@ TEST_F(NetworkDelayListenerTest, TwoBlockingExtensions) {
|
|||||||
LoadTestExtension1();
|
LoadTestExtension1();
|
||||||
LoadTestExtension(kTestExtensionId2);
|
LoadTestExtension(kTestExtensionId2);
|
||||||
ASSERT_EQ(2u, service_->extensions()->size());
|
ASSERT_EQ(2u, service_->extensions()->size());
|
||||||
const Extension* extension2 =
|
const Extension* extension2 = service_->extensions()->at(1).get();
|
||||||
service_->extensions()->GetByID(kTestExtensionId2);
|
ASSERT_FALSE(extension2 == NULL);
|
||||||
ASSERT_TRUE(extension2);
|
|
||||||
|
|
||||||
TestDelegate delegate;
|
TestDelegate delegate;
|
||||||
scoped_ptr<TestURLRequest> request(StartTestRequest(&delegate, kTestUrl));
|
scoped_ptr<TestURLRequest> request(StartTestRequest(&delegate, kTestUrl));
|
||||||
@ -232,7 +231,7 @@ TEST_F(NetworkDelayListenerTest, ExtensionReadyTwice) {
|
|||||||
// Tests that there's no delay if no loaded extension needs one.
|
// Tests that there's no delay if no loaded extension needs one.
|
||||||
TEST_F(NetworkDelayListenerTest, NoDelayNoWebRequest) {
|
TEST_F(NetworkDelayListenerTest, NoDelayNoWebRequest) {
|
||||||
LoadTestExtension(kTestExtensionNoNetworkDelay);
|
LoadTestExtension(kTestExtensionNoNetworkDelay);
|
||||||
ASSERT_FALSE(service_->extensions()->is_empty());
|
ASSERT_FALSE(service_->extensions()->empty());
|
||||||
|
|
||||||
TestDelegate delegate;
|
TestDelegate delegate;
|
||||||
scoped_ptr<TestURLRequest> request(StartTestRequest(&delegate, kTestUrl));
|
scoped_ptr<TestURLRequest> request(StartTestRequest(&delegate, kTestUrl));
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
TestExtensionService::~TestExtensionService() {}
|
TestExtensionService::~TestExtensionService() {}
|
||||||
|
|
||||||
const ExtensionSet* TestExtensionService::extensions() const {
|
const ExtensionList* TestExtensionService::extensions() const {
|
||||||
ADD_FAILURE();
|
ADD_FAILURE();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ class TestExtensionService : public ExtensionServiceInterface {
|
|||||||
virtual ~TestExtensionService();
|
virtual ~TestExtensionService();
|
||||||
|
|
||||||
// ExtensionServiceInterface implementation.
|
// ExtensionServiceInterface implementation.
|
||||||
virtual const ExtensionSet* extensions() const OVERRIDE;
|
virtual const ExtensionList* extensions() const OVERRIDE;
|
||||||
virtual PendingExtensionManager* pending_extension_manager() OVERRIDE;
|
virtual PendingExtensionManager* pending_extension_manager() OVERRIDE;
|
||||||
|
|
||||||
virtual bool UpdateExtension(
|
virtual bool UpdateExtension(
|
||||||
|
@ -194,12 +194,15 @@ void UnpackedInstaller::OnLoaded(
|
|||||||
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||||
if (!service_weak_.get())
|
if (!service_weak_.get())
|
||||||
return;
|
return;
|
||||||
const ExtensionSet* disabled_extensions =
|
const ExtensionList* disabled_extensions =
|
||||||
service_weak_->disabled_extensions();
|
service_weak_->disabled_extensions();
|
||||||
if (service_weak_->show_extensions_prompts() &&
|
if (service_weak_->show_extensions_prompts() &&
|
||||||
prompt_for_plugins_ &&
|
prompt_for_plugins_ &&
|
||||||
!extension->plugins().empty() &&
|
!extension->plugins().empty() &&
|
||||||
disabled_extensions->Contains(extension->id())) {
|
std::find(disabled_extensions->begin(),
|
||||||
|
disabled_extensions->end(),
|
||||||
|
extension) !=
|
||||||
|
disabled_extensions->end()) {
|
||||||
SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt(
|
SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt(
|
||||||
service_weak_->profile(),
|
service_weak_->profile(),
|
||||||
service_weak_,
|
service_weak_,
|
||||||
|
@ -200,7 +200,7 @@ void UserScriptListener::Observe(int type,
|
|||||||
// Clear all our patterns and reregister all the still-loaded extensions.
|
// Clear all our patterns and reregister all the still-loaded extensions.
|
||||||
URLPatterns new_patterns;
|
URLPatterns new_patterns;
|
||||||
ExtensionService* service = profile->GetExtensionService();
|
ExtensionService* service = profile->GetExtensionService();
|
||||||
for (ExtensionSet::const_iterator it = service->extensions()->begin();
|
for (ExtensionList::const_iterator it = service->extensions()->begin();
|
||||||
it != service->extensions()->end(); ++it) {
|
it != service->extensions()->end(); ++it) {
|
||||||
if (*it != unloaded_extension)
|
if (*it != unloaded_extension)
|
||||||
CollectURLPatterns(*it, &new_patterns);
|
CollectURLPatterns(*it, &new_patterns);
|
||||||
|
@ -138,8 +138,8 @@ class UserScriptListenerTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UnloadTestExtension() {
|
void UnloadTestExtension() {
|
||||||
ASSERT_FALSE(service_->extensions()->is_empty());
|
ASSERT_FALSE(service_->extensions()->empty());
|
||||||
service_->UnloadExtension((*service_->extensions()->begin())->id(),
|
service_->UnloadExtension(service_->extensions()->at(0)->id(),
|
||||||
extension_misc::UNLOAD_REASON_DISABLE);
|
extension_misc::UNLOAD_REASON_DISABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,9 +81,9 @@ void WebIntentsRegistry::OnWebDataServiceRequestDone(
|
|||||||
|
|
||||||
// Loop over all intents in all extensions, collect ones matching the query.
|
// Loop over all intents in all extensions, collect ones matching the query.
|
||||||
if (extension_service_) {
|
if (extension_service_) {
|
||||||
const ExtensionSet* extensions = extension_service_->extensions();
|
const ExtensionList* extensions = extension_service_->extensions();
|
||||||
if (extensions) {
|
if (extensions) {
|
||||||
for (ExtensionSet::const_iterator i(extensions->begin());
|
for (ExtensionList::const_iterator i(extensions->begin());
|
||||||
i != extensions->end(); ++i) {
|
i != extensions->end(); ++i) {
|
||||||
const IntentServiceList& intents((*i)->intents_services());
|
const IntentServiceList& intents((*i)->intents_services());
|
||||||
for (IntentServiceList::const_iterator j(intents.begin());
|
for (IntentServiceList::const_iterator j(intents.begin());
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "chrome/browser/intents/web_intents_registry.h"
|
#include "chrome/browser/intents/web_intents_registry.h"
|
||||||
#include "chrome/browser/webdata/web_data_service.h"
|
#include "chrome/browser/webdata/web_data_service.h"
|
||||||
#include "chrome/common/chrome_paths.h"
|
#include "chrome/common/chrome_paths.h"
|
||||||
#include "chrome/common/extensions/extension_set.h"
|
|
||||||
#include "content/test/test_browser_thread.h"
|
#include "content/test/test_browser_thread.h"
|
||||||
#include "testing/gmock/include/gmock/gmock.h"
|
#include "testing/gmock/include/gmock/gmock.h"
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
@ -22,17 +21,37 @@ using webkit_glue::WebIntentServiceData;
|
|||||||
class MockExtensionService: public TestExtensionService {
|
class MockExtensionService: public TestExtensionService {
|
||||||
public:
|
public:
|
||||||
virtual ~MockExtensionService() {}
|
virtual ~MockExtensionService() {}
|
||||||
MOCK_CONST_METHOD0(extensions, const ExtensionSet*());
|
MOCK_CONST_METHOD0(extensions, const ExtensionList*());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO(groby): Unify loading functions with extension_manifest_unittest code.
|
||||||
|
DictionaryValue* LoadManifestFile(const std::string& filename,
|
||||||
|
std::string* error) {
|
||||||
|
FilePath path;
|
||||||
|
PathService::Get(chrome::DIR_TEST_DATA, &path);
|
||||||
|
path = path.AppendASCII("extensions")
|
||||||
|
.AppendASCII("manifest_tests")
|
||||||
|
.AppendASCII(filename.c_str());
|
||||||
|
EXPECT_TRUE(file_util::PathExists(path));
|
||||||
|
|
||||||
|
JSONFileValueSerializer serializer(path);
|
||||||
|
return static_cast<DictionaryValue*>(serializer.Deserialize(NULL, error));
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// TODO(groby): Unify loading functions with extension_manifest_unittest code.
|
scoped_refptr<Extension> LoadExtensionWithLocation(
|
||||||
DictionaryValue* LoadManifestFile(const FilePath& path,
|
DictionaryValue* value,
|
||||||
std::string* error) {
|
Extension::Location location,
|
||||||
EXPECT_TRUE(file_util::PathExists(path));
|
bool strict_error_checks,
|
||||||
JSONFileValueSerializer serializer(path);
|
std::string* error) {
|
||||||
return static_cast<DictionaryValue*>(serializer.Deserialize(NULL, error));
|
FilePath path;
|
||||||
|
PathService::Get(chrome::DIR_TEST_DATA, &path);
|
||||||
|
path = path.AppendASCII("extensions").AppendASCII("manifest_tests");
|
||||||
|
int flags = Extension::NO_FLAGS;
|
||||||
|
if (strict_error_checks)
|
||||||
|
flags |= Extension::STRICT_ERROR_CHECKS;
|
||||||
|
return Extension::Create(path.DirName(), location, *value, flags, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_refptr<Extension> LoadExtensionWithLocation(
|
scoped_refptr<Extension> LoadExtensionWithLocation(
|
||||||
@ -40,23 +59,11 @@ scoped_refptr<Extension> LoadExtensionWithLocation(
|
|||||||
Extension::Location location,
|
Extension::Location location,
|
||||||
bool strict_error_checks,
|
bool strict_error_checks,
|
||||||
std::string* error) {
|
std::string* error) {
|
||||||
FilePath path;
|
scoped_ptr<DictionaryValue> value(LoadManifestFile(name, error));
|
||||||
PathService::Get(chrome::DIR_TEST_DATA, &path);
|
|
||||||
path = path.AppendASCII("extensions")
|
|
||||||
.AppendASCII("manifest_tests")
|
|
||||||
.AppendASCII(name.c_str());
|
|
||||||
scoped_ptr<DictionaryValue> value(LoadManifestFile(path, error));
|
|
||||||
if (!value.get())
|
if (!value.get())
|
||||||
return NULL;
|
return NULL;
|
||||||
int flags = Extension::NO_FLAGS;
|
return LoadExtensionWithLocation(value.get(), location,
|
||||||
if (strict_error_checks)
|
strict_error_checks, error);
|
||||||
flags |= Extension::STRICT_ERROR_CHECKS;
|
|
||||||
return Extension::CreateWithId(path.DirName(),
|
|
||||||
location,
|
|
||||||
*value,
|
|
||||||
flags,
|
|
||||||
Extension::GenerateIdForPath(path),
|
|
||||||
error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_refptr<Extension> LoadExtension(const std::string& name,
|
scoped_refptr<Extension> LoadExtension(const std::string& name,
|
||||||
@ -107,7 +114,7 @@ class WebIntentsRegistryTest : public testing::Test {
|
|||||||
content::TestBrowserThread db_thread_;
|
content::TestBrowserThread db_thread_;
|
||||||
scoped_refptr<WebDataService> wds_;
|
scoped_refptr<WebDataService> wds_;
|
||||||
MockExtensionService extension_service_;
|
MockExtensionService extension_service_;
|
||||||
ExtensionSet extensions_;
|
ExtensionList extensions_;
|
||||||
WebIntentsRegistry registry_;
|
WebIntentsRegistry registry_;
|
||||||
ScopedTempDir temp_dir_;
|
ScopedTempDir temp_dir_;
|
||||||
};
|
};
|
||||||
@ -206,9 +213,8 @@ TEST_F(WebIntentsRegistryTest, GetAllIntents) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WebIntentsRegistryTest, GetExtensionIntents) {
|
TEST_F(WebIntentsRegistryTest, GetExtensionIntents) {
|
||||||
extensions_.Insert(LoadAndExpectSuccess("intent_valid.json"));
|
extensions_.push_back(LoadAndExpectSuccess("intent_valid.json"));
|
||||||
extensions_.Insert(LoadAndExpectSuccess("intent_valid_2.json"));
|
extensions_.push_back(LoadAndExpectSuccess("intent_valid_2.json"));
|
||||||
ASSERT_EQ(2U, extensions_.size());
|
|
||||||
|
|
||||||
TestConsumer consumer;
|
TestConsumer consumer;
|
||||||
consumer.expected_id_ = registry_.GetAllIntentProviders(&consumer);
|
consumer.expected_id_ = registry_.GetAllIntentProviders(&consumer);
|
||||||
@ -217,9 +223,8 @@ TEST_F(WebIntentsRegistryTest, GetExtensionIntents) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WebIntentsRegistryTest, GetSomeExtensionIntents) {
|
TEST_F(WebIntentsRegistryTest, GetSomeExtensionIntents) {
|
||||||
extensions_.Insert(LoadAndExpectSuccess("intent_valid.json"));
|
extensions_.push_back(LoadAndExpectSuccess("intent_valid.json"));
|
||||||
extensions_.Insert(LoadAndExpectSuccess("intent_valid_2.json"));
|
extensions_.push_back(LoadAndExpectSuccess("intent_valid_2.json"));
|
||||||
ASSERT_EQ(2U, extensions_.size());
|
|
||||||
|
|
||||||
TestConsumer consumer;
|
TestConsumer consumer;
|
||||||
consumer.expected_id_ = registry_.GetIntentProviders(
|
consumer.expected_id_ = registry_.GetIntentProviders(
|
||||||
@ -230,9 +235,8 @@ TEST_F(WebIntentsRegistryTest, GetSomeExtensionIntents) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WebIntentsRegistryTest, GetIntentsFromMixedSources) {
|
TEST_F(WebIntentsRegistryTest, GetIntentsFromMixedSources) {
|
||||||
extensions_.Insert(LoadAndExpectSuccess("intent_valid.json"));
|
extensions_.push_back(LoadAndExpectSuccess("intent_valid.json"));
|
||||||
extensions_.Insert(LoadAndExpectSuccess("intent_valid_2.json"));
|
extensions_.push_back(LoadAndExpectSuccess("intent_valid_2.json"));
|
||||||
ASSERT_EQ(2U, extensions_.size());
|
|
||||||
|
|
||||||
webkit_glue::WebIntentServiceData service;
|
webkit_glue::WebIntentServiceData service;
|
||||||
service.service_url = GURL("http://somewhere.com/intent/edit.html");
|
service.service_url = GURL("http://somewhere.com/intent/edit.html");
|
||||||
|
@ -78,22 +78,22 @@ std::vector<std::string> SyncExtensionHelper::GetInstalledExtensionNames(
|
|||||||
std::vector<std::string> names;
|
std::vector<std::string> names;
|
||||||
ExtensionService* extension_service = profile->GetExtensionService();
|
ExtensionService* extension_service = profile->GetExtensionService();
|
||||||
|
|
||||||
const ExtensionSet* extensions = extension_service->extensions();
|
const ExtensionList* extensions = extension_service->extensions();
|
||||||
for (ExtensionSet::const_iterator it = extensions->begin();
|
for (ExtensionList::const_iterator it = extensions->begin();
|
||||||
it != extensions->end(); ++it) {
|
it != extensions->end(); ++it) {
|
||||||
names.push_back((*it)->name());
|
names.push_back((*it)->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExtensionSet* disabled_extensions =
|
const ExtensionList* disabled_extensions =
|
||||||
extension_service->disabled_extensions();
|
extension_service->disabled_extensions();
|
||||||
for (ExtensionSet::const_iterator it = disabled_extensions->begin();
|
for (ExtensionList::const_iterator it = disabled_extensions->begin();
|
||||||
it != disabled_extensions->end(); ++it) {
|
it != disabled_extensions->end(); ++it) {
|
||||||
names.push_back((*it)->name());
|
names.push_back((*it)->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExtensionSet* terminated_extensions =
|
const ExtensionList* terminated_extensions =
|
||||||
extension_service->terminated_extensions();
|
extension_service->terminated_extensions();
|
||||||
for (ExtensionSet::const_iterator it = terminated_extensions->begin();
|
for (ExtensionList::const_iterator it = terminated_extensions->begin();
|
||||||
it != terminated_extensions->end(); ++it) {
|
it != terminated_extensions->end(); ++it) {
|
||||||
names.push_back((*it)->name());
|
names.push_back((*it)->name());
|
||||||
}
|
}
|
||||||
@ -180,8 +180,8 @@ SyncExtensionHelper::ExtensionStateMap
|
|||||||
|
|
||||||
ExtensionService* extension_service = profile->GetExtensionService();
|
ExtensionService* extension_service = profile->GetExtensionService();
|
||||||
|
|
||||||
const ExtensionSet* extensions = extension_service->extensions();
|
const ExtensionList* extensions = extension_service->extensions();
|
||||||
for (ExtensionSet::const_iterator it = extensions->begin();
|
for (ExtensionList::const_iterator it = extensions->begin();
|
||||||
it != extensions->end(); ++it) {
|
it != extensions->end(); ++it) {
|
||||||
const std::string& id = (*it)->id();
|
const std::string& id = (*it)->id();
|
||||||
extension_state_map[id].enabled_state = ExtensionState::ENABLED;
|
extension_state_map[id].enabled_state = ExtensionState::ENABLED;
|
||||||
@ -191,9 +191,9 @@ SyncExtensionHelper::ExtensionStateMap
|
|||||||
<< profile_debug_name << " is enabled";
|
<< profile_debug_name << " is enabled";
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExtensionSet* disabled_extensions =
|
const ExtensionList* disabled_extensions =
|
||||||
extension_service->disabled_extensions();
|
extension_service->disabled_extensions();
|
||||||
for (ExtensionSet::const_iterator it = disabled_extensions->begin();
|
for (ExtensionList::const_iterator it = disabled_extensions->begin();
|
||||||
it != disabled_extensions->end(); ++it) {
|
it != disabled_extensions->end(); ++it) {
|
||||||
const std::string& id = (*it)->id();
|
const std::string& id = (*it)->id();
|
||||||
extension_state_map[id].enabled_state = ExtensionState::DISABLED;
|
extension_state_map[id].enabled_state = ExtensionState::DISABLED;
|
||||||
|
@ -338,8 +338,8 @@ void ThemeService::RemoveUnusedThemes() {
|
|||||||
return;
|
return;
|
||||||
std::string current_theme = GetThemeID();
|
std::string current_theme = GetThemeID();
|
||||||
std::vector<std::string> remove_list;
|
std::vector<std::string> remove_list;
|
||||||
const ExtensionSet* extensions = service->extensions();
|
const ExtensionList* extensions = service->extensions();
|
||||||
for (ExtensionSet::const_iterator it = extensions->begin();
|
for (ExtensionList::const_iterator it = extensions->begin();
|
||||||
it != extensions->end(); ++it) {
|
it != extensions->end(); ++it) {
|
||||||
if ((*it)->is_theme() && (*it)->id() != current_theme) {
|
if ((*it)->is_theme() && (*it)->id() != current_theme) {
|
||||||
remove_list.push_back((*it)->id());
|
remove_list.push_back((*it)->id());
|
||||||
|
@ -164,12 +164,11 @@ class BrowserTest : public ExtensionBrowserTest {
|
|||||||
|
|
||||||
// Returns the app extension aptly named "App Test".
|
// Returns the app extension aptly named "App Test".
|
||||||
const Extension* GetExtension() {
|
const Extension* GetExtension() {
|
||||||
const ExtensionSet* extensions =
|
const ExtensionList* extensions =
|
||||||
browser()->profile()->GetExtensionService()->extensions();
|
browser()->profile()->GetExtensionService()->extensions();
|
||||||
for (ExtensionSet::const_iterator it = extensions->begin();
|
for (size_t i = 0; i < extensions->size(); ++i) {
|
||||||
it != extensions->end(); ++it) {
|
if ((*extensions)[i]->name() == "App Test")
|
||||||
if ((*it)->name() == "App Test")
|
return (*extensions)[i];
|
||||||
return *it;
|
|
||||||
}
|
}
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -540,12 +540,10 @@ void LocationBarViewMac::RefreshPageActionDecorations() {
|
|||||||
if (!service)
|
if (!service)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Find all the page actions.
|
|
||||||
std::vector<ExtensionAction*> page_actions;
|
std::vector<ExtensionAction*> page_actions;
|
||||||
for (ExtensionSet::const_iterator it = service->extensions()->begin();
|
for (size_t i = 0; i < service->extensions()->size(); ++i) {
|
||||||
it != service->extensions()->end(); ++it) {
|
if (service->extensions()->at(i)->page_action())
|
||||||
if ((*it)->page_action())
|
page_actions.push_back(service->extensions()->at(i)->page_action());
|
||||||
page_actions.push_back((*it)->page_action());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// On startup we sometimes haven't loaded any extensions. This makes sure
|
// On startup we sometimes haven't loaded any extensions. This makes sure
|
||||||
|
@ -642,10 +642,9 @@ void LocationBarViewGtk::UpdatePageActions() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Find all the page actions.
|
// Find all the page actions.
|
||||||
for (ExtensionSet::const_iterator it = service->extensions()->begin();
|
for (size_t i = 0; i < service->extensions()->size(); ++i) {
|
||||||
it != service->extensions()->end(); ++it) {
|
if (service->extensions()->at(i)->page_action())
|
||||||
if ((*it)->page_action())
|
page_actions.push_back(service->extensions()->at(i)->page_action());
|
||||||
page_actions.push_back((*it)->page_action());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize on the first call, or re-inialize if more extensions have been
|
// Initialize on the first call, or re-inialize if more extensions have been
|
||||||
|
@ -242,14 +242,17 @@ IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, ForceHide) {
|
|||||||
IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, TestCrash57536) {
|
IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, TestCrash57536) {
|
||||||
LOG(INFO) << "Test starting\n" << std::flush;
|
LOG(INFO) << "Test starting\n" << std::flush;
|
||||||
|
|
||||||
|
ExtensionService* service = browser()->profile()->GetExtensionService();
|
||||||
|
const size_t size_before = service->extensions()->size();
|
||||||
|
|
||||||
LOG(INFO) << "Loading extension\n" << std::flush;
|
LOG(INFO) << "Loading extension\n" << std::flush;
|
||||||
|
|
||||||
// Load extension A (contains browser action).
|
// Load extension A (contains browser action).
|
||||||
const Extension* extension = LoadExtension(
|
ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("api_test")
|
||||||
test_data_dir_.AppendASCII("api_test")
|
.AppendASCII("browser_action")
|
||||||
.AppendASCII("browser_action")
|
.AppendASCII("crash_57536")));
|
||||||
.AppendASCII("crash_57536"));
|
|
||||||
ASSERT_TRUE(extension);
|
const Extension* extension = service->extensions()->at(size_before);
|
||||||
|
|
||||||
LOG(INFO) << "Creating bitmap\n" << std::flush;
|
LOG(INFO) << "Creating bitmap\n" << std::flush;
|
||||||
|
|
||||||
|
@ -925,10 +925,9 @@ void LocationBarView::RefreshPageActionViews() {
|
|||||||
// Remember the previous visibility of the page actions so that we can
|
// Remember the previous visibility of the page actions so that we can
|
||||||
// notify when this changes.
|
// notify when this changes.
|
||||||
std::vector<ExtensionAction*> page_actions;
|
std::vector<ExtensionAction*> page_actions;
|
||||||
for (ExtensionSet::const_iterator it = service->extensions()->begin();
|
for (size_t i = 0; i < service->extensions()->size(); ++i) {
|
||||||
it != service->extensions()->end(); ++it) {
|
if (service->extensions()->at(i)->page_action())
|
||||||
if ((*it)->page_action())
|
page_actions.push_back(service->extensions()->at(i)->page_action());
|
||||||
page_actions.push_back((*it)->page_action());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// On startup we sometimes haven't loaded any extensions. This makes sure
|
// On startup we sometimes haven't loaded any extensions. This makes sure
|
||||||
|
@ -326,12 +326,11 @@ void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
|
|||||||
AutoReset<bool> auto_reset(&ignore_changes_, true);
|
AutoReset<bool> auto_reset(&ignore_changes_, true);
|
||||||
|
|
||||||
ListValue* list = new ListValue();
|
ListValue* list = new ListValue();
|
||||||
const ExtensionSet* extensions = extension_service_->extensions();
|
const ExtensionList* extensions = extension_service_->extensions();
|
||||||
ExtensionSet::const_iterator it;
|
ExtensionList::const_iterator it;
|
||||||
for (it = extensions->begin(); it != extensions->end(); ++it) {
|
for (it = extensions->begin(); it != extensions->end(); ++it) {
|
||||||
const Extension* extension = *it;
|
if (!IsAppExcludedFromList(*it)) {
|
||||||
if (!IsAppExcludedFromList(extension)) {
|
DictionaryValue* app_info = GetAppInfo(*it);
|
||||||
DictionaryValue* app_info = GetAppInfo(extension);
|
|
||||||
list->Append(app_info);
|
list->Append(app_info);
|
||||||
} else {
|
} else {
|
||||||
// This is necessary because in some previous versions of chrome, we set a
|
// This is necessary because in some previous versions of chrome, we set a
|
||||||
@ -339,8 +338,8 @@ void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
|
|||||||
// and this fixes it. If we don't fix it, GetNaturalAppPageIndex() doesn't
|
// and this fixes it. If we don't fix it, GetNaturalAppPageIndex() doesn't
|
||||||
// work. See http://crbug.com/98325
|
// work. See http://crbug.com/98325
|
||||||
ExtensionPrefs* prefs = extension_service_->extension_prefs();
|
ExtensionPrefs* prefs = extension_service_->extension_prefs();
|
||||||
if (prefs->GetPageIndex(extension->id()) != -1)
|
if (prefs->GetPageIndex((*it)->id()) != -1)
|
||||||
prefs->ClearPageIndex(extension->id());
|
prefs->ClearPageIndex((*it)->id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,8 +150,8 @@ void ExtensionSettingsHandler::HandleRequestExtensionsData(
|
|||||||
|
|
||||||
ExtensionWarningSet* warnings = extension_service_->extension_warnings();
|
ExtensionWarningSet* warnings = extension_service_->extension_warnings();
|
||||||
|
|
||||||
const ExtensionSet* extensions = extension_service_->extensions();
|
const ExtensionList* extensions = extension_service_->extensions();
|
||||||
for (ExtensionSet::const_iterator extension = extensions->begin();
|
for (ExtensionList::const_iterator extension = extensions->begin();
|
||||||
extension != extensions->end(); ++extension) {
|
extension != extensions->end(); ++extension) {
|
||||||
if (ShouldShowExtension(*extension)) {
|
if (ShouldShowExtension(*extension)) {
|
||||||
extensions_list->Append(CreateExtensionDetailValue(
|
extensions_list->Append(CreateExtensionDetailValue(
|
||||||
@ -163,7 +163,7 @@ void ExtensionSettingsHandler::HandleRequestExtensionsData(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
extensions = extension_service_->disabled_extensions();
|
extensions = extension_service_->disabled_extensions();
|
||||||
for (ExtensionSet::const_iterator extension = extensions->begin();
|
for (ExtensionList::const_iterator extension = extensions->begin();
|
||||||
extension != extensions->end(); ++extension) {
|
extension != extensions->end(); ++extension) {
|
||||||
if (ShouldShowExtension(*extension)) {
|
if (ShouldShowExtension(*extension)) {
|
||||||
extensions_list->Append(CreateExtensionDetailValue(
|
extensions_list->Append(CreateExtensionDetailValue(
|
||||||
@ -176,7 +176,7 @@ void ExtensionSettingsHandler::HandleRequestExtensionsData(
|
|||||||
}
|
}
|
||||||
extensions = extension_service_->terminated_extensions();
|
extensions = extension_service_->terminated_extensions();
|
||||||
std::vector<ExtensionPage> empty_pages;
|
std::vector<ExtensionPage> empty_pages;
|
||||||
for (ExtensionSet::const_iterator extension = extensions->begin();
|
for (ExtensionList::const_iterator extension = extensions->begin();
|
||||||
extension != extensions->end(); ++extension) {
|
extension != extensions->end(); ++extension) {
|
||||||
if (ShouldShowExtension(*extension)) {
|
if (ShouldShowExtension(*extension)) {
|
||||||
extensions_list->Append(CreateExtensionDetailValue(
|
extensions_list->Append(CreateExtensionDetailValue(
|
||||||
|
@ -143,8 +143,8 @@ void SearchEngineManagerHandler::OnModelChanged() {
|
|||||||
ExtensionService* extension_service =
|
ExtensionService* extension_service =
|
||||||
Profile::FromWebUI(web_ui_)->GetExtensionService();
|
Profile::FromWebUI(web_ui_)->GetExtensionService();
|
||||||
if (extension_service) {
|
if (extension_service) {
|
||||||
const ExtensionSet* extensions = extension_service->extensions();
|
const ExtensionList* extensions = extension_service->extensions();
|
||||||
for (ExtensionSet::const_iterator it = extensions->begin();
|
for (ExtensionList::const_iterator it = extensions->begin();
|
||||||
it != extensions->end(); ++it) {
|
it != extensions->end(); ++it) {
|
||||||
if ((*it)->omnibox_keyword().size() > 0)
|
if ((*it)->omnibox_keyword().size() > 0)
|
||||||
keyword_list.Append(CreateDictionaryForExtension(*(*it)));
|
keyword_list.Append(CreateDictionaryForExtension(*(*it)));
|
||||||
|
@ -29,10 +29,6 @@ size_t ExtensionSet::size() const {
|
|||||||
return extensions_.size();
|
return extensions_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExtensionSet::is_empty() const {
|
|
||||||
return extensions_.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ExtensionSet::Contains(const std::string& extension_id) const {
|
bool ExtensionSet::Contains(const std::string& extension_id) const {
|
||||||
return extensions_.find(extension_id) != extensions_.end();
|
return extensions_.find(extension_id) != extensions_.end();
|
||||||
}
|
}
|
||||||
@ -45,11 +41,7 @@ void ExtensionSet::Remove(const std::string& id) {
|
|||||||
extensions_.erase(id);
|
extensions_.erase(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtensionSet::Clear() {
|
std::string ExtensionSet::GetIdByURL(const ExtensionURLInfo& info) const {
|
||||||
extensions_.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ExtensionSet::GetIDByURL(const ExtensionURLInfo& info) const {
|
|
||||||
DCHECK(!info.origin().isNull());
|
DCHECK(!info.origin().isNull());
|
||||||
|
|
||||||
if (info.url().SchemeIs(chrome::kExtensionScheme))
|
if (info.url().SchemeIs(chrome::kExtensionScheme))
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
#define CHROME_COMMON_EXTENSIONS_EXTENSION_SET_H_
|
#define CHROME_COMMON_EXTENSIONS_EXTENSION_SET_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <iterator>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "base/gtest_prod_util.h"
|
#include "base/gtest_prod_util.h"
|
||||||
#include "base/memory/ref_counted.h"
|
#include "base/memory/ref_counted.h"
|
||||||
@ -44,39 +44,17 @@ class ExtensionSet {
|
|||||||
public:
|
public:
|
||||||
typedef std::pair<FilePath, std::string> ExtensionPathAndDefaultLocale;
|
typedef std::pair<FilePath, std::string> ExtensionPathAndDefaultLocale;
|
||||||
typedef std::map<std::string, scoped_refptr<const Extension> > ExtensionMap;
|
typedef std::map<std::string, scoped_refptr<const Extension> > ExtensionMap;
|
||||||
|
typedef ExtensionMap::const_iterator const_iterator;
|
||||||
// Iteration over the values of the map (given that it's an ExtensionSet,
|
|
||||||
// it should iterate like a set iterator).
|
|
||||||
class const_iterator :
|
|
||||||
public std::iterator<std::input_iterator_tag,
|
|
||||||
scoped_refptr<const Extension> > {
|
|
||||||
public:
|
|
||||||
const_iterator() {}
|
|
||||||
explicit const_iterator(ExtensionMap::const_iterator it) :
|
|
||||||
it_(it) {}
|
|
||||||
const_iterator& operator++() {
|
|
||||||
++it_;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
const scoped_refptr<const Extension> operator*() {
|
|
||||||
return it_->second;
|
|
||||||
}
|
|
||||||
bool operator!=(const const_iterator& other) { return it_ != other.it_; }
|
|
||||||
bool operator==(const const_iterator& other) { return it_ == other.it_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
ExtensionMap::const_iterator it_;
|
|
||||||
};
|
|
||||||
|
|
||||||
ExtensionSet();
|
ExtensionSet();
|
||||||
~ExtensionSet();
|
~ExtensionSet();
|
||||||
|
|
||||||
|
// Gets the number of extensions contained.
|
||||||
size_t size() const;
|
size_t size() const;
|
||||||
bool is_empty() const;
|
|
||||||
|
|
||||||
// Iteration support.
|
// Iteration support.
|
||||||
const_iterator begin() const { return const_iterator(extensions_.begin()); }
|
const_iterator begin() const { return extensions_.begin(); }
|
||||||
const_iterator end() const { return const_iterator(extensions_.end()); }
|
const_iterator end() const { return extensions_.end(); }
|
||||||
|
|
||||||
// Returns true if the set contains the specified extension.
|
// Returns true if the set contains the specified extension.
|
||||||
bool Contains(const std::string& id) const;
|
bool Contains(const std::string& id) const;
|
||||||
@ -88,12 +66,9 @@ class ExtensionSet {
|
|||||||
// Removes the specified extension.
|
// Removes the specified extension.
|
||||||
void Remove(const std::string& id);
|
void Remove(const std::string& id);
|
||||||
|
|
||||||
// Removes all extensions.
|
|
||||||
void Clear();
|
|
||||||
|
|
||||||
// Returns the extension ID, or empty if none. This includes web URLs that
|
// Returns the extension ID, or empty if none. This includes web URLs that
|
||||||
// are part of an extension's web extent.
|
// are part of an extension's web extent.
|
||||||
std::string GetIDByURL(const ExtensionURLInfo& info) const;
|
std::string GetIdByURL(const ExtensionURLInfo& info) const;
|
||||||
|
|
||||||
// Returns the Extension, or NULL if none. This includes web URLs that are
|
// Returns the Extension, or NULL if none. This includes web URLs that are
|
||||||
// part of an extension's web extent.
|
// part of an extension's web extent.
|
||||||
|
@ -293,7 +293,7 @@ void ExtensionDispatcher::DidCreateScriptContext(
|
|||||||
extension_id = user_script_slave_->GetExtensionIdForIsolatedWorld(world_id);
|
extension_id = user_script_slave_->GetExtensionIdForIsolatedWorld(world_id);
|
||||||
} else {
|
} else {
|
||||||
GURL frame_url = UserScriptSlave::GetDataSourceURLForFrame(frame);
|
GURL frame_url = UserScriptSlave::GetDataSourceURLForFrame(frame);
|
||||||
extension_id = extensions_.GetIDByURL(
|
extension_id = extensions_.GetIdByURL(
|
||||||
ExtensionURLInfo(frame->document().securityOrigin(), frame_url));
|
ExtensionURLInfo(frame->document().securityOrigin(), frame_url));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user