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

Side by Side Diff: chrome/browser/dom_ui/app_launcher_handler.cc

Issue 3236001: Add the collapsed 'miniview' to the apps and most visisted sections. (Closed)
Patch Set: more unnecessary changes Created 10 years, 3 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/dom_ui/app_launcher_handler.h" 5 #include "chrome/browser/dom_ui/app_launcher_handler.h"
6 6
7 #include "app/animation.h" 7 #include "app/animation.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 20 matching lines...) Expand all
31 std::string string_value; 31 std::string string_value;
32 32
33 if (list->GetString(index, &string_value)) { 33 if (list->GetString(index, &string_value)) {
34 base::StringToInt(string_value, out_int); 34 base::StringToInt(string_value, out_int);
35 return true; 35 return true;
36 } 36 }
37 37
38 return false; 38 return false;
39 } 39 }
40 40
41 std::string GetIconURL(Extension* extension, Extension::Icons icon,
42 const std::string& default_val) {
43 ExtensionResource resource = extension->GetIconPath(icon);
44 if (resource.empty())
45 return default_val;
46
47 #if defined(OS_POSIX)
48 std::string path = resource.relative_path().value();
49 #elif defined(OS_WIN)
50 std::string path = WideToUTF8(resource.relative_path().value());
51 #endif // OS_WIN
52
53 return extension->GetResourceURL(path).spec();
54 }
55
41 } // namespace 56 } // namespace
42 57
43 AppLauncherHandler::AppLauncherHandler(ExtensionsService* extension_service) 58 AppLauncherHandler::AppLauncherHandler(ExtensionsService* extension_service)
44 : extensions_service_(extension_service) { 59 : extensions_service_(extension_service) {
45 } 60 }
46 61
47 AppLauncherHandler::~AppLauncherHandler() {} 62 AppLauncherHandler::~AppLauncherHandler() {}
48 63
49 DOMMessageHandler* AppLauncherHandler::Attach(DOMUI* dom_ui) { 64 DOMMessageHandler* AppLauncherHandler::Attach(DOMUI* dom_ui) {
50 // TODO(arv): Add initialization code to the Apps store etc. 65 // TODO(arv): Add initialization code to the Apps store etc.
(...skipping 27 matching lines...) Expand all
78 // static 93 // static
79 void AppLauncherHandler::CreateAppInfo(Extension* extension, 94 void AppLauncherHandler::CreateAppInfo(Extension* extension,
80 DictionaryValue* value) { 95 DictionaryValue* value) {
81 value->Clear(); 96 value->Clear();
82 value->SetString("id", extension->id()); 97 value->SetString("id", extension->id());
83 value->SetString("name", extension->name()); 98 value->SetString("name", extension->name());
84 value->SetString("description", extension->description()); 99 value->SetString("description", extension->description());
85 value->SetString("launch_url", extension->GetFullLaunchURL().spec()); 100 value->SetString("launch_url", extension->GetFullLaunchURL().spec());
86 value->SetString("options_url", extension->options_url().spec()); 101 value->SetString("options_url", extension->options_url().spec());
87 102
88 FilePath relative_path = 103 // TODO(aa): Need a better default icon for apps.
89 extension->GetIconPath(Extension::EXTENSION_ICON_LARGE).relative_path(); 104 value->SetString("icon_big", GetIconURL(
90 105 extension, Extension::EXTENSION_ICON_LARGE,
91 #if defined(OS_POSIX) 106 "chrome://theme/IDR_EXTENSION_DEFAULT_ICON"));
92 std::string path = relative_path.value(); 107 value->SetString("icon_small", GetIconURL(
93 #elif defined(OS_WIN) 108 extension, Extension::EXTENSION_ICON_BITTY,
94 std::string path = WideToUTF8(relative_path.value()); 109 std::string("chrome://favicon/") + extension->GetFullLaunchURL().spec()));
95 #endif // OS_WIN
96
97 GURL icon_url = extension->GetResourceURL(path);
98 value->SetString("icon", icon_url.spec());
99 } 110 }
100 111
101 void AppLauncherHandler::HandleGetApps(const ListValue* args) { 112 void AppLauncherHandler::HandleGetApps(const ListValue* args) {
102 bool show_debug_link = CommandLine::ForCurrentProcess()->HasSwitch( 113 bool show_debug_link = CommandLine::ForCurrentProcess()->HasSwitch(
103 switches::kAppsDebug); 114 switches::kAppsDebug);
104 115
105 DictionaryValue dictionary; 116 DictionaryValue dictionary;
106 dictionary.SetBoolean("showDebugLink", show_debug_link); 117 dictionary.SetBoolean("showDebugLink", show_debug_link);
107 118
108 ListValue* list = new ListValue(); 119 ListValue* list = new ListValue();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 void AppLauncherHandler::HandleUninstallApp(const ListValue* args) { 215 void AppLauncherHandler::HandleUninstallApp(const ListValue* args) {
205 std::string extension_id = WideToUTF8(ExtractStringValue(args)); 216 std::string extension_id = WideToUTF8(ExtractStringValue(args));
206 217
207 // Make sure that the extension exists. 218 // Make sure that the extension exists.
208 Extension* extension = 219 Extension* extension =
209 extensions_service_->GetExtensionById(extension_id, false); 220 extensions_service_->GetExtensionById(extension_id, false);
210 DCHECK(extension); 221 DCHECK(extension);
211 222
212 extensions_service_->UninstallExtension(extension_id, false); 223 extensions_service_->UninstallExtension(extension_id, false);
213 } 224 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698