| OLD | NEW |
| 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/browser_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/browser_options_handler.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 default_browser_worker_->StartCheckIsDefault(); | 204 default_browser_worker_->StartCheckIsDefault(); |
| 205 #endif | 205 #endif |
| 206 } | 206 } |
| 207 | 207 |
| 208 void BrowserOptionsHandler::BecomeDefaultBrowser(const ListValue* args) { | 208 void BrowserOptionsHandler::BecomeDefaultBrowser(const ListValue* args) { |
| 209 // If the default browser setting is managed then we should not be able to | 209 // If the default browser setting is managed then we should not be able to |
| 210 // call this function. | 210 // call this function. |
| 211 if (default_browser_policy_.IsManaged()) | 211 if (default_browser_policy_.IsManaged()) |
| 212 return; | 212 return; |
| 213 | 213 |
| 214 UserMetricsRecordAction(UserMetricsAction("Options_SetAsDefaultBrowser")); | 214 UserMetrics::RecordAction(UserMetricsAction("Options_SetAsDefaultBrowser")); |
| 215 #if defined(OS_MACOSX) | 215 #if defined(OS_MACOSX) |
| 216 if (ShellIntegration::SetAsDefaultBrowser()) | 216 if (ShellIntegration::SetAsDefaultBrowser()) |
| 217 UpdateDefaultBrowserState(); | 217 UpdateDefaultBrowserState(); |
| 218 #else | 218 #else |
| 219 default_browser_worker_->StartSetAsDefault(); | 219 default_browser_worker_->StartSetAsDefault(); |
| 220 // Callback takes care of updating UI. | 220 // Callback takes care of updating UI. |
| 221 #endif | 221 #endif |
| 222 | 222 |
| 223 // If the user attempted to make Chrome the default browser, then he/she | 223 // If the user attempted to make Chrome the default browser, then he/she |
| 224 // arguably wants to be notified when that changes. | 224 // arguably wants to be notified when that changes. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 NOTREACHED(); | 305 NOTREACHED(); |
| 306 return; | 306 return; |
| 307 } | 307 } |
| 308 | 308 |
| 309 std::vector<const TemplateURL*> model_urls = | 309 std::vector<const TemplateURL*> model_urls = |
| 310 template_url_service_->GetTemplateURLs(); | 310 template_url_service_->GetTemplateURLs(); |
| 311 if (selected_index >= 0 && | 311 if (selected_index >= 0 && |
| 312 selected_index < static_cast<int>(model_urls.size())) | 312 selected_index < static_cast<int>(model_urls.size())) |
| 313 template_url_service_->SetDefaultSearchProvider(model_urls[selected_index]); | 313 template_url_service_->SetDefaultSearchProvider(model_urls[selected_index]); |
| 314 | 314 |
| 315 UserMetricsRecordAction(UserMetricsAction("Options_SearchEngineChanged")); | 315 UserMetrics::RecordAction(UserMetricsAction("Options_SearchEngineChanged")); |
| 316 } | 316 } |
| 317 | 317 |
| 318 void BrowserOptionsHandler::UpdateSearchEngines() { | 318 void BrowserOptionsHandler::UpdateSearchEngines() { |
| 319 template_url_service_ = TemplateURLServiceFactory::GetForProfile( | 319 template_url_service_ = TemplateURLServiceFactory::GetForProfile( |
| 320 web_ui_->GetProfile()); | 320 web_ui_->GetProfile()); |
| 321 if (template_url_service_) { | 321 if (template_url_service_) { |
| 322 template_url_service_->Load(); | 322 template_url_service_->Load(); |
| 323 template_url_service_->AddObserver(this); | 323 template_url_service_->AddObserver(this); |
| 324 OnTemplateURLServiceChanged(); | 324 OnTemplateURLServiceChanged(); |
| 325 } | 325 } |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 DictionaryValue* entry = new DictionaryValue(); | 547 DictionaryValue* entry = new DictionaryValue(); |
| 548 entry->SetString("title", match.description); | 548 entry->SetString("title", match.description); |
| 549 entry->SetString("displayURL", match.contents); | 549 entry->SetString("displayURL", match.contents); |
| 550 entry->SetString("url", match.destination_url.spec()); | 550 entry->SetString("url", match.destination_url.spec()); |
| 551 suggestions.Append(entry); | 551 suggestions.Append(entry); |
| 552 } | 552 } |
| 553 | 553 |
| 554 web_ui_->CallJavascriptFunction( | 554 web_ui_->CallJavascriptFunction( |
| 555 "BrowserOptions.updateAutocompleteSuggestions", suggestions); | 555 "BrowserOptions.updateAutocompleteSuggestions", suggestions); |
| 556 } | 556 } |
| OLD | NEW |