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

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

Issue 6040005: More cleanup of DefaultApps code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unnecessary change, add comments Created 9 years, 11 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
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/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 dictionary->SetBoolean("disableAppWindowLaunch", true); 186 dictionary->SetBoolean("disableAppWindowLaunch", true);
187 dictionary->SetBoolean("disableCreateAppShortcut", true); 187 dictionary->SetBoolean("disableCreateAppShortcut", true);
188 #endif 188 #endif
189 189
190 #if defined(OS_CHROMEOS) 190 #if defined(OS_CHROMEOS)
191 // Making shortcut does not make sense on ChromeOS because it does not have 191 // Making shortcut does not make sense on ChromeOS because it does not have
192 // a desktop. 192 // a desktop.
193 dictionary->SetBoolean("disableCreateAppShortcut", true); 193 dictionary->SetBoolean("disableCreateAppShortcut", true);
194 #endif 194 #endif
195 195
196 // We always show the launcher on Chrome OS. On Desktop Chrome, only show it
197 // if we've installed our default apps.
198 #if defined(OS_CHROMEOS)
199 dictionary->SetBoolean("showLauncher", true);
200 #else
201 dictionary->SetBoolean( 196 dictionary->SetBoolean(
202 "showLauncher", 197 "showLauncher",
203 extensions_service_->default_apps()->GetDefaultAppsInstalled()); 198 extensions_service_->default_apps()->ShouldShowAppLauncher(
204 #endif 199 extensions_service_->GetAppIds()));
205 } 200 }
206 201
207 void AppLauncherHandler::HandleGetApps(const ListValue* args) { 202 void AppLauncherHandler::HandleGetApps(const ListValue* args) {
208 DictionaryValue dictionary; 203 DictionaryValue dictionary;
209 FillAppDictionary(&dictionary); 204 FillAppDictionary(&dictionary);
210 205
211 // Tell the client whether to show the promo for this view. We don't do this 206 // Tell the client whether to show the promo for this view. We don't do this
212 // in the case of PREF_CHANGED because: 207 // in the case of PREF_CHANGED because:
213 // 208 //
214 // a) At that point in time, depending on the pref that changed, it can look 209 // a) At that point in time, depending on the pref that changed, it can look
215 // like the set of apps installed has changed, and we will mark the promo 210 // like the set of apps installed has changed, and we will mark the promo
216 // expired. 211 // expired.
217 // b) Conceptually, it doesn't really make sense to count a 212 // b) Conceptually, it doesn't really make sense to count a
218 // prefchange-triggered refresh as a promo 'view'. 213 // prefchange-triggered refresh as a promo 'view'.
219 DefaultApps* default_apps = extensions_service_->default_apps(); 214 DefaultApps* default_apps = extensions_service_->default_apps();
220 if (default_apps->CheckShouldShowPromo(extensions_service_->GetAppIds())) { 215 if (default_apps->ShouldShowPromo(extensions_service_->GetAppIds())) {
221 dictionary.SetBoolean("showPromo", true); 216 dictionary.SetBoolean("showPromo", true);
222 default_apps->DidShowPromo(); 217 default_apps->DidShowPromo();
223 promo_active_ = true; 218 promo_active_ = true;
224 } else { 219 } else {
225 dictionary.SetBoolean("showPromo", false); 220 dictionary.SetBoolean("showPromo", false);
226 promo_active_ = false; 221 promo_active_ = false;
227 } 222 }
228 223
229 dom_ui_->CallJavascriptFunction(L"getAppsCallback", dictionary); 224 dom_ui_->CallJavascriptFunction(L"getAppsCallback", dictionary);
230 225
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 GetExtensionInstallUI()->ConfirmUninstall(this, extension); 323 GetExtensionInstallUI()->ConfirmUninstall(this, extension);
329 } 324 }
330 325
331 void AppLauncherHandler::HandleHideAppsPromo(const ListValue* args) { 326 void AppLauncherHandler::HandleHideAppsPromo(const ListValue* args) {
332 // If the user has intentionally hidden the promotion, we'll uninstall all the 327 // If the user has intentionally hidden the promotion, we'll uninstall all the
333 // default apps (we know the user hasn't installed any apps on their own at 328 // default apps (we know the user hasn't installed any apps on their own at
334 // this point, or the promotion wouldn't have been shown). 329 // this point, or the promotion wouldn't have been shown).
335 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, 330 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram,
336 extension_misc::PROMO_CLOSE, 331 extension_misc::PROMO_CLOSE,
337 extension_misc::PROMO_BUCKET_BOUNDARY); 332 extension_misc::PROMO_BUCKET_BOUNDARY);
333
338 DefaultApps* default_apps = extensions_service_->default_apps(); 334 DefaultApps* default_apps = extensions_service_->default_apps();
339 const ExtensionIdSet* app_ids = default_apps->GetDefaultApps(); 335 const ExtensionIdSet& app_ids = default_apps->default_apps();
340 DCHECK(*app_ids == extensions_service_->GetAppIds()); 336 for (ExtensionIdSet::const_iterator iter = app_ids.begin();
341 337 iter != app_ids.end(); ++iter) {
342 for (ExtensionIdSet::const_iterator iter = app_ids->begin();
343 iter != app_ids->end(); ++iter) {
344 if (extensions_service_->GetExtensionById(*iter, true)) 338 if (extensions_service_->GetExtensionById(*iter, true))
345 extensions_service_->UninstallExtension(*iter, false); 339 extensions_service_->UninstallExtension(*iter, false);
346 } 340 }
347 341
348 extensions_service_->default_apps()->SetPromoHidden(); 342 extensions_service_->default_apps()->SetPromoHidden();
349 } 343 }
350 344
351 void AppLauncherHandler::HandleCreateAppShortcut(const ListValue* args) { 345 void AppLauncherHandler::HandleCreateAppShortcut(const ListValue* args) {
352 std::string extension_id; 346 std::string extension_id;
353 if (!args->GetString(0, &extension_id)) { 347 if (!args->GetString(0, &extension_id)) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 // We make this check for the case of minimized windows, unit tests, etc. 411 // We make this check for the case of minimized windows, unit tests, etc.
418 if (platform_util::IsVisible(dom_ui_->tab_contents()->GetNativeView()) && 412 if (platform_util::IsVisible(dom_ui_->tab_contents()->GetNativeView()) &&
419 Animation::ShouldRenderRichAnimation()) { 413 Animation::ShouldRenderRichAnimation()) {
420 #if defined(OS_WIN) 414 #if defined(OS_WIN)
421 AppLaunchedAnimation::Show(extension, rect); 415 AppLaunchedAnimation::Show(extension, rect);
422 #else 416 #else
423 NOTIMPLEMENTED(); 417 NOTIMPLEMENTED();
424 #endif 418 #endif
425 } 419 }
426 } 420 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/default_apps.h » ('j') | chrome/browser/extensions/default_apps_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698