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

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: 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 unified diff | Download patch | Annotate | Revision Log
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 GetExtensionData(url.path().substr(1));
28
29 source_->AddLocalizedString("isRunning",
30 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.
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::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.
54 ExtensionService* extension_service =
55 ExtensionSystem::Get(Profile::FromWebUI(web_ui()))->extension_service();
56 const extensions::Extension* extension =
57 extension_service->extensions()->GetByID(extension_id);
58 if (!extension)
59 return;
60
61 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.
62 source_->AddString("description", UTF8ToUTF16(extension->description()));
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

Powered by Google App Engine
This is Rietveld 408576698