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

Side by Side Diff: chrome/browser/ui/webui/ntp/app_launcher_handler.cc

Issue 8438028: ntp: remove ShownSectionHandler and all references to it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more functional test updates Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/webui/ntp/app_launcher_handler.h" 5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/browser/extensions/extension_prefs.h" 23 #include "chrome/browser/extensions/extension_prefs.h"
24 #include "chrome/browser/extensions/extension_service.h" 24 #include "chrome/browser/extensions/extension_service.h"
25 #include "chrome/browser/prefs/pref_service.h" 25 #include "chrome/browser/prefs/pref_service.h"
26 #include "chrome/browser/prefs/scoped_user_pref_update.h" 26 #include "chrome/browser/prefs/scoped_user_pref_update.h"
27 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/ui/browser.h" 28 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/browser_list.h" 29 #include "chrome/browser/ui/browser_list.h"
30 #include "chrome/browser/ui/browser_window.h" 30 #include "chrome/browser/ui/browser_window.h"
31 #include "chrome/browser/ui/webui/extension_icon_source.h" 31 #include "chrome/browser/ui/webui/extension_icon_source.h"
32 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 32 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
33 #include "chrome/browser/ui/webui/ntp/shown_sections_handler.h"
34 #include "chrome/common/chrome_notification_types.h" 33 #include "chrome/common/chrome_notification_types.h"
35 #include "chrome/common/extensions/extension.h" 34 #include "chrome/common/extensions/extension.h"
36 #include "chrome/common/extensions/extension_constants.h" 35 #include "chrome/common/extensions/extension_constants.h"
37 #include "chrome/common/extensions/extension_icon_set.h" 36 #include "chrome/common/extensions/extension_icon_set.h"
38 #include "chrome/common/extensions/extension_resource.h" 37 #include "chrome/common/extensions/extension_resource.h"
39 #include "chrome/common/favicon_url.h" 38 #include "chrome/common/favicon_url.h"
40 #include "chrome/common/pref_names.h" 39 #include "chrome/common/pref_names.h"
41 #include "chrome/common/url_constants.h" 40 #include "chrome/common/url_constants.h"
42 #include "chrome/common/web_apps.h" 41 #include "chrome/common/web_apps.h"
43 #include "content/browser/disposition_utils.h" 42 #include "content/browser/disposition_utils.h"
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 // Tell the client whether to show the promo for this view. We don't do this 502 // Tell the client whether to show the promo for this view. We don't do this
504 // in the case of PREF_CHANGED because: 503 // in the case of PREF_CHANGED because:
505 // 504 //
506 // a) At that point in time, depending on the pref that changed, it can look 505 // a) At that point in time, depending on the pref that changed, it can look
507 // like the set of apps installed has changed, and we will mark the promo 506 // like the set of apps installed has changed, and we will mark the promo
508 // expired. 507 // expired.
509 // b) Conceptually, it doesn't really make sense to count a 508 // b) Conceptually, it doesn't really make sense to count a
510 // prefchange-triggered refresh as a promo 'view'. 509 // prefchange-triggered refresh as a promo 'view'.
511 AppsPromo* apps_promo = extension_service_->apps_promo(); 510 AppsPromo* apps_promo = extension_service_->apps_promo();
512 Profile* profile = Profile::FromWebUI(web_ui_); 511 Profile* profile = Profile::FromWebUI(web_ui_);
513 PrefService* prefs = profile->GetPrefs();
514 bool apps_promo_just_expired = false; 512 bool apps_promo_just_expired = false;
515 if (apps_promo->ShouldShowPromo(extension_service_->GetAppIds(), 513 if (apps_promo->ShouldShowPromo(extension_service_->GetAppIds(),
516 &apps_promo_just_expired)) { 514 &apps_promo_just_expired)) {
517 apps_promo->MaximizeAppsIfNecessary();
518 dictionary.SetBoolean("showPromo", true); 515 dictionary.SetBoolean("showPromo", true);
519 FillPromoDictionary(&dictionary); 516 FillPromoDictionary(&dictionary);
520 promo_active_ = true; 517 promo_active_ = true;
521 } else { 518 } else {
522 dictionary.SetBoolean("showPromo", false); 519 dictionary.SetBoolean("showPromo", false);
523 promo_active_ = false; 520 promo_active_ = false;
524 } 521 }
525 522
526 // If the default apps have just expired (user viewed them too many times with 523 // If the default apps have just expired (user viewed them too many times with
527 // no interaction), then we uninstall them and focus the recent sites section. 524 // no interaction), then we uninstall them and focus the recent sites section.
528 if (apps_promo_just_expired) { 525 if (apps_promo_just_expired) {
529 ignore_changes_ = true; 526 ignore_changes_ = true;
530 UninstallDefaultApps(); 527 UninstallDefaultApps();
531 ignore_changes_ = false; 528 ignore_changes_ = false;
532 ShownSectionsHandler::SetShownSection(prefs, THUMB);
533 } 529 }
534 530
535 SetAppToBeHighlighted(); 531 SetAppToBeHighlighted();
536 FillAppDictionary(&dictionary); 532 FillAppDictionary(&dictionary);
537 web_ui_->CallJavascriptFunction("getAppsCallback", dictionary); 533 web_ui_->CallJavascriptFunction("getAppsCallback", dictionary);
538 534
539 // First time we get here we set up the observer so that we can tell update 535 // First time we get here we set up the observer so that we can tell update
540 // the apps as they change. 536 // the apps as they change.
541 if (!has_loaded_apps_) { 537 if (!has_loaded_apps_) {
542 pref_change_registrar_.Init( 538 pref_change_registrar_.Init(
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 1049
1054 void AppLauncherHandler::UninstallDefaultApps() { 1050 void AppLauncherHandler::UninstallDefaultApps() {
1055 AppsPromo* apps_promo = extension_service_->apps_promo(); 1051 AppsPromo* apps_promo = extension_service_->apps_promo();
1056 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); 1052 const ExtensionIdSet& app_ids = apps_promo->old_default_apps();
1057 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); 1053 for (ExtensionIdSet::const_iterator iter = app_ids.begin();
1058 iter != app_ids.end(); ++iter) { 1054 iter != app_ids.end(); ++iter) {
1059 if (extension_service_->GetExtensionById(*iter, true)) 1055 if (extension_service_->GetExtensionById(*iter, true))
1060 extension_service_->UninstallExtension(*iter, false, NULL); 1056 extension_service_->UninstallExtension(*iter, false, NULL);
1061 } 1057 }
1062 } 1058 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/ui/webui/ntp/new_tab_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698