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

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

Issue 8919017: Split UserMetrics into API vs. implementation. Move API to content/public. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Version for commit (merged again). Created 9 years 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/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/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/browser/prefs/pref_service.h" 22 #include "chrome/browser/prefs/pref_service.h"
23 #include "chrome/browser/prefs/session_startup_pref.h" 23 #include "chrome/browser/prefs/session_startup_pref.h"
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/search_engines/template_url.h" 25 #include "chrome/browser/search_engines/template_url.h"
26 #include "chrome/browser/search_engines/template_url_service.h" 26 #include "chrome/browser/search_engines/template_url_service.h"
27 #include "chrome/browser/search_engines/template_url_service_factory.h" 27 #include "chrome/browser/search_engines/template_url_service_factory.h"
28 #include "chrome/browser/ui/webui/favicon_source.h" 28 #include "chrome/browser/ui/webui/favicon_source.h"
29 #include "chrome/common/chrome_notification_types.h" 29 #include "chrome/common/chrome_notification_types.h"
30 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
31 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
32 #include "content/browser/user_metrics.h"
33 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
34 #include "content/public/browser/notification_details.h" 33 #include "content/public/browser/notification_details.h"
35 #include "content/public/browser/notification_source.h" 34 #include "content/public/browser/notification_source.h"
35 #include "content/public/browser/user_metrics.h"
36 #include "grit/chromium_strings.h" 36 #include "grit/chromium_strings.h"
37 #include "grit/generated_resources.h" 37 #include "grit/generated_resources.h"
38 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
39 39
40 using content::UserMetricsAction;
41
40 BrowserOptionsHandler::BrowserOptionsHandler() 42 BrowserOptionsHandler::BrowserOptionsHandler()
41 : template_url_service_(NULL), startup_custom_pages_table_model_(NULL) { 43 : template_url_service_(NULL), startup_custom_pages_table_model_(NULL) {
42 #if !defined(OS_MACOSX) 44 #if !defined(OS_MACOSX)
43 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); 45 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this);
44 #endif 46 #endif
45 } 47 }
46 48
47 BrowserOptionsHandler::~BrowserOptionsHandler() { 49 BrowserOptionsHandler::~BrowserOptionsHandler() {
48 if (default_browser_worker_.get()) 50 if (default_browser_worker_.get())
49 default_browser_worker_->ObserverDestroyed(); 51 default_browser_worker_->ObserverDestroyed();
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 default_browser_worker_->StartCheckIsDefault(); 179 default_browser_worker_->StartCheckIsDefault();
178 #endif 180 #endif
179 } 181 }
180 182
181 void BrowserOptionsHandler::BecomeDefaultBrowser(const ListValue* args) { 183 void BrowserOptionsHandler::BecomeDefaultBrowser(const ListValue* args) {
182 // If the default browser setting is managed then we should not be able to 184 // If the default browser setting is managed then we should not be able to
183 // call this function. 185 // call this function.
184 if (default_browser_policy_.IsManaged()) 186 if (default_browser_policy_.IsManaged())
185 return; 187 return;
186 188
187 UserMetrics::RecordAction(UserMetricsAction("Options_SetAsDefaultBrowser")); 189 content::RecordAction(UserMetricsAction("Options_SetAsDefaultBrowser"));
188 #if defined(OS_MACOSX) 190 #if defined(OS_MACOSX)
189 if (ShellIntegration::SetAsDefaultBrowser()) 191 if (ShellIntegration::SetAsDefaultBrowser())
190 UpdateDefaultBrowserState(); 192 UpdateDefaultBrowserState();
191 #else 193 #else
192 default_browser_worker_->StartSetAsDefault(); 194 default_browser_worker_->StartSetAsDefault();
193 // Callback takes care of updating UI. 195 // Callback takes care of updating UI.
194 #endif 196 #endif
195 197
196 // If the user attempted to make Chrome the default browser, then he/she 198 // If the user attempted to make Chrome the default browser, then he/she
197 // arguably wants to be notified when that changes. 199 // arguably wants to be notified when that changes.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 NOTREACHED(); 280 NOTREACHED();
279 return; 281 return;
280 } 282 }
281 283
282 std::vector<const TemplateURL*> model_urls = 284 std::vector<const TemplateURL*> model_urls =
283 template_url_service_->GetTemplateURLs(); 285 template_url_service_->GetTemplateURLs();
284 if (selected_index >= 0 && 286 if (selected_index >= 0 &&
285 selected_index < static_cast<int>(model_urls.size())) 287 selected_index < static_cast<int>(model_urls.size()))
286 template_url_service_->SetDefaultSearchProvider(model_urls[selected_index]); 288 template_url_service_->SetDefaultSearchProvider(model_urls[selected_index]);
287 289
288 UserMetrics::RecordAction(UserMetricsAction("Options_SearchEngineChanged")); 290 content::RecordAction(UserMetricsAction("Options_SearchEngineChanged"));
289 } 291 }
290 292
291 void BrowserOptionsHandler::UpdateSearchEngines() { 293 void BrowserOptionsHandler::UpdateSearchEngines() {
292 template_url_service_ = 294 template_url_service_ =
293 TemplateURLServiceFactory::GetForProfile(Profile::FromWebUI(web_ui_)); 295 TemplateURLServiceFactory::GetForProfile(Profile::FromWebUI(web_ui_));
294 if (template_url_service_) { 296 if (template_url_service_) {
295 template_url_service_->Load(); 297 template_url_service_->Load();
296 template_url_service_->AddObserver(this); 298 template_url_service_->AddObserver(this);
297 OnTemplateURLServiceChanged(); 299 OnTemplateURLServiceChanged();
298 } 300 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 DictionaryValue* entry = new DictionaryValue(); 487 DictionaryValue* entry = new DictionaryValue();
486 entry->SetString("title", match.description); 488 entry->SetString("title", match.description);
487 entry->SetString("displayURL", match.contents); 489 entry->SetString("displayURL", match.contents);
488 entry->SetString("url", match.destination_url.spec()); 490 entry->SetString("url", match.destination_url.spec());
489 suggestions.Append(entry); 491 suggestions.Append(entry);
490 } 492 }
491 493
492 web_ui_->CallJavascriptFunction( 494 web_ui_->CallJavascriptFunction(
493 "BrowserOptions.updateAutocompleteSuggestions", suggestions); 495 "BrowserOptions.updateAutocompleteSuggestions", suggestions);
494 } 496 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698