| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 default_browser_worker_->StartCheckIsDefault(); | 186 default_browser_worker_->StartCheckIsDefault(); |
| 187 #endif | 187 #endif |
| 188 } | 188 } |
| 189 | 189 |
| 190 void BrowserOptionsHandler::BecomeDefaultBrowser(const ListValue* args) { | 190 void BrowserOptionsHandler::BecomeDefaultBrowser(const ListValue* args) { |
| 191 // If the default browser setting is managed then we should not be able to | 191 // If the default browser setting is managed then we should not be able to |
| 192 // call this function. | 192 // call this function. |
| 193 if (default_browser_policy_.IsManaged()) | 193 if (default_browser_policy_.IsManaged()) |
| 194 return; | 194 return; |
| 195 | 195 |
| 196 UserMetricsRecordAction(UserMetricsAction("Options_SetAsDefaultBrowser")); | 196 UserMetrics::RecordAction(UserMetricsAction("Options_SetAsDefaultBrowser")); |
| 197 #if defined(OS_MACOSX) | 197 #if defined(OS_MACOSX) |
| 198 if (ShellIntegration::SetAsDefaultBrowser()) | 198 if (ShellIntegration::SetAsDefaultBrowser()) |
| 199 UpdateDefaultBrowserState(); | 199 UpdateDefaultBrowserState(); |
| 200 #else | 200 #else |
| 201 default_browser_worker_->StartSetAsDefault(); | 201 default_browser_worker_->StartSetAsDefault(); |
| 202 // Callback takes care of updating UI. | 202 // Callback takes care of updating UI. |
| 203 #endif | 203 #endif |
| 204 | 204 |
| 205 // If the user attempted to make Chrome the default browser, then he/she | 205 // If the user attempted to make Chrome the default browser, then he/she |
| 206 // arguably wants to be notified when that changes. | 206 // arguably wants to be notified when that changes. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 NOTREACHED(); | 287 NOTREACHED(); |
| 288 return; | 288 return; |
| 289 } | 289 } |
| 290 | 290 |
| 291 std::vector<const TemplateURL*> model_urls = | 291 std::vector<const TemplateURL*> model_urls = |
| 292 template_url_service_->GetTemplateURLs(); | 292 template_url_service_->GetTemplateURLs(); |
| 293 if (selected_index >= 0 && | 293 if (selected_index >= 0 && |
| 294 selected_index < static_cast<int>(model_urls.size())) | 294 selected_index < static_cast<int>(model_urls.size())) |
| 295 template_url_service_->SetDefaultSearchProvider(model_urls[selected_index]); | 295 template_url_service_->SetDefaultSearchProvider(model_urls[selected_index]); |
| 296 | 296 |
| 297 UserMetricsRecordAction(UserMetricsAction("Options_SearchEngineChanged")); | 297 UserMetrics::RecordAction(UserMetricsAction("Options_SearchEngineChanged")); |
| 298 } | 298 } |
| 299 | 299 |
| 300 void BrowserOptionsHandler::UpdateSearchEngines() { | 300 void BrowserOptionsHandler::UpdateSearchEngines() { |
| 301 template_url_service_ = TemplateURLServiceFactory::GetForProfile( | 301 template_url_service_ = TemplateURLServiceFactory::GetForProfile( |
| 302 web_ui_->GetProfile()); | 302 web_ui_->GetProfile()); |
| 303 if (template_url_service_) { | 303 if (template_url_service_) { |
| 304 template_url_service_->Load(); | 304 template_url_service_->Load(); |
| 305 template_url_service_->AddObserver(this); | 305 template_url_service_->AddObserver(this); |
| 306 OnTemplateURLServiceChanged(); | 306 OnTemplateURLServiceChanged(); |
| 307 } | 307 } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 DictionaryValue* entry = new DictionaryValue(); | 474 DictionaryValue* entry = new DictionaryValue(); |
| 475 entry->SetString("title", match.description); | 475 entry->SetString("title", match.description); |
| 476 entry->SetString("displayURL", match.contents); | 476 entry->SetString("displayURL", match.contents); |
| 477 entry->SetString("url", match.destination_url.spec()); | 477 entry->SetString("url", match.destination_url.spec()); |
| 478 suggestions.Append(entry); | 478 suggestions.Append(entry); |
| 479 } | 479 } |
| 480 | 480 |
| 481 web_ui_->CallJavascriptFunction( | 481 web_ui_->CallJavascriptFunction( |
| 482 "BrowserOptions.updateAutocompleteSuggestions", suggestions); | 482 "BrowserOptions.updateAutocompleteSuggestions", suggestions); |
| 483 } | 483 } |
| OLD | NEW |