| 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/browser_options_handler.h" | 5 #include "chrome/browser/dom_ui/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/chrome_thread.h" | 14 #include "chrome/browser/chrome_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_managed_banner_handler.h" | 17 #include "chrome/browser/dom_ui/options_managed_banner_handler.h" |
| 18 #include "chrome/browser/metrics/user_metrics.h" |
| 18 #include "chrome/browser/net/url_fixer_upper.h" | 19 #include "chrome/browser/net/url_fixer_upper.h" |
| 19 #include "chrome/browser/profile.h" | 20 #include "chrome/browser/profile.h" |
| 20 #include "chrome/browser/options_window.h" | 21 #include "chrome/browser/options_window.h" |
| 21 #include "chrome/browser/session_startup_pref.h" | 22 #include "chrome/browser/session_startup_pref.h" |
| 22 #include "chrome/installer/util/browser_distribution.h" | 23 #include "chrome/installer/util/browser_distribution.h" |
| 23 #include "grit/chromium_strings.h" | 24 #include "grit/chromium_strings.h" |
| 24 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 25 | 26 |
| 26 BrowserOptionsHandler::BrowserOptionsHandler() | 27 BrowserOptionsHandler::BrowserOptionsHandler() |
| 27 : template_url_model_(NULL), startup_custom_pages_table_model_(NULL) { | 28 : template_url_model_(NULL), startup_custom_pages_table_model_(NULL) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 else | 133 else |
| 133 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN; | 134 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN; |
| 134 | 135 |
| 135 SetDefaultBrowserUIString(status_string_id); | 136 SetDefaultBrowserUIString(status_string_id); |
| 136 #else | 137 #else |
| 137 default_browser_worker_->StartCheckDefaultBrowser(); | 138 default_browser_worker_->StartCheckDefaultBrowser(); |
| 138 #endif | 139 #endif |
| 139 } | 140 } |
| 140 | 141 |
| 141 void BrowserOptionsHandler::BecomeDefaultBrowser(const ListValue* args) { | 142 void BrowserOptionsHandler::BecomeDefaultBrowser(const ListValue* args) { |
| 143 UserMetricsRecordAction(UserMetricsAction("Options_SetAsDefaultBrowser"), |
| 144 NULL); |
| 142 #if defined(OS_MACOSX) | 145 #if defined(OS_MACOSX) |
| 143 if (ShellIntegration::SetAsDefaultBrowser()) | 146 if (ShellIntegration::SetAsDefaultBrowser()) |
| 144 UpdateDefaultBrowserState(); | 147 UpdateDefaultBrowserState(); |
| 145 #else | 148 #else |
| 146 default_browser_worker_->StartSetAsDefaultBrowser(); | 149 default_browser_worker_->StartSetAsDefaultBrowser(); |
| 147 // Callback takes care of updating UI. | 150 // Callback takes care of updating UI. |
| 148 #endif | 151 #endif |
| 149 } | 152 } |
| 150 | 153 |
| 151 int BrowserOptionsHandler::StatusStringIdForState( | 154 int BrowserOptionsHandler::StatusStringIdForState( |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 if (!ExtractIntegerValue(args, &selected_index)) { | 222 if (!ExtractIntegerValue(args, &selected_index)) { |
| 220 NOTREACHED(); | 223 NOTREACHED(); |
| 221 return; | 224 return; |
| 222 } | 225 } |
| 223 | 226 |
| 224 std::vector<const TemplateURL*> model_urls = | 227 std::vector<const TemplateURL*> model_urls = |
| 225 template_url_model_->GetTemplateURLs(); | 228 template_url_model_->GetTemplateURLs(); |
| 226 if (selected_index >= 0 && | 229 if (selected_index >= 0 && |
| 227 selected_index < static_cast<int>(model_urls.size())) | 230 selected_index < static_cast<int>(model_urls.size())) |
| 228 template_url_model_->SetDefaultSearchProvider(model_urls[selected_index]); | 231 template_url_model_->SetDefaultSearchProvider(model_urls[selected_index]); |
| 232 |
| 233 UserMetricsRecordAction(UserMetricsAction("Options_SearchEngineChanged"), |
| 234 NULL); |
| 229 } | 235 } |
| 230 | 236 |
| 231 void BrowserOptionsHandler::UpdateSearchEngines() { | 237 void BrowserOptionsHandler::UpdateSearchEngines() { |
| 232 template_url_model_ = dom_ui_->GetProfile()->GetTemplateURLModel(); | 238 template_url_model_ = dom_ui_->GetProfile()->GetTemplateURLModel(); |
| 233 if (template_url_model_) { | 239 if (template_url_model_) { |
| 234 template_url_model_->Load(); | 240 template_url_model_->Load(); |
| 235 template_url_model_->AddObserver(this); | 241 template_url_model_->AddObserver(this); |
| 236 OnTemplateURLModelChanged(); | 242 OnTemplateURLModelChanged(); |
| 237 } | 243 } |
| 238 } | 244 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 334 } |
| 329 | 335 |
| 330 void BrowserOptionsHandler::SaveStartupPagesPref() { | 336 void BrowserOptionsHandler::SaveStartupPagesPref() { |
| 331 PrefService* prefs = dom_ui_->GetProfile()->GetPrefs(); | 337 PrefService* prefs = dom_ui_->GetProfile()->GetPrefs(); |
| 332 | 338 |
| 333 SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs); | 339 SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs); |
| 334 pref.urls = startup_custom_pages_table_model_->GetURLs(); | 340 pref.urls = startup_custom_pages_table_model_->GetURLs(); |
| 335 | 341 |
| 336 SessionStartupPref::SetStartupPref(prefs, pref); | 342 SessionStartupPref::SetStartupPref(prefs, pref); |
| 337 } | 343 } |
| OLD | NEW |