Adding component extension with background page in Chromium does not work.

743 views
Skip to first unread message

Viatcheslav Gachkaylo

unread,
Jul 25, 2011, 10:21:12 AM7/25/11
to Chromium-dev
Hello.

I want to add a component extension to Chromium release 12.0.742.100
I've added "key" attribute to extension's manifest properly.
I've added a folder with an extension to chrome/browser/resources.
Added resource for manifest in chrome/browser/browser_resources.grd
with path: resources\uncensor\manifest.json
Added all extension files to chrome/browser/resources/
component_extension_resources.grd
with path: uncensor/filename.ext
And added this code to chrome/browser/profiles/profile_impl.cc:

component_extensions.push_back(std::make_pair(
FILE_PATH_LITERAL("uncensor"),
IDR_UNCENSOR_MANIFEST));

Also I've changed the ShouldShowExtension return result to true for
component extensions, so that I see them when I open chrome://extensions

And when I click on background.html in chrome://extensions (developer
mode) to see the page with my extension - I get Resource not found in
javascript console and I see a blank page. Can you suggest where can I
look at to fix this issue and make background page load?

I've tested the extension without adding it to browser resources and
it works ok.

Antony Sargent

unread,
Jul 25, 2011, 3:17:41 PM7/25/11
to vgach...@gmail.com, Chromium-dev
I'd try putting a breakpoint in ExtensionsDOMHandler::HandleInspectMessage and step through the debugger from there (maybe try with a normal extension first, then your component one to see where things differ). 



--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
   http://groups.google.com/a/chromium.org/group/chromium-dev

Viatcheslav Gachkaylo

unread,
Jul 26, 2011, 9:58:05 AM7/26/11
to Antony Sargent, chromi...@chromium.org
After debugging for a while, I've found that the actual problem is with extension controlled preference, which I added before.
In chrome/browser/extensions/extension_preference_api.cc I've added my property to the list

PrefMappingEntry kPrefMapping[] = {
{ "blockThirdPartyCookies",
prefs::kBlockThirdPartyCookies,
Extension::kContentSettingsPermission
},
{ "enableReferrers",
prefs::kEnableReferrers,
Extension::kContentSettingsPermission
},
{ "enableHyperlinkAuditing",
prefs::kEnableHyperlinkAuditing,
Extension::kContentSettingsPermission
},
{ "proxy",
prefs::kProxy,
Extension::kProxyPermission
},
+ { "uncensorPrefs",
+ prefs::kUncensorPrefs,
+ Extension::kContentSettingsPermission
+ },
};

Also I've changed the json file with api description, adding uncensorPrefs to chrome.experimental.contentSettings.misc.uncensorPrefs
and registered the preference, initializing it with empty string.
Also my component extension has permissions "experimental" and "contentSettings"

But I probably missed something required to access property from extension.
What else might I need to enable access to this property from a component extension?

Thank you,
Viatcheslav Gachkaylo
Crystalnix

Viatcheslav Gachkaylo

unread,
Jul 26, 2011, 10:10:47 AM7/26/11
to Antony Sargent, chromi...@chromium.org
The browser fails on startup in chrome/browser/extensions/extension_pref_value_map.cc:

bool ExtensionPrefValueMap::CanExtensionControlPref(
const std::string& extension_id,
const std::string& pref_key,
bool incognito) const {
ExtensionEntryMap::const_iterator ext = entries_.find(extension_id);
if (ext == entries_.end()) {
NOTREACHED(); <-- fails here
return false;

Mattias Nissler

unread,
Jul 26, 2011, 11:01:48 AM7/26/11
to vgach...@gmail.com, Dominic Battre, Antony Sargent, chromi...@chromium.org
Dominic, I figured you'd now about this particular NOTREACHED() :)

Viatcheslav Gachkaylo

unread,
Jul 27, 2011, 9:52:21 AM7/27/11
to Mattias Nissler, chromi...@chromium.org
One strange thing happen. If I don't use "key" attribute in extension's manifest.json and load it from a local folder -
everything works as expected. Does it mean component extensions are not allowed to access experimental
or contentSettings API?

Dominic Battre

unread,
Jul 27, 2011, 10:56:05 AM7/27/11
to vgach...@gmail.com, Mattias Nissler, chromi...@chromium.org
You need to register the preference first for this to work. Registering the extension defines the type of values that can be stored as well as a default value.

Please check chrome/browser/prefs/browser_prefs.cc and add your preference registration to RegisterUserPrefs.

Dominic

Viatcheslav Gachkaylo

unread,
Jul 28, 2011, 8:34:36 AM7/28/11
to Dominic Battre, chromi...@chromium.org
I had a line:

prefs->RegisterStringPref(prefs::kUncensorPrefs, std::string());

in chrome/browser/ui/browser.cc
If I hadn't this property registered - the extension wouldn't work when running from a local folder. The problem persists when adding a "key" attribute for public key and running as a component extension.

Thank you,
Viatcheslav Gachkaylo
Reply all
Reply to author
Forward
0 new messages