summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_dom_ui.cc
diff options
context:
space:
mode:
authorarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-12 19:37:52 +0000
committerarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-12 19:37:52 +0000
commit591948964e3088901b3d66fee2837446700d9083 (patch)
tree062993137f4a82b2a544bc0a3d8666b8b0c0b1ff /chrome/browser/extensions/extension_dom_ui.cc
parentf34b7c5bab399a1cb348e29306b0961fb572f48e (diff)
downloadchromium_src-591948964e3088901b3d66fee2837446700d9083.zip
chromium_src-591948964e3088901b3d66fee2837446700d9083.tar.gz
chromium_src-591948964e3088901b3d66fee2837446700d9083.tar.bz2
Show favicons for extensions.
This uses the 16x16 icon as defined in the manifest for extension pages. BUG=36514 TEST=Open the new bookmark manager. It should now show its favicon. Review URL: http://codereview.chromium.org/650185 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41462 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_dom_ui.cc')
-rw-r--r--chrome/browser/extensions/extension_dom_ui.cc44
1 files changed, 42 insertions, 2 deletions
diff --git a/chrome/browser/extensions/extension_dom_ui.cc b/chrome/browser/extensions/extension_dom_ui.cc
index 926b5d7..424dd80e 100644
--- a/chrome/browser/extensions/extension_dom_ui.cc
+++ b/chrome/browser/extensions/extension_dom_ui.cc
@@ -4,9 +4,13 @@
#include "chrome/browser/extensions/extension_dom_ui.h"
+#include "base/file_path.h"
+#include "base/file_util.h"
+#include "net/base/file_stream.h"
#include "base/string_util.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/extensions/extension_bookmark_manager_api.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/pref_service.h"
@@ -15,16 +19,35 @@
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/bindings_policy.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/extension.h"
#include "chrome/common/url_constants.h"
namespace {
const wchar_t kExtensionURLOverrides[] = L"extensions.chrome_url_overrides";
+
+// Returns a piece of memory with the contents of the file |path|.
+RefCountedMemory* ReadFileData(const FilePath& path) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
+
+ if (path.empty())
+ return NULL;
+
+ RefCountedBytes* result = new RefCountedBytes;
+ std::string content;
+ if (!file_util::ReadFileToString(path, &content))
+ return NULL;
+
+ result->data.resize(content.size());
+ std::copy(content.begin(), content.end(),
+ result->data.begin());
+
+ return result;
}
+} // namespace
+
ExtensionDOMUI::ExtensionDOMUI(TabContents* tab_contents)
: DOMUI(tab_contents) {
- // TODO(aa): It would be cool to show the extension's icon in here.
- hide_favicon_ = true;
should_hide_url_ = true;
bindings_ = BindingsPolicy::EXTENSION;
@@ -290,3 +313,20 @@ void ExtensionDOMUI::UnregisterChromeURLOverrides(
}
}
}
+
+// static
+RefCountedMemory* ExtensionDOMUI::GetFaviconResourceBytes(Profile* profile,
+ GURL page_url) {
+ // Even when the extensions service is enabled by default, it's still
+ // disabled in incognito mode.
+ ExtensionsService* service = profile->GetExtensionsService();
+ if (!service)
+ return NULL;
+
+ Extension* extension = service->GetExtensionByURL(page_url);
+ if (!extension)
+ return NULL;
+
+ return ReadFileData(
+ extension->GetIconPath(Extension::EXTENSION_ICON_BITTY).GetFilePath());
+}