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

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

Issue 2855009: Only allow installation of extensions/apps with gallery update url via download from gallery (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: name change Created 10 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
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 "app/l10n_util.h"
8 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
9 #include "base/base64.h" 10 #include "base/base64.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "chrome/browser/app_launched_animation.h" 13 #include "chrome/browser/app_launched_animation.h"
13 #include "chrome/browser/browser.h" 14 #include "chrome/browser/browser.h"
14 #include "chrome/browser/browser_list.h" 15 #include "chrome/browser/browser_list.h"
15 #include "chrome/browser/extensions/extensions_service.h" 16 #include "chrome/browser/extensions/extensions_service.h"
16 #include "chrome/browser/platform_util.h" 17 #include "chrome/browser/platform_util.h"
17 #include "chrome/browser/tab_contents/tab_contents.h" 18 #include "chrome/browser/tab_contents/tab_contents.h"
18 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/extensions/extension.h"
19 #include "chrome/common/extensions/extension_resource.h" 21 #include "chrome/common/extensions/extension_resource.h"
20 #include "chrome/common/notification_service.h" 22 #include "chrome/common/notification_service.h"
21 #include "chrome/common/notification_type.h" 23 #include "chrome/common/notification_type.h"
22 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
23 #include "gfx/rect.h" 25 #include "gfx/rect.h"
24 #include "grit/browser_resources.h" 26 #include "grit/browser_resources.h"
27 #include "grit/generated_resources.h"
25 28
26 namespace { 29 namespace {
27 30
28 // This extracts an int from a ListValue at the given |index|. 31 // This extracts an int from a ListValue at the given |index|.
29 bool ExtractInt(const ListValue* list, size_t index, int* out_int) { 32 bool ExtractInt(const ListValue* list, size_t index, int* out_int) {
30 std::string string_value; 33 std::string string_value;
31 34
32 if (list->GetString(index, &string_value)) { 35 if (list->GetString(index, &string_value)) {
33 *out_int = StringToInt(string_value); 36 *out_int = StringToInt(string_value);
34 return true; 37 return true;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 std::string path = relative_path.value(); 91 std::string path = relative_path.value();
89 #elif defined(OS_WIN) 92 #elif defined(OS_WIN)
90 std::string path = WideToUTF8(relative_path.value()); 93 std::string path = WideToUTF8(relative_path.value());
91 #endif // OS_WIN 94 #endif // OS_WIN
92 95
93 GURL icon_url = extension->GetResourceURL(path); 96 GURL icon_url = extension->GetResourceURL(path);
94 value->SetString(L"icon", icon_url.spec()); 97 value->SetString(L"icon", icon_url.spec());
95 } 98 }
96 99
97 void AppLauncherHandler::HandleGetApps(const Value* value) { 100 void AppLauncherHandler::HandleGetApps(const Value* value) {
98 std::string gallery_title; 101 std::string gallery_title =
99 std::string gallery_url; 102 l10n_util::GetStringUTF8(IDS_EXTENSION_WEB_STORE_TITLE);
100 103
101 // TODO(aa): Decide the final values for these and remove the switches.
102 gallery_title = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
103 switches::kAppsGalleryTitle);
104 gallery_url = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
105 switches::kAppsGalleryURL);
106 bool show_debug_link = CommandLine::ForCurrentProcess()->HasSwitch( 104 bool show_debug_link = CommandLine::ForCurrentProcess()->HasSwitch(
107 switches::kAppsDebug); 105 switches::kAppsDebug);
108 106
109 DictionaryValue dictionary; 107 DictionaryValue dictionary;
110 dictionary.SetString(L"galleryTitle", gallery_title); 108 dictionary.SetString(L"galleryTitle", gallery_title);
111 dictionary.SetString(L"galleryURL", gallery_url); 109 dictionary.SetString(L"galleryURL", Extension::ChromeStoreURL());
112 dictionary.SetBoolean(L"showDebugLink", show_debug_link); 110 dictionary.SetBoolean(L"showDebugLink", show_debug_link);
113 111
114 ListValue* list = new ListValue(); 112 ListValue* list = new ListValue();
115 const ExtensionList* extensions = extensions_service_->extensions(); 113 const ExtensionList* extensions = extensions_service_->extensions();
116 for (ExtensionList::const_iterator it = extensions->begin(); 114 for (ExtensionList::const_iterator it = extensions->begin();
117 it != extensions->end(); ++it) { 115 it != extensions->end(); ++it) {
118 if ((*it)->IsApp()) { 116 if ((*it)->IsApp()) {
119 DictionaryValue* app_info = new DictionaryValue(); 117 DictionaryValue* app_info = new DictionaryValue();
120 CreateAppInfo(*it, app_info); 118 CreateAppInfo(*it, app_info);
121 list->Append(app_info); 119 list->Append(app_info);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // We make this check for the case of minimized windows, unit tests, etc. 208 // We make this check for the case of minimized windows, unit tests, etc.
211 if (platform_util::IsVisible(dom_ui_->tab_contents()->GetNativeView()) && 209 if (platform_util::IsVisible(dom_ui_->tab_contents()->GetNativeView()) &&
212 Animation::ShouldRenderRichAnimation()) { 210 Animation::ShouldRenderRichAnimation()) {
213 #if defined(OS_WIN) 211 #if defined(OS_WIN)
214 AppLaunchedAnimation::Show(extension, rect); 212 AppLaunchedAnimation::Show(extension, rect);
215 #else 213 #else
216 NOTIMPLEMENTED(); 214 NOTIMPLEMENTED();
217 #endif 215 #endif
218 } 216 }
219 } 217 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698