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

Side by Side Diff: chrome/browser/ui/webui/options/core_options_handler.cc

Issue 6875001: Hide Flash storage settings link. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 8 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) 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/options/core_options_handler.h" 5 #include "chrome/browser/ui/webui/options/core_options_handler.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/google/google_util.h" 14 #include "chrome/browser/google/google_util.h"
14 #include "chrome/browser/metrics/user_metrics.h" 15 #include "chrome/browser/metrics/user_metrics.h"
15 #include "chrome/browser/prefs/pref_service.h" 16 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/pref_names.h"
17 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
18 #include "content/common/notification_details.h" 20 #include "content/common/notification_details.h"
19 #include "content/common/notification_type.h" 21 #include "content/common/notification_type.h"
20 #include "googleurl/src/gurl.h" 22 #include "googleurl/src/gurl.h"
21 #include "grit/chromium_strings.h" 23 #include "grit/chromium_strings.h"
22 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
23 #include "grit/locale_settings.h" 25 #include "grit/locale_settings.h"
24 #include "grit/theme_resources.h" 26 #include "grit/theme_resources.h"
25 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
26 28
27 CoreOptionsHandler::CoreOptionsHandler() 29 CoreOptionsHandler::CoreOptionsHandler()
28 : handlers_host_(NULL) { 30 : handlers_host_(NULL) {
29 } 31 }
30 32
31 CoreOptionsHandler::~CoreOptionsHandler() {} 33 CoreOptionsHandler::~CoreOptionsHandler() {}
32 34
35 void CoreOptionsHandler::Initialize() {
36 clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled,
37 g_browser_process->local_state(),
38 this);
39 UpdateClearPluginLSOData();
40 }
41
33 void CoreOptionsHandler::GetLocalizedValues( 42 void CoreOptionsHandler::GetLocalizedValues(
34 DictionaryValue* localized_strings) { 43 DictionaryValue* localized_strings) {
35 DCHECK(localized_strings); 44 DCHECK(localized_strings);
36 // Main 45 // Main
37 localized_strings->SetString("title", 46 localized_strings->SetString("title",
38 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); 47 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE));
39 48
40 // Managed prefs 49 // Managed prefs
41 localized_strings->SetString("managedPrefsBannerText", 50 localized_strings->SetString("managedPrefsBannerText",
42 l10n_util::GetStringUTF16(IDS_OPTIONS_MANAGED_PREFS)); 51 l10n_util::GetStringUTF16(IDS_OPTIONS_MANAGED_PREFS));
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 343
335 ClearPref(pref_name, metric); 344 ClearPref(pref_name, metric);
336 } 345 }
337 346
338 void CoreOptionsHandler::HandleUserMetricsAction(const ListValue* args) { 347 void CoreOptionsHandler::HandleUserMetricsAction(const ListValue* args) {
339 std::string metric = UTF16ToUTF8(ExtractStringValue(args)); 348 std::string metric = UTF16ToUTF8(ExtractStringValue(args));
340 if (!metric.empty()) 349 if (!metric.empty())
341 UserMetricsRecordAction(UserMetricsAction(metric.c_str())); 350 UserMetricsRecordAction(UserMetricsAction(metric.c_str()));
342 } 351 }
343 352
353 void CoreOptionsHandler::UpdateClearPluginLSOData() {
354 scoped_ptr<Value> enabled(
355 Value::CreateBooleanValue(clear_plugin_lso_data_enabled_.GetValue()));
356 web_ui_->CallJavascriptFunction(
357 "OptionsPage.setClearPluginLSODataEnabled", *enabled);
358 }
359
344 void CoreOptionsHandler::NotifyPrefChanged(const std::string* pref_name) { 360 void CoreOptionsHandler::NotifyPrefChanged(const std::string* pref_name) {
361 if (*pref_name == prefs::kClearPluginLSODataEnabled) {
362 // This preference is stored in Local State, not in the user preferences.
363 UpdateClearPluginLSOData();
364 return;
365 }
366
345 PrefService* pref_service = web_ui_->GetProfile()->GetPrefs(); 367 PrefService* pref_service = web_ui_->GetProfile()->GetPrefs();
346 const PrefService::Preference* pref = 368 const PrefService::Preference* pref =
347 pref_service->FindPreference(pref_name->c_str()); 369 pref_service->FindPreference(pref_name->c_str());
348 if (pref) { 370 if (pref) {
349 for (PreferenceCallbackMap::const_iterator iter = 371 for (PreferenceCallbackMap::const_iterator iter =
350 pref_callback_map_.find(*pref_name); 372 pref_callback_map_.find(*pref_name);
351 iter != pref_callback_map_.end(); ++iter) { 373 iter != pref_callback_map_.end(); ++iter) {
352 const std::wstring& callback_function = iter->second; 374 const std::wstring& callback_function = iter->second;
353 ListValue result_value; 375 ListValue result_value;
354 result_value.Append(Value::CreateStringValue(pref_name->c_str())); 376 result_value.Append(Value::CreateStringValue(pref_name->c_str()));
355 377
356 DictionaryValue* dict = new DictionaryValue; 378 DictionaryValue* dict = new DictionaryValue;
357 dict->Set("value", pref->GetValue()->DeepCopy()); 379 dict->Set("value", pref->GetValue()->DeepCopy());
358 dict->SetBoolean("managed", pref->IsManaged()); 380 dict->SetBoolean("managed", pref->IsManaged());
359 result_value.Append(dict); 381 result_value.Append(dict);
360 382
361 web_ui_->CallJavascriptFunction(WideToASCII(callback_function), 383 web_ui_->CallJavascriptFunction(WideToASCII(callback_function),
362 result_value); 384 result_value);
363 } 385 }
364 } 386 }
365 } 387 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/core_options_handler.h ('k') | chrome/browser/ui/webui/settings_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698