Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5010)

Unified Diff: chrome/browser/ui/webui/extensions/extension_info_ui.cc

Issue 10544195: Show an extension info bubble when a script badge is clicked. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleaner Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/extensions/extension_info_ui.cc
diff --git a/chrome/browser/ui/webui/extensions/extension_info_ui.cc b/chrome/browser/ui/webui/extensions/extension_info_ui.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d05b4a24ddf595b75dc8e762fd47fca65d422c3a
--- /dev/null
+++ b/chrome/browser/ui/webui/extensions/extension_info_ui.cc
@@ -0,0 +1,75 @@
+// Copyright (c) 2012 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/browser/ui/webui/extensions/extension_info_ui.h"
+
+#include "base/i18n/time_formatting.h"
+#include "base/stringprintf.h"
+#include "base/time.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/extensions/extension_prefs.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
+#include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/extension_icon_set.h"
+#include "chrome/common/url_constants.h"
+#include "content/public/browser/web_ui.h"
+#include "grit/browser_resources.h"
+#include "grit/generated_resources.h"
+
+ExtensionInfoUI::ExtensionInfoUI(content::WebUI* web_ui, const GURL& url)
+ : content::WebUIController(web_ui),
+ source_(new ChromeWebUIDataSource(chrome::kChromeUIExtensionInfoHost)) {
+ GetExtensionData(url.path().substr(1));
+
+ source_->AddLocalizedString("isRunning",
+ IDS_EXTENSION_SCRIPT_POPUP_IS_RUNNING);
Evan Stade 2012/06/21 18:56:22 one more indent here and below
Yoyo Zhou 2012/06/21 21:38:05 Done.
+ source_->AddLocalizedString("lastUpdated",
+ IDS_EXTENSION_SCRIPT_POPUP_LAST_UPDATED);
+ source_->set_use_json_js_format_v2();
+ source_->set_json_path("strings.js");
+
+ source_->add_resource_path("extension_info.css", IDR_EXTENSION_INFO_CSS);
+ source_->add_resource_path("extension_info.js", IDR_EXTENSION_INFO_JS);
+ source_->set_default_resource(IDR_EXTENSION_INFO_HTML);
+
+ Profile* profile = Profile::FromWebUI(web_ui);
+ ChromeURLDataManager::AddDataSource(profile, source_);
+}
+
+ExtensionInfoUI::~ExtensionInfoUI() {
+}
+
+// static
+GURL ExtensionInfoUI::GetURL(const std::string& extension_id) {
+ return GURL(base::StringPrintf(
+ "%s%s", chrome::kChromeUIExtensionInfoURL, extension_id.c_str()));
+}
+
+void ExtensionInfoUI::GetExtensionData(const std::string& extension_id) {
Evan Stade 2012/06/21 18:56:22 odd function name because you aren't returning any
Yoyo Zhou 2012/06/21 21:38:05 Done.
+ ExtensionService* extension_service =
+ ExtensionSystem::Get(Profile::FromWebUI(web_ui()))->extension_service();
+ const extensions::Extension* extension =
+ extension_service->extensions()->GetByID(extension_id);
+ if (!extension)
+ return;
+
+ source_->AddString("name", UTF8ToUTF16(extension->name()));
Evan Stade 2012/06/21 18:56:22 perhaps use extension->GetBasicInfo
Yoyo Zhou 2012/06/21 21:38:05 I was doing that before, but now I'm not using Val
Evan Stade 2012/06/21 21:46:06 extension->GetBasicInfo(true, source_->localized_s
Yoyo Zhou 2012/06/22 19:20:53 Ok, good call.
+ source_->AddString("description", UTF8ToUTF16(extension->description()));
+
+ // Set the icon URL.
+ GURL icon =
+ ExtensionIconSource::GetIconURL(extension,
+ ExtensionIconSet::EXTENSION_ICON_MEDIUM,
+ ExtensionIconSet::MATCH_BIGGER,
+ false, NULL);
+ source_->AddString("icon", UTF8ToUTF16(icon.spec()));
+ // Set the last update time (the install time).
+ base::Time install_time = extension_service->extension_prefs()->
+ GetInstallTime(extension_id);
+ source_->AddString("installTime", base::TimeFormatShortDate(install_time));
+}

Powered by Google App Engine
This is Rietveld 408576698