summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-16 14:56:24 +0000
committerjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-16 14:56:24 +0000
commit2a192fb3f93e12bb197f9b62de14bfa84c1046a1 (patch)
tree2d36de8e013f4d07f63ce4c766cb04ecaabf0ac9
parent5156aa4d7c22d272bb700ce781dae6cf4087c671 (diff)
downloadchromium_src-2a192fb3f93e12bb197f9b62de14bfa84c1046a1.zip
chromium_src-2a192fb3f93e12bb197f9b62de14bfa84c1046a1.tar.gz
chromium_src-2a192fb3f93e12bb197f9b62de14bfa84c1046a1.tar.bz2
Make chrome://extension-icon resources available in incognito mode.
BUG=74905 TEST=ExtensionIconSourceTest Review URL: http://codereview.chromium.org/6623057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78364 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extension_icon_source_apitest.cc37
-rw-r--r--chrome/browser/profiles/profile.cc5
-rw-r--r--chrome/browser/profiles/profile_impl.cc5
-rw-r--r--chrome/test/data/extensions/api_test/icons/extension_no_permission/manifest.json1
-rw-r--r--chrome/test/data/extensions/api_test/icons/extension_with_permission/manifest.json1
5 files changed, 46 insertions, 3 deletions
diff --git a/chrome/browser/extensions/extension_icon_source_apitest.cc b/chrome/browser/extensions/extension_icon_source_apitest.cc
index ee2690c..a7c2b70 100644
--- a/chrome/browser/extensions/extension_icon_source_apitest.cc
+++ b/chrome/browser/extensions/extension_icon_source_apitest.cc
@@ -3,7 +3,10 @@
// found in the LICENSE file.
#include "base/logging.h"
+#include "chrome/browser/browser_list.h"
#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/ui_test_utils.h"
#include "content/browser/tab_contents/tab_contents.h"
@@ -41,3 +44,37 @@ IN_PROC_BROWSER_TEST_F(ExtensionIconSourceTest, IconsLoaded) {
&result));
EXPECT_EQ(result, "Not Loaded");
}
+
+IN_PROC_BROWSER_TEST_F(ExtensionIconSourceTest, IconsLoadedIncognito) {
+ FilePath basedir = test_data_dir_.AppendASCII("icons");
+ ASSERT_TRUE(LoadExtensionIncognito(
+ basedir.AppendASCII("extension_with_permission")));
+ ASSERT_TRUE(LoadExtensionIncognito(
+ basedir.AppendASCII("extension_no_permission")));
+ std::string result;
+
+ // Test that the icons are loaded and that the chrome://extension-icon
+ // parameters work correctly.
+ ui_test_utils::OpenURLOffTheRecord(
+ browser()->profile(),
+ GURL("chrome-extension://gbmgkahjioeacddebbnengilkgbkhodg/index.html"));
+ Browser* otr_browser = BrowserList::FindBrowserWithType(
+ browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL,
+ false);
+ ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
+ otr_browser->GetSelectedTabContents()->render_view_host(), L"",
+ L"window.domAutomationController.send(document.title)",
+ &result));
+ EXPECT_EQ(result, "Loaded");
+
+ // Verify that the an extension can't load chrome://extension-icon icons
+ // without the management permission.
+ ui_test_utils::OpenURLOffTheRecord(
+ browser()->profile(),
+ GURL("chrome-extension://apocjbpjpkghdepdngjlknfpmabcmlao/index.html"));
+ ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
+ otr_browser->GetSelectedTabContents()->render_view_host(), L"",
+ L"window.domAutomationController.send(document.title)",
+ &result));
+ EXPECT_EQ(result, "Not Loaded");
+}
diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc
index 6a0955d..2902aad 100644
--- a/chrome/browser/profiles/profile.cc
+++ b/chrome/browser/profiles/profile.cc
@@ -32,6 +32,7 @@
#include "chrome/browser/themes/browser_theme_provider.h"
#include "chrome/browser/ui/find_bar/find_bar_state.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
+#include "chrome/browser/ui/webui/extension_icon_source.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -176,6 +177,10 @@ class OffTheRecordProfileImpl : public Profile,
#if defined(OS_CHROMEOS)
GetRequestContext();
#endif // defined(OS_CHROMEOS)
+
+ // Make the chrome//extension-icon/ resource available.
+ ExtensionIconSource* icon_source = new ExtensionIconSource(real_profile);
+ GetChromeURLDataManager()->AddDataSource(icon_source);
}
virtual ~OffTheRecordProfileImpl() {
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index b1fbf66..1e4bff0 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -396,9 +396,8 @@ void ProfileImpl::InitExtensions() {
extensions_service_->LoadExtension(path);
}
- // Make the chrome://extension-icon/ resource is available.
- ExtensionIconSource* icon_source = new ExtensionIconSource(this);
- GetChromeURLDataManager()->AddDataSource(icon_source);
+ // Make the chrome://extension-icon/ resource available.
+ GetChromeURLDataManager()->AddDataSource(new ExtensionIconSource(this));
}
void ProfileImpl::RegisterComponentExtensions() {
diff --git a/chrome/test/data/extensions/api_test/icons/extension_no_permission/manifest.json b/chrome/test/data/extensions/api_test/icons/extension_no_permission/manifest.json
index 8b56002..2833a1c 100644
--- a/chrome/test/data/extensions/api_test/icons/extension_no_permission/manifest.json
+++ b/chrome/test/data/extensions/api_test/icons/extension_no_permission/manifest.json
@@ -4,6 +4,7 @@
"name": "test",
"version": "0.1",
"permissions": [],
+ "incognito": "split",
"icons": {
"24": "24.png"
}
diff --git a/chrome/test/data/extensions/api_test/icons/extension_with_permission/manifest.json b/chrome/test/data/extensions/api_test/icons/extension_with_permission/manifest.json
index e2bb86e..ea4d279 100644
--- a/chrome/test/data/extensions/api_test/icons/extension_with_permission/manifest.json
+++ b/chrome/test/data/extensions/api_test/icons/extension_with_permission/manifest.json
@@ -4,6 +4,7 @@
"name": "test",
"version": "0.1",
"permissions": [ "management" ],
+ "incognito": "split",
"icons": {
"128": "128.png",
"32": "32.png",