summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/extensions/api/developer_private/developer_private_api.cc3
-rw-r--r--chrome/browser/extensions/api/messaging/message_service.cc3
-rw-r--r--chrome/browser/extensions/api/preference/preference_helpers.cc5
-rw-r--r--chrome/browser/extensions/api/tabs/tabs_api.cc3
-rw-r--r--chrome/browser/extensions/component_loader_unittest.cc14
-rw-r--r--chrome/browser/extensions/event_router.cc3
-rw-r--r--chrome/browser/extensions/extension_fullscreen_apitest.cc1
-rw-r--r--chrome/browser/extensions/extension_info_map.cc3
-rw-r--r--chrome/browser/extensions/extension_pointer_lock_apitest.cc1
-rw-r--r--chrome/browser/extensions/extension_process_manager.cc10
-rw-r--r--chrome/browser/extensions/extension_protocols.cc3
-rw-r--r--chrome/browser/extensions/extension_protocols_unittest.cc10
-rw-r--r--chrome/browser/extensions/extension_service.cc5
-rw-r--r--chrome/browser/extensions/extension_web_ui.cc3
-rw-r--r--chrome/browser/media_galleries/media_file_system_registry_unittest.cc2
-rw-r--r--chrome/browser/media_galleries/media_galleries_preferences_unittest.cc5
-rw-r--r--chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller_unittest.mm2
-rw-r--r--chrome/browser/ui/webui/extensions/extension_settings_handler.cc3
-rw-r--r--chrome/chrome_common.gypi6
-rw-r--r--chrome/common/extensions/api/_manifest_features.json2
-rw-r--r--chrome/common/extensions/extension.cc31
-rw-r--r--chrome/common/extensions/extension.h5
-rw-r--r--chrome/common/extensions/extension_unittest.cc2
-rw-r--r--chrome/common/extensions/incognito_handler.cc73
-rw-r--r--chrome/common/extensions/incognito_handler.h43
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifest_test.cc10
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifest_test.h1
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc15
-rw-r--r--chrome/common/extensions/permissions/permission_set_unittest.cc13
-rw-r--r--chrome/renderer/chrome_content_renderer_client.cc2
-rw-r--r--chrome/utility/chrome_content_utility_client.cc2
31 files changed, 211 insertions, 73 deletions
diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
index fc212a4..4f38bc2 100644
--- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc
+++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
@@ -30,6 +30,7 @@
#include "chrome/common/extensions/api/icons/icons_handler.h"
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension_icon_set.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
@@ -321,7 +322,7 @@ ItemInspectViewList DeveloperPrivateGetItemsInfoFunction::
// Repeat for the incognito process, if applicable. Don't try to get
// shell windows for incognito process.
if (service->profile()->HasOffTheRecordProfile() &&
- extension->incognito_split_mode()) {
+ IncognitoInfo::IsSplitMode(extension)) {
process_manager = ExtensionSystem::Get(
service->profile()->GetOffTheRecordProfile())->process_manager();
GetInspectablePagesForExtensionProcess(
diff --git a/chrome/browser/extensions/api/messaging/message_service.cc b/chrome/browser/extensions/api/messaging/message_service.cc
index 6b9c1ab..be369e5 100644
--- a/chrome/browser/extensions/api/messaging/message_service.cc
+++ b/chrome/browser/extensions/api/messaging/message_service.cc
@@ -25,6 +25,7 @@
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/view_type.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
@@ -486,7 +487,7 @@ bool MessageService::MaybeAddPendingOpenChannelTask(
// If the extension uses spanning incognito mode, make sure we're always
// using the original profile since that is what the extension process
// will use.
- if (!extension->incognito_split_mode())
+ if (!IncognitoInfo::IsSplitMode(extension))
profile = profile->GetOriginalProfile();
if (lazy_background_task_queue_->ShouldEnqueueTask(profile, extension)) {
diff --git a/chrome/browser/extensions/api/preference/preference_helpers.cc b/chrome/browser/extensions/api/preference/preference_helpers.cc
index 739f401..55297dd 100644
--- a/chrome/browser/extensions/api/preference/preference_helpers.cc
+++ b/chrome/browser/extensions/api/preference/preference_helpers.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/incognito_handler.h"
namespace extensions {
namespace preference_helpers {
@@ -98,7 +99,7 @@ void DispatchEventToExtensions(
// TODO(bauerb): Only iterate over registered event listeners.
if (router->ExtensionHasEventListener(extension_id, event_name) &&
(*it)->HasAPIPermission(permission) &&
- (!incognito || (*it)->incognito_split_mode() ||
+ (!incognito || IncognitoInfo::IsSplitMode(*it) ||
extension_service->CanCrossIncognito(*it))) {
// Inject level of control key-value.
DictionaryValue* dict;
@@ -114,7 +115,7 @@ void DispatchEventToExtensions(
// incognito pref has not alredy been set
Profile* restrict_to_profile = NULL;
bool from_incognito = false;
- if ((*it)->incognito_split_mode()) {
+ if (IncognitoInfo::IsSplitMode(*it)) {
if (incognito && extension_service->IsIncognitoEnabled(extension_id)) {
restrict_to_profile = profile->GetOffTheRecordProfile();
} else if (!incognito &&
diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc
index 7e9a659..3201c96 100644
--- a/chrome/browser/extensions/api/tabs/tabs_api.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -58,6 +58,7 @@
#include "chrome/common/extensions/extension_l10n_util.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/extension_messages.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/message_bundle.h"
#include "chrome/common/extensions/user_script.h"
#include "chrome/common/pref_names.h"
@@ -1097,7 +1098,7 @@ bool TabsCreateFunction::RunImpl() {
// We can't load extension URLs into incognito windows unless the extension
// uses split mode. Special case to fall back to a tabbed window.
if (url.SchemeIs(extensions::kExtensionScheme) &&
- !GetExtension()->incognito_split_mode() &&
+ !extensions::IncognitoInfo::IsSplitMode(GetExtension()) &&
browser->profile()->IsOffTheRecord()) {
Profile* profile = browser->profile()->GetOriginalProfile();
chrome::HostDesktopType desktop_type = browser->host_desktop_type();
diff --git a/chrome/browser/extensions/component_loader_unittest.cc b/chrome/browser/extensions/component_loader_unittest.cc
index 8923c5a..9b2b980 100644
--- a/chrome/browser/extensions/component_loader_unittest.cc
+++ b/chrome/browser/extensions/component_loader_unittest.cc
@@ -14,13 +14,15 @@
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_set.h"
+#include "chrome/common/extensions/incognito_handler.h"
+#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_pref_service_syncable.h"
#include "components/user_prefs/pref_registry_syncable.h"
#include "extensions/common/constants.h"
#include "testing/gtest/include/gtest/gtest.h"
-using extensions::Extension;
+namespace extensions {
namespace {
@@ -72,8 +74,6 @@ class MockExtensionService : public TestExtensionService {
} // namespace
-namespace extensions {
-
class ComponentLoaderTest : public testing::Test {
public:
ComponentLoaderTest() :
@@ -82,8 +82,9 @@ class ComponentLoaderTest : public testing::Test {
component_loader_(&extension_service_, &prefs_, &local_state_) {
}
- virtual void SetUp() {
+ virtual void SetUp() OVERRIDE {
(new BackgroundManifestHandler)->Register();
+ (new IncognitoHandler)->Register();
extension_path_ =
GetBasePath().AppendASCII("good")
@@ -113,6 +114,11 @@ class ComponentLoaderTest : public testing::Test {
#endif
}
+ virtual void TearDown() OVERRIDE {
+ ManifestHandler::ClearRegistryForTesting();
+ testing::Test::TearDown();
+ }
+
protected:
MockExtensionService extension_service_;
TestingPrefServiceSyncable prefs_;
diff --git a/chrome/browser/extensions/event_router.cc b/chrome/browser/extensions/event_router.cc
index 337f4f9..c21c4a3 100644
--- a/chrome/browser/extensions/event_router.cc
+++ b/chrome/browser/extensions/event_router.cc
@@ -32,6 +32,7 @@
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/view_type.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_process_host.h"
@@ -451,7 +452,7 @@ void EventRouter::DispatchLazyEvent(
}
if (profile_->HasOffTheRecordProfile() &&
- extension->incognito_split_mode()) {
+ IncognitoInfo::IsSplitMode(extension)) {
if (MaybeLoadLazyBackgroundPageToDispatchEvent(
profile_->GetOffTheRecordProfile(), extension, event)) {
already_dispatched->insert(
diff --git a/chrome/browser/extensions/extension_fullscreen_apitest.cc b/chrome/browser/extensions/extension_fullscreen_apitest.cc
index 9bb9baa..87786789 100644
--- a/chrome/browser/extensions/extension_fullscreen_apitest.cc
+++ b/chrome/browser/extensions/extension_fullscreen_apitest.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/test/base/ui_test_utils.h"
-
IN_PROC_BROWSER_TEST_F(ExtensionApiTest,
ExtensionFullscreenAccessFail) {
// Test that fullscreen can be accessed from an extension without permission.
diff --git a/chrome/browser/extensions/extension_info_map.cc b/chrome/browser/extensions/extension_info_map.cc
index d3b3d42..0139fd9 100644
--- a/chrome/browser/extensions/extension_info_map.cc
+++ b/chrome/browser/extensions/extension_info_map.cc
@@ -6,6 +6,7 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_set.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/common/constants.h"
@@ -97,7 +98,7 @@ bool ExtensionInfoMap::IsIncognitoEnabled(
bool ExtensionInfoMap::CanCrossIncognito(const Extension* extension) const {
// This is duplicated from ExtensionService :(.
return IsIncognitoEnabled(extension->id()) &&
- !extension->incognito_split_mode();
+ !extensions::IncognitoInfo::IsSplitMode(extension);
}
void ExtensionInfoMap::RegisterExtensionProcess(const std::string& extension_id,
diff --git a/chrome/browser/extensions/extension_pointer_lock_apitest.cc b/chrome/browser/extensions/extension_pointer_lock_apitest.cc
index 2762723..3bfeaf43 100644
--- a/chrome/browser/extensions/extension_pointer_lock_apitest.cc
+++ b/chrome/browser/extensions/extension_pointer_lock_apitest.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/test/base/ui_test_utils.h"
-
IN_PROC_BROWSER_TEST_F(ExtensionApiTest,
ExtensionPointerLockAccessFail) {
// Test that pointer lock cannot be accessed from an extension without
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index 0bb03f9..f529bed 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -28,6 +28,7 @@
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "chrome/common/url_constants.h"
@@ -181,6 +182,7 @@ ExtensionProcessManager::ExtensionProcessManager(Profile* profile)
}
(new BackgroundManifestHandler())->Register();
+ (new extensions::IncognitoHandler())->Register();
}
ExtensionProcessManager::~ExtensionProcessManager() {
@@ -837,7 +839,7 @@ ExtensionHost* IncognitoExtensionProcessManager::CreateViewHost(
const GURL& url,
Browser* browser,
chrome::ViewType view_type) {
- if (extension->incognito_split_mode()) {
+ if (extensions::IncognitoInfo::IsSplitMode(extension)) {
if (IsIncognitoEnabled(extension)) {
return ExtensionProcessManager::CreateViewHost(extension, url,
browser, view_type);
@@ -855,7 +857,7 @@ ExtensionHost* IncognitoExtensionProcessManager::CreateViewHost(
void IncognitoExtensionProcessManager::CreateBackgroundHost(
const Extension* extension, const GURL& url) {
- if (extension->incognito_split_mode()) {
+ if (extensions::IncognitoInfo::IsSplitMode(extension)) {
if (IsIncognitoEnabled(extension))
ExtensionProcessManager::CreateBackgroundHost(extension, url);
} else {
@@ -870,8 +872,10 @@ SiteInstance* IncognitoExtensionProcessManager::GetSiteInstanceForURL(
if (service) {
const Extension* extension = service->extensions()->GetExtensionOrAppByURL(
ExtensionURLInfo(url));
- if (extension && !extension->incognito_split_mode())
+ if (extension &&
+ !extensions::IncognitoInfo::IsSplitMode(extension)) {
return original_manager_->GetSiteInstanceForURL(url);
+ }
}
return ExtensionProcessManager::GetSiteInstanceForURL(url);
}
diff --git a/chrome/browser/extensions/extension_protocols.cc b/chrome/browser/extensions/extension_protocols.cc
index 3423088..69ef52b 100644
--- a/chrome/browser/extensions/extension_protocols.cc
+++ b/chrome/browser/extensions/extension_protocols.cc
@@ -24,6 +24,7 @@
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_file_util.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/web_accessible_resources_handler.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/resource_request_info.h"
@@ -257,7 +258,7 @@ bool ExtensionCanLoadInIncognito(const ResourceRequestInfo* info,
if (info->GetResourceType() == ResourceType::MAIN_FRAME) {
const Extension* extension =
extension_info_map->extensions().GetByID(extension_id);
- return extension && extension->incognito_split_mode();
+ return extension && extensions::IncognitoInfo::IsSplitMode(extension);
}
return true;
diff --git a/chrome/browser/extensions/extension_protocols_unittest.cc b/chrome/browser/extensions/extension_protocols_unittest.cc
index 48fffb6..e909031 100644
--- a/chrome/browser/extensions/extension_protocols_unittest.cc
+++ b/chrome/browser/extensions/extension_protocols_unittest.cc
@@ -6,12 +6,17 @@
#include "base/file_util.h"
#include "base/message_loop.h"
+#include "base/values.h"
#include "chrome/browser/extensions/extension_info_map.h"
#include "chrome/browser/extensions/extension_protocols.h"
#include "chrome/common/extensions/api/icons/icons_handler.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/extension_manifest_constants.h"
+#include "chrome/common/extensions/incognito_handler.h"
+#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/resource_request_info.h"
#include "content/public/test/mock_resource_context.h"
@@ -70,12 +75,13 @@ class ExtensionProtocolTest : public testing::Test {
file_thread_(BrowserThread::FILE, &message_loop_),
io_thread_(BrowserThread::IO, &message_loop_) {}
- virtual void SetUp() {
+ virtual void SetUp() OVERRIDE {
+ testing::Test::SetUp();
extension_info_map_ = new ExtensionInfoMap();
net::URLRequestContext* request_context =
resource_context_.GetRequestContext();
old_factory_ = request_context->job_factory();
-
+ (new IncognitoHandler)->Register();
(new IconsHandler)->Register();
}
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 5098729..e6f28b7 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -85,6 +85,7 @@
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/extensions/feature_switch.h"
#include "chrome/common/extensions/features/feature.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/manifest.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "chrome/common/pref_names.h"
@@ -1638,7 +1639,7 @@ bool ExtensionService::CanCrossIncognito(const Extension* extension) const {
// extensions only see events for a matching profile.
CHECK(extension);
return IsIncognitoEnabled(extension->id()) &&
- !extension->incognito_split_mode();
+ !extensions::IncognitoInfo::IsSplitMode(extension);
}
bool ExtensionService::CanLoadInIncognito(const Extension* extension) const {
@@ -1646,7 +1647,7 @@ bool ExtensionService::CanLoadInIncognito(const Extension* extension) const {
return true;
// Packaged apps and regular extensions need to be enabled specifically for
// incognito (and split mode should be set).
- return extension->incognito_split_mode() &&
+ return extensions::IncognitoInfo::IsSplitMode(extension) &&
IsIncognitoEnabled(extension->id());
}
diff --git a/chrome/browser/extensions/extension_web_ui.cc b/chrome/browser/extensions/extension_web_ui.cc
index 2ebaab0..d37df1d 100644
--- a/chrome/browser/extensions/extension_web_ui.cc
+++ b/chrome/browser/extensions/extension_web_ui.cc
@@ -23,6 +23,7 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_icon_set.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/url_constants.h"
#include "components/user_prefs/pref_registry_syncable.h"
#include "content/public/browser/navigation_controller.h"
@@ -241,7 +242,7 @@ bool ExtensionWebUI::HandleChromeURLOverride(
// We can't handle chrome-extension URLs in incognito mode unless the
// extension uses split mode.
bool incognito_override_allowed =
- extension->incognito_split_mode() &&
+ extensions::IncognitoInfo::IsSplitMode(extension) &&
service->IsIncognitoEnabled(extension->id());
if (profile->IsOffTheRecord() && !incognito_override_allowed) {
++i;
diff --git a/chrome/browser/media_galleries/media_file_system_registry_unittest.cc b/chrome/browser/media_galleries/media_file_system_registry_unittest.cc
index 5657f00..374f3a9 100644
--- a/chrome/browser/media_galleries/media_file_system_registry_unittest.cc
+++ b/chrome/browser/media_galleries/media_file_system_registry_unittest.cc
@@ -33,6 +33,7 @@
#include "chrome/browser/storage_monitor/test_storage_monitor.h"
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_browser_process.h"
@@ -756,6 +757,7 @@ void MediaFileSystemRegistryTest::SetUp() {
test_file_system_context_ = new TestMediaFileSystemContext(
g_browser_process->media_file_system_registry());
(new extensions::BackgroundManifestHandler)->Register();
+ (new extensions::IncognitoHandler)->Register();
ASSERT_TRUE(galleries_dir_.CreateUniqueTempDir());
empty_dir_ = galleries_dir_.path().AppendASCII("empty");
diff --git a/chrome/browser/media_galleries/media_galleries_preferences_unittest.cc b/chrome/browser/media_galleries/media_galleries_preferences_unittest.cc
index acd8663..5a3a4ff 100644
--- a/chrome/browser/media_galleries/media_galleries_preferences_unittest.cc
+++ b/chrome/browser/media_galleries/media_galleries_preferences_unittest.cc
@@ -22,6 +22,7 @@
#include "chrome/browser/storage_monitor/test_storage_monitor.h"
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread.h"
@@ -78,12 +79,15 @@ class MediaGalleriesPreferencesTest : public testing::Test {
}
virtual void SetUp() OVERRIDE {
+ testing::Test::SetUp();
+
extensions::TestExtensionSystem* extension_system(
static_cast<extensions::TestExtensionSystem*>(
extensions::ExtensionSystem::Get(profile_.get())));
extension_system->CreateExtensionService(
CommandLine::ForCurrentProcess(), base::FilePath(), false);
(new extensions::BackgroundManifestHandler)->Register();
+ (new extensions::IncognitoHandler)->Register();
gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get()));
@@ -118,6 +122,7 @@ class MediaGalleriesPreferencesTest : public testing::Test {
virtual void TearDown() OVERRIDE {
Verify();
extensions::ManifestHandler::ClearRegistryForTesting();
+ testing::Test::TearDown();
}
void Verify() {
diff --git a/chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller_unittest.mm
index f714b09..0b62b36 100644
--- a/chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller_unittest.mm
@@ -14,6 +14,7 @@
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_builder.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/manifest_handler.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -60,6 +61,7 @@ class ActionBoxMenuBubbleControllerTest : public CocoaProfileTest {
EXPECT_TRUE(service_->extensions_enabled());
service_->Init();
(new extensions::BackgroundManifestHandler)->Register();
+ (new extensions::IncognitoHandler)->Register();
}
virtual void TearDown() OVERRIDE {
diff --git a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
index 924c2dc..5ce90be 100644
--- a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
+++ b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
@@ -50,6 +50,7 @@
#include "chrome/common/extensions/extension_icon_set.h"
#include "chrome/common/extensions/extension_set.h"
#include "chrome/common/extensions/feature_switch.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
@@ -990,7 +991,7 @@ ExtensionSettingsHandler::GetInspectablePagesForExtension(
// Repeat for the incognito process, if applicable. Don't try to get
// shell windows for incognito processes.
if (extension_service_->profile()->HasOffTheRecordProfile() &&
- extension->incognito_split_mode()) {
+ extensions::IncognitoInfo::IsSplitMode(extension)) {
ExtensionProcessManager* process_manager =
extensions::ExtensionSystem::Get(extension_service_->profile()->
GetOffTheRecordProfile())->process_manager();
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 73aeddb4..2f26949 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -171,6 +171,8 @@
'common/extensions/api/extension_api.cc',
'common/extensions/api/extension_api.h',
'common/extensions/api/extension_api_stub.cc',
+ 'common/extensions/api/file_handlers/file_handlers_parser.cc',
+ 'common/extensions/api/file_handlers/file_handlers_parser.h',
'common/extensions/api/i18n/default_locale_handler.cc',
'common/extensions/api/i18n/default_locale_handler.h',
'common/extensions/api/icons/icons_handler.cc',
@@ -179,8 +181,6 @@
'common/extensions/api/identity/oauth2_manifest_handler.h',
'common/extensions/api/input_ime/input_components_handler.cc',
'common/extensions/api/input_ime/input_components_handler.h',
- 'common/extensions/api/file_handlers/file_handlers_parser.cc',
- 'common/extensions/api/file_handlers/file_handlers_parser.h',
'common/extensions/api/omnibox/omnibox_handler.cc',
'common/extensions/api/omnibox/omnibox_handler.h',
'common/extensions/api/page_launcher/page_launcher_handler.cc',
@@ -234,6 +234,8 @@
'common/extensions/features/permission_feature.h',
'common/extensions/features/simple_feature.cc',
'common/extensions/features/simple_feature.h',
+ 'common/extensions/incognito_handler.cc',
+ 'common/extensions/incognito_handler.h',
'common/extensions/manifest.cc',
'common/extensions/manifest.h',
'common/extensions/manifest_handler.cc',
diff --git a/chrome/common/extensions/api/_manifest_features.json b/chrome/common/extensions/api/_manifest_features.json
index ea92007..6dcbd21 100644
--- a/chrome/common/extensions/api/_manifest_features.json
+++ b/chrome/common/extensions/api/_manifest_features.json
@@ -161,7 +161,7 @@
},
"incognito": {
"channel": "stable",
- "extension_types": ["extension", "packaged_app", "platform_app"]
+ "extension_types": ["extension", "packaged_app"]
},
"input_components": {
"channel": "stable",
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index a83392e..ac7816d 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -38,6 +38,7 @@
#include "chrome/common/extensions/feature_switch.h"
#include "chrome/common/extensions/features/base_feature_provider.h"
#include "chrome/common/extensions/features/feature.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/manifest.h"
#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_handler_helpers.h"
@@ -1208,7 +1209,6 @@ bool Extension::IsTrustedId(const std::string& id) {
Extension::Extension(const base::FilePath& path,
scoped_ptr<extensions::Manifest> manifest)
: manifest_version_(0),
- incognito_split_mode_(false),
kiosk_enabled_(false),
offline_enabled_(false),
converted_from_user_script_(false),
@@ -1918,11 +1918,7 @@ bool Extension::LoadExtensionFeatures(string16* error) {
manifest_->GetBoolean(keys::kConvertedFromUserScript,
&converted_from_user_script_);
- if (!LoadSystemIndicator(error) ||
- !LoadIncognitoMode(error))
- return false;
-
- return true;
+ return LoadSystemIndicator(error);
}
bool Extension::LoadSystemIndicator(string16* error) {
@@ -1952,27 +1948,6 @@ bool Extension::LoadSystemIndicator(string16* error) {
return true;
}
-bool Extension::LoadIncognitoMode(string16* error) {
- // Apps default to split mode, extensions default to spanning.
- incognito_split_mode_ = is_app();
- if (!manifest_->HasKey(keys::kIncognito))
- return true;
- std::string value;
- if (!manifest_->GetString(keys::kIncognito, &value)) {
- *error = ASCIIToUTF16(errors::kInvalidIncognitoBehavior);
- return false;
- }
- if (value == values::kIncognitoSpanning) {
- incognito_split_mode_ = false;
- } else if (value == values::kIncognitoSplit) {
- incognito_split_mode_ = true;
- } else {
- *error = ASCIIToUTF16(errors::kInvalidIncognitoBehavior);
- return false;
- }
- return true;
-}
-
bool Extension::HasMultipleUISurfaces() const {
int num_surfaces = 0;
@@ -2108,7 +2083,7 @@ bool Extension::CheckPlatformAppFeatures(string16* error) const {
return false;
}
- if (!incognito_split_mode_) {
+ if (!IncognitoInfo::IsSplitMode(this)) {
*error = ASCIIToUTF16(errors::kInvalidIncognitoModeForPlatformApp);
return false;
}
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index 86f7f96..37f30e9 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -458,7 +458,6 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
const extensions::Manifest* manifest() const {
return manifest_.get();
}
- bool incognito_split_mode() const { return incognito_split_mode_; }
bool kiosk_enabled() const { return kiosk_enabled_; }
bool offline_enabled() const { return offline_enabled_; }
bool wants_file_access() const { return wants_file_access_; }
@@ -641,10 +640,6 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
// The absolute path to the directory the extension is stored in.
base::FilePath path_;
- // If true, a separate process will be used for the extension in incognito
- // mode.
- bool incognito_split_mode_;
-
// Whether the extension or app should be enabled in app kiosk mode.
bool kiosk_enabled_;
diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc
index 696de8b..b1cda14 100644
--- a/chrome/common/extensions/extension_unittest.cc
+++ b/chrome/common/extensions/extension_unittest.cc
@@ -22,6 +22,7 @@
#include "chrome/common/extensions/extension_file_util.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/features/feature.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/manifest.h"
#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
@@ -112,6 +113,7 @@ class ExtensionTest : public testing::Test {
(new CommandsHandler)->Register();
(new ContentScriptsHandler)->Register();
(new PluginsHandler)->Register();
+ (new IncognitoHandler)->Register();
}
virtual void TearDown() OVERRIDE {
diff --git a/chrome/common/extensions/incognito_handler.cc b/chrome/common/extensions/incognito_handler.cc
new file mode 100644
index 0000000..5bbcbf4
--- /dev/null
+++ b/chrome/common/extensions/incognito_handler.cc
@@ -0,0 +1,73 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/extensions/incognito_handler.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "base/utf_string_conversions.h"
+#include "base/values.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/extension_manifest_constants.h"
+
+namespace keys = extension_manifest_keys;
+
+namespace extensions {
+
+IncognitoInfo::IncognitoInfo(bool incognito_split_mode)
+ : split_mode(incognito_split_mode) {
+}
+
+IncognitoInfo::~IncognitoInfo() {
+}
+
+// static
+bool IncognitoInfo::IsSplitMode(const Extension* extension) {
+ IncognitoInfo* info = static_cast<IncognitoInfo*>(
+ extension->GetManifestData(keys::kIncognito));
+ return info ? info->split_mode : false;
+}
+
+IncognitoHandler::IncognitoHandler() {
+}
+
+IncognitoHandler::~IncognitoHandler() {
+}
+
+bool IncognitoHandler::Parse(Extension* extension, string16* error) {
+ if (!extension->manifest()->HasKey(keys::kIncognito)) {
+ // Apps default to split mode, extensions default to spanning.
+ extension->SetManifestData(keys::kIncognito,
+ new IncognitoInfo(extension->is_app()));
+ return true;
+ }
+
+ bool split_mode = false;
+ std::string incognito_string;
+ if (!extension->manifest()->GetString(keys::kIncognito, &incognito_string)) {
+ *error = ASCIIToUTF16(extension_manifest_errors::kInvalidIncognitoBehavior);
+ return false;
+ }
+
+ if (incognito_string == extension_manifest_values::kIncognitoSplit)
+ split_mode = true;
+ else if (incognito_string != extension_manifest_values::kIncognitoSpanning) {
+ // If incognito_string == kIncognitoSpanning, it is valid and
+ // split_mode remains false.
+ *error = ASCIIToUTF16(extension_manifest_errors::kInvalidIncognitoBehavior);
+ return false;
+ }
+
+ extension->SetManifestData(keys::kIncognito, new IncognitoInfo(split_mode));
+ return true;
+}
+
+bool IncognitoHandler::AlwaysParseForType(Manifest::Type type) const {
+ return true;
+}
+
+const std::vector<std::string> IncognitoHandler::Keys() const {
+ return SingleKey(keys::kIncognito);
+}
+
+} // namespace extensions
diff --git a/chrome/common/extensions/incognito_handler.h b/chrome/common/extensions/incognito_handler.h
new file mode 100644
index 0000000..f036e55
--- /dev/null
+++ b/chrome/common/extensions/incognito_handler.h
@@ -0,0 +1,43 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_EXTENSIONS_INCOGNITO_HANDLER_H_
+#define CHROME_COMMON_EXTENSIONS_INCOGNITO_HANDLER_H_
+
+#include "base/string16.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/manifest_handler.h"
+
+namespace extensions {
+
+struct IncognitoInfo : public Extension::ManifestData {
+ explicit IncognitoInfo(bool split_mode);
+ virtual ~IncognitoInfo();
+
+ // If true, a separate process will be used for the extension in incognito
+ // mode.
+ bool split_mode;
+
+ // Return the incognito mode information for the given |extension|.
+ static bool IsSplitMode(const Extension* extension);
+};
+
+// Parses the "incognito" manifest key.
+class IncognitoHandler : public ManifestHandler {
+ public:
+ IncognitoHandler();
+ virtual ~IncognitoHandler();
+
+ virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
+ virtual bool AlwaysParseForType(Manifest::Type type) const OVERRIDE;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(IncognitoHandler);
+};
+
+} // namespace extensions
+
+#endif // CHROME_COMMON_EXTENSIONS_INCOGNITO_HANDLER_H_
diff --git a/chrome/common/extensions/manifest_tests/extension_manifest_test.cc b/chrome/common/extensions/manifest_tests/extension_manifest_test.cc
index b4ce528..feb8c0b 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifest_test.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifest_test.cc
@@ -11,6 +11,8 @@
#include "base/values.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension_l10n_util.h"
+#include "chrome/common/extensions/extension_manifest_constants.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/manifest_handler.h"
#include "ui/base/l10n/l10n_util.h"
@@ -56,6 +58,14 @@ ExtensionManifestTest::ExtensionManifestTest()
// UNKNOWN == trunk.
current_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {}
+void ExtensionManifestTest::SetUp() {
+ testing::Test::SetUp();
+ // We need the IncognitoHandler registered for all tests, since
+ // Extension uses it in Extension::CheckPlatformAppFeatures() as part of the
+ // creation process.
+ (new extensions::IncognitoHandler)->Register();
+}
+
void ExtensionManifestTest::TearDown() {
extensions::ManifestHandler::ClearRegistryForTesting();
}
diff --git a/chrome/common/extensions/manifest_tests/extension_manifest_test.h b/chrome/common/extensions/manifest_tests/extension_manifest_test.h
index 79c1ea2..dbebb7b 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifest_test.h
+++ b/chrome/common/extensions/manifest_tests/extension_manifest_test.h
@@ -19,6 +19,7 @@ class ExtensionManifestTest : public testing::Test {
ExtensionManifestTest();
protected:
+ virtual void SetUp() OVERRIDE;
virtual void TearDown() OVERRIDE;
// Helper class that simplifies creating methods that take either a filename
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc
index fc0d158..6a9a704 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc
@@ -9,6 +9,7 @@
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/csp_handler.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -20,6 +21,7 @@ class PlatformAppsManifestTest : public ExtensionManifestTest {
virtual void SetUp() OVERRIDE {
(new BackgroundManifestHandler)->Register();
(new CSPHandler(true))->Register(); // platform app.
+ (new IncognitoHandler())->Register();
}
};
@@ -27,22 +29,20 @@ TEST_F(PlatformAppsManifestTest, PlatformApps) {
scoped_refptr<extensions::Extension> extension =
LoadAndExpectSuccess("init_valid_platform_app.json");
EXPECT_TRUE(extension->is_storage_isolated());
- EXPECT_TRUE(extension->incognito_split_mode());
+ EXPECT_TRUE(IncognitoInfo::IsSplitMode(extension));
extension =
LoadAndExpectSuccess("init_valid_platform_app_no_manifest_version.json");
EXPECT_EQ(2, extension->manifest_version());
extension = LoadAndExpectSuccess("incognito_valid_platform_app.json");
- EXPECT_TRUE(extension->incognito_split_mode());
+ EXPECT_TRUE(IncognitoInfo::IsSplitMode(extension));
Testcase error_testcases[] = {
Testcase("init_invalid_platform_app_2.json",
errors::kBackgroundRequiredForPlatformApps),
Testcase("init_invalid_platform_app_3.json",
errors::kPlatformAppNeedsManifestVersion2),
- Testcase("incognito_invalid_platform_app.json",
- errors::kInvalidIncognitoModeForPlatformApp),
};
RunTestcases(error_testcases, arraysize(error_testcases), EXPECT_TYPE_ERROR);
@@ -58,7 +58,10 @@ TEST_F(PlatformAppsManifestTest, PlatformApps) {
Testcase(
"init_invalid_platform_app_5.json",
"'background' is only allowed for extensions, hosted apps and legacy "
- "packaged apps, and this is a packaged app.")
+ "packaged apps, and this is a packaged app."),
+ Testcase("incognito_invalid_platform_app.json",
+ "'incognito' is only allowed for extensions and legacy packaged apps, "
+ "and this is a packaged app."),
};
RunTestcases(
warning_testcases, arraysize(warning_testcases), EXPECT_TYPE_WARNING);
@@ -84,7 +87,7 @@ TEST_F(PlatformAppsManifestTest, PlatformAppContentSecurityPolicy) {
std::string test_id = "ahplfneplbnjcflhdgkkjeiglkkfeelb";
CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kWhitelistedExtensionID, test_id);
- scoped_refptr<extensions::Extension> extension =
+ scoped_refptr<Extension> extension =
LoadAndExpectSuccess("init_platform_app_csp.json");
EXPECT_EQ(0U, extension->install_warnings().size())
<< "Unexpected warning " << extension->install_warnings()[0].message;
diff --git a/chrome/common/extensions/permissions/permission_set_unittest.cc b/chrome/common/extensions/permissions/permission_set_unittest.cc
index c569f49..ca5ade3 100644
--- a/chrome/common/extensions/permissions/permission_set_unittest.cc
+++ b/chrome/common/extensions/permissions/permission_set_unittest.cc
@@ -13,6 +13,7 @@
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/features/feature.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
#include "chrome/common/extensions/permissions/permission_set.h"
@@ -21,8 +22,6 @@
#include "extensions/common/error_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
-using extensions::Extension;
-
namespace extensions {
namespace {
@@ -85,6 +84,7 @@ class PermissionsTest : public testing::Test {
(new BackgroundManifestHandler)->Register();
(new ContentScriptsHandler)->Register();
(new PluginsHandler)->Register();
+ (new IncognitoHandler)->Register();
}
virtual void TearDown() OVERRIDE {
@@ -920,8 +920,7 @@ TEST_F(PermissionsTest, GetWarningMessages_Serial) {
}
TEST_F(PermissionsTest, GetWarningMessages_Socket_AnyHost) {
- extensions::Feature::ScopedCurrentChannel channel(
- chrome::VersionInfo::CHANNEL_DEV);
+ Feature::ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV);
scoped_refptr<Extension> extension =
LoadManifest("permissions", "socket_any_host.json");
@@ -934,8 +933,7 @@ TEST_F(PermissionsTest, GetWarningMessages_Socket_AnyHost) {
}
TEST_F(PermissionsTest, GetWarningMessages_Socket_OneDomainTwoHostnames) {
- extensions::Feature::ScopedCurrentChannel channel(
- chrome::VersionInfo::CHANNEL_DEV);
+ Feature::ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV);
scoped_refptr<Extension> extension =
LoadManifest("permissions", "socket_one_domain_two_hostnames.json");
@@ -960,8 +958,7 @@ TEST_F(PermissionsTest, GetWarningMessages_Socket_OneDomainTwoHostnames) {
}
TEST_F(PermissionsTest, GetWarningMessages_Socket_TwoDomainsOneHostname) {
- extensions::Feature::ScopedCurrentChannel channel(
- chrome::VersionInfo::CHANNEL_DEV);
+ Feature::ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV);
scoped_refptr<Extension> extension =
LoadManifest("permissions", "socket_two_domains_one_hostname.json");
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index 0870c05..6242d58 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -26,6 +26,7 @@
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/extension_process_policy.h"
#include "chrome/common/extensions/extension_set.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "chrome/common/extensions/web_accessible_resources_handler.h"
@@ -144,6 +145,7 @@ void RegisterExtensionManifestHandlers() {
(new extensions::PageActionHandler)->Register();
(new extensions::CSPHandler(false))->Register(); // not platform app.
(new extensions::CSPHandler(true))->Register(); // platform app.
+ (new extensions::IncognitoHandler)->Register();
}
static void AppendParams(const std::vector<string16>& additional_names,
diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc
index 0572ab9..d260631 100644
--- a/chrome/utility/chrome_content_utility_client.cc
+++ b/chrome/utility/chrome_content_utility_client.cc
@@ -26,6 +26,7 @@
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_l10n_util.h"
+#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/manifest.h"
#include "chrome/common/extensions/unpacker.h"
#include "chrome/common/extensions/update_manifest.h"
@@ -62,6 +63,7 @@ void RegisterExtensionManifestHandlers() {
(new extensions::PageActionHandler)->Register();
(new extensions::ThemeHandler)->Register();
(new extensions::PluginsHandler)->Register();
+ (new extensions::IncognitoHandler)->Register();
}
} // namespace