| OLD | NEW |
| 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/options/browser_options_handler.h" | 5 #include "chrome/browser/dom_ui/options/browser_options_handler.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "base/singleton.h" | 10 #include "base/singleton.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/browser_thread.h" | 14 #include "chrome/browser/browser_thread.h" |
| 15 #include "chrome/browser/custom_home_pages_table_model.h" | 15 #include "chrome/browser/custom_home_pages_table_model.h" |
| 16 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" | 16 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" |
| 17 #include "chrome/browser/dom_ui/options/dom_options_util.h" |
| 17 #include "chrome/browser/dom_ui/options/options_managed_banner_handler.h" | 18 #include "chrome/browser/dom_ui/options/options_managed_banner_handler.h" |
| 18 #include "chrome/browser/instant/instant_confirm_dialog.h" | 19 #include "chrome/browser/instant/instant_confirm_dialog.h" |
| 19 #include "chrome/browser/metrics/user_metrics.h" | 20 #include "chrome/browser/metrics/user_metrics.h" |
| 20 #include "chrome/browser/net/url_fixer_upper.h" | 21 #include "chrome/browser/net/url_fixer_upper.h" |
| 21 #include "chrome/browser/prefs/session_startup_pref.h" | 22 #include "chrome/browser/prefs/session_startup_pref.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/search_engines/template_url.h" | 24 #include "chrome/browser/search_engines/template_url.h" |
| 24 #include "chrome/browser/search_engines/template_url_model.h" | 25 #include "chrome/browser/search_engines/template_url_model.h" |
| 25 #include "chrome/browser/ui/options/options_window.h" | 26 #include "chrome/browser/ui/options/options_window.h" |
| 26 #include "chrome/installer/util/browser_distribution.h" | 27 #include "chrome/installer/util/browser_distribution.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 38 if (default_browser_worker_.get()) | 39 if (default_browser_worker_.get()) |
| 39 default_browser_worker_->ObserverDestroyed(); | 40 default_browser_worker_->ObserverDestroyed(); |
| 40 if (template_url_model_) | 41 if (template_url_model_) |
| 41 template_url_model_->RemoveObserver(this); | 42 template_url_model_->RemoveObserver(this); |
| 42 } | 43 } |
| 43 | 44 |
| 44 void BrowserOptionsHandler::GetLocalizedValues( | 45 void BrowserOptionsHandler::GetLocalizedValues( |
| 45 DictionaryValue* localized_strings) { | 46 DictionaryValue* localized_strings) { |
| 46 DCHECK(localized_strings); | 47 DCHECK(localized_strings); |
| 47 localized_strings->SetString("startupGroupName", | 48 localized_strings->SetString("startupGroupName", |
| 48 l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_GROUP_NAME)); | 49 dom_options_util::StripColon( |
| 50 l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_GROUP_NAME))); |
| 49 localized_strings->SetString("startupShowDefaultAndNewTab", | 51 localized_strings->SetString("startupShowDefaultAndNewTab", |
| 50 l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_SHOW_DEFAULT_AND_NEWTAB)); | 52 l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_SHOW_DEFAULT_AND_NEWTAB)); |
| 51 localized_strings->SetString("startupShowLastSession", | 53 localized_strings->SetString("startupShowLastSession", |
| 52 l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_SHOW_LAST_SESSION)); | 54 l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_SHOW_LAST_SESSION)); |
| 53 localized_strings->SetString("startupShowPages", | 55 localized_strings->SetString("startupShowPages", |
| 54 l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_SHOW_PAGES)); | 56 l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_SHOW_PAGES)); |
| 55 localized_strings->SetString("startupShowManyPages", | 57 localized_strings->SetString("startupShowManyPages", |
| 56 l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_SHOW_MANY_PAGES)); | 58 l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_SHOW_MANY_PAGES)); |
| 57 localized_strings->SetString("startupUseCurrent", | 59 localized_strings->SetString("startupUseCurrent", |
| 58 l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_USE_CURRENT)); | 60 l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_USE_CURRENT)); |
| 59 localized_strings->SetString("homepageGroupName", | 61 localized_strings->SetString("homepageGroupName", |
| 60 l10n_util::GetStringUTF16(IDS_OPTIONS_HOMEPAGE_GROUP_NAME)); | 62 dom_options_util::StripColon( |
| 63 l10n_util::GetStringUTF16(IDS_OPTIONS_HOMEPAGE_GROUP_NAME))); |
| 61 localized_strings->SetString("homepageUseNewTab", | 64 localized_strings->SetString("homepageUseNewTab", |
| 62 l10n_util::GetStringUTF16(IDS_OPTIONS_HOMEPAGE_USE_NEWTAB)); | 65 l10n_util::GetStringUTF16(IDS_OPTIONS_HOMEPAGE_USE_NEWTAB)); |
| 63 localized_strings->SetString("homepageUseURL", | 66 localized_strings->SetString("homepageUseURL", |
| 64 l10n_util::GetStringUTF16(IDS_OPTIONS_HOMEPAGE_USE_URL)); | 67 l10n_util::GetStringUTF16(IDS_OPTIONS_HOMEPAGE_USE_URL)); |
| 65 localized_strings->SetString("toolbarGroupName", | 68 localized_strings->SetString("toolbarGroupName", |
| 66 l10n_util::GetStringUTF16(IDS_OPTIONS_TOOLBAR_GROUP_NAME)); | 69 dom_options_util::StripColon( |
| 70 l10n_util::GetStringUTF16(IDS_OPTIONS_TOOLBAR_GROUP_NAME))); |
| 67 localized_strings->SetString("toolbarShowHomeButton", | 71 localized_strings->SetString("toolbarShowHomeButton", |
| 68 l10n_util::GetStringUTF16(IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON)); | 72 l10n_util::GetStringUTF16(IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON)); |
| 69 localized_strings->SetString("defaultSearchGroupName", | 73 localized_strings->SetString("defaultSearchGroupName", |
| 70 l10n_util::GetStringUTF16(IDS_OPTIONS_DEFAULTSEARCH_GROUP_NAME)); | 74 dom_options_util::StripColon( |
| 75 l10n_util::GetStringUTF16(IDS_OPTIONS_DEFAULTSEARCH_GROUP_NAME))); |
| 71 localized_strings->SetString("defaultSearchManageEngines", | 76 localized_strings->SetString("defaultSearchManageEngines", |
| 72 l10n_util::GetStringUTF16(IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES)); | 77 l10n_util::GetStringUTF16(IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES)); |
| 73 localized_strings->SetString("instantName", | 78 localized_strings->SetString("instantName", |
| 74 l10n_util::GetStringUTF16(IDS_INSTANT_PREF)); | 79 l10n_util::GetStringUTF16(IDS_INSTANT_PREF)); |
| 75 localized_strings->SetString("instantWarningText", | 80 localized_strings->SetString("instantWarningText", |
| 76 l10n_util::GetStringUTF16(IDS_INSTANT_PREF_WARNING)); | 81 l10n_util::GetStringUTF16(IDS_INSTANT_PREF_WARNING)); |
| 77 localized_strings->SetString("instantLearnMoreLink", | 82 localized_strings->SetString("instantLearnMoreLink", |
| 78 ASCIIToUTF16(browser::InstantLearnMoreURL().spec())); | 83 ASCIIToUTF16(browser::InstantLearnMoreURL().spec())); |
| 79 localized_strings->SetString("instantConfirmTitle", | 84 localized_strings->SetString("instantConfirmTitle", |
| 80 l10n_util::GetStringUTF16(IDS_INSTANT_OPT_IN_TITLE)); | 85 l10n_util::GetStringUTF16(IDS_INSTANT_OPT_IN_TITLE)); |
| 81 localized_strings->SetString("instantConfirmMessage", | 86 localized_strings->SetString("instantConfirmMessage", |
| 82 l10n_util::GetStringUTF16(IDS_INSTANT_OPT_IN_MESSAGE)); | 87 l10n_util::GetStringUTF16(IDS_INSTANT_OPT_IN_MESSAGE)); |
| 83 localized_strings->SetString("defaultBrowserGroupName", | 88 localized_strings->SetString("defaultBrowserGroupName", |
| 84 l10n_util::GetStringUTF16(IDS_OPTIONS_DEFAULTBROWSER_GROUP_NAME)); | 89 dom_options_util::StripColon( |
| 90 l10n_util::GetStringUTF16(IDS_OPTIONS_DEFAULTBROWSER_GROUP_NAME))); |
| 85 localized_strings->SetString("defaultBrowserUnknown", | 91 localized_strings->SetString("defaultBrowserUnknown", |
| 86 l10n_util::GetStringFUTF16(IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN, | 92 l10n_util::GetStringFUTF16(IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN, |
| 87 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 93 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
| 88 localized_strings->SetString("defaultBrowserUseAsDefault", | 94 localized_strings->SetString("defaultBrowserUseAsDefault", |
| 89 l10n_util::GetStringFUTF16(IDS_OPTIONS_DEFAULTBROWSER_USEASDEFAULT, | 95 l10n_util::GetStringFUTF16(IDS_OPTIONS_DEFAULTBROWSER_USEASDEFAULT, |
| 90 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 96 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
| 91 } | 97 } |
| 92 | 98 |
| 93 void BrowserOptionsHandler::RegisterMessages() { | 99 void BrowserOptionsHandler::RegisterMessages() { |
| 94 dom_ui_->RegisterMessageCallback( | 100 dom_ui_->RegisterMessageCallback( |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 } | 355 } |
| 350 | 356 |
| 351 void BrowserOptionsHandler::SaveStartupPagesPref() { | 357 void BrowserOptionsHandler::SaveStartupPagesPref() { |
| 352 PrefService* prefs = dom_ui_->GetProfile()->GetPrefs(); | 358 PrefService* prefs = dom_ui_->GetProfile()->GetPrefs(); |
| 353 | 359 |
| 354 SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs); | 360 SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs); |
| 355 pref.urls = startup_custom_pages_table_model_->GetURLs(); | 361 pref.urls = startup_custom_pages_table_model_->GetURLs(); |
| 356 | 362 |
| 357 SessionStartupPref::SetStartupPref(prefs, pref); | 363 SessionStartupPref::SetStartupPref(prefs, pref); |
| 358 } | 364 } |
| OLD | NEW |