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

Side by Side 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: rebase eh 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/extensions/extension_info_ui.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/extensions/extension_info_ui.h"
6
7 #include "base/i18n/time_formatting.h"
8 #include "base/stringprintf.h"
9 #include "base/time.h"
10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/extensions/extension_prefs.h"
12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/extension_system.h"
14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
16 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
17 #include "chrome/common/extensions/extension.h"
18 #include "chrome/common/extensions/extension_icon_set.h"
19 #include "chrome/common/url_constants.h"
20 #include "content/public/browser/web_ui.h"
21 #include "grit/browser_resources.h"
22 #include "grit/generated_resources.h"
23
24 ExtensionInfoUI::ExtensionInfoUI(content::WebUI* web_ui, const GURL& url)
25 : content::WebUIController(web_ui),
26 source_(new ChromeWebUIDataSource(chrome::kChromeUIExtensionInfoHost)) {
27 AddExtensionDataToSource(url.path().substr(1));
28
29 source_->AddLocalizedString("isRunning",
30 IDS_EXTENSION_SCRIPT_POPUP_IS_RUNNING);
31 source_->AddLocalizedString("lastUpdated",
32 IDS_EXTENSION_SCRIPT_POPUP_LAST_UPDATED);
33 source_->set_use_json_js_format_v2();
34 source_->set_json_path("strings.js");
35
36 source_->add_resource_path("extension_info.css", IDR_EXTENSION_INFO_CSS);
37 source_->add_resource_path("extension_info.js", IDR_EXTENSION_INFO_JS);
38 source_->set_default_resource(IDR_EXTENSION_INFO_HTML);
39
40 Profile* profile = Profile::FromWebUI(web_ui);
41 ChromeURLDataManager::AddDataSource(profile, source_);
42 }
43
44 ExtensionInfoUI::~ExtensionInfoUI() {
45 }
46
47 // static
48 GURL ExtensionInfoUI::GetURL(const std::string& extension_id) {
49 return GURL(base::StringPrintf(
50 "%s%s", chrome::kChromeUIExtensionInfoURL, extension_id.c_str()));
51 }
52
53 void ExtensionInfoUI::AddExtensionDataToSource(
54 const std::string& extension_id) {
55 ExtensionService* extension_service =
56 ExtensionSystem::Get(Profile::FromWebUI(web_ui()))->extension_service();
57 const extensions::Extension* extension =
58 extension_service->extensions()->GetByID(extension_id);
59 if (!extension)
60 return;
61
62 extension->GetBasicInfo(true, source_->localized_strings());
63
64 // Set the icon URL.
65 GURL icon =
66 ExtensionIconSource::GetIconURL(extension,
67 ExtensionIconSet::EXTENSION_ICON_MEDIUM,
68 ExtensionIconSet::MATCH_BIGGER,
69 false, NULL);
70 source_->AddString("icon", UTF8ToUTF16(icon.spec()));
71 // Set the last update time (the install time).
72 base::Time install_time = extension_service->extension_prefs()->
73 GetInstallTime(extension_id);
74 source_->AddString("installTime", base::TimeFormatShortDate(install_time));
75 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/extensions/extension_info_ui.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698