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

Unified Diff: chrome/browser/dom_ui/shown_sections_handler.cc

Issue 4506002: Make sure the app section opens whenever a new apps is (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment cleanup Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/dom_ui/shown_sections_handler.h ('k') | chrome/browser/resources/ntp/apps.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/shown_sections_handler.cc
diff --git a/chrome/browser/dom_ui/shown_sections_handler.cc b/chrome/browser/dom_ui/shown_sections_handler.cc
index 381ea326103edbc6c54653340aa8dbeba2ad88f3..189c1c3d39b0d4a6c6a995e0d8772a238f0fbf92 100644
--- a/chrome/browser/dom_ui/shown_sections_handler.cc
+++ b/chrome/browser/dom_ui/shown_sections_handler.cc
@@ -14,6 +14,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/notification_details.h"
+#include "chrome/common/notification_source.h"
#include "chrome/common/notification_type.h"
#include "chrome/common/pref_names.h"
@@ -49,11 +50,14 @@ int ShownSectionsHandler::GetShownSections(PrefService* prefs) {
ShownSectionsHandler::ShownSectionsHandler(PrefService* pref_service)
: pref_service_(pref_service) {
- registrar_.Init(pref_service);
- registrar_.Add(prefs::kNTPShownSections, this);
+ pref_registrar_.Init(pref_service);
+ pref_registrar_.Add(prefs::kNTPShownSections, this);
}
void ShownSectionsHandler::RegisterMessages() {
+ notification_registrar_.Add(this, NotificationType::EXTENSION_INSTALLED,
+ Source<Profile>(dom_ui_->GetProfile()));
+
dom_ui_->RegisterMessageCallback("getShownSections",
NewCallback(this, &ShownSectionsHandler::HandleGetShownSections));
dom_ui_->RegisterMessageCallback("setShownSections",
@@ -63,13 +67,30 @@ void ShownSectionsHandler::RegisterMessages() {
void ShownSectionsHandler::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- DCHECK(NotificationType::PREF_CHANGED == type);
- std::string* pref_name = Details<std::string>(details).ptr();
- DCHECK(*pref_name == prefs::kNTPShownSections);
-
- int sections = pref_service_->GetInteger(prefs::kNTPShownSections);
- FundamentalValue sections_value(sections);
- dom_ui_->CallJavascriptFunction(L"setShownSections", sections_value);
+ if (type == NotificationType::PREF_CHANGED) {
+ std::string* pref_name = Details<std::string>(details).ptr();
+ DCHECK(*pref_name == prefs::kNTPShownSections);
+ int sections = pref_service_->GetInteger(prefs::kNTPShownSections);
+ FundamentalValue sections_value(sections);
+ dom_ui_->CallJavascriptFunction(L"setShownSections", sections_value);
+ } else if (type == NotificationType::EXTENSION_INSTALLED) {
+ if (Details<const Extension>(details).ptr()->is_app()) {
+ int mode = pref_service_->GetInteger(prefs::kNTPShownSections);
+
+ // De-minimize the apps section.
+ mode &= ~MINIMIZED_APPS;
+
+ // Hide any open sections.
Erik does not do reviews 2010/11/04 23:40:39 Shouldn't this be "minimize" rather than "hide"?
Aaron Boodman 2010/11/05 00:08:34 The nomenclature in NTP is all messed up. We unfor
+ mode &= ~ALL_SECTIONS_MASK;
+
+ // Show the apps section.
+ mode |= APPS;
+
+ pref_service_->SetInteger(prefs::kNTPShownSections, mode);
+ }
+ } else {
+ NOTREACHED();
+ }
}
void ShownSectionsHandler::HandleGetShownSections(const ListValue* args) {
« no previous file with comments | « chrome/browser/dom_ui/shown_sections_handler.h ('k') | chrome/browser/resources/ntp/apps.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698