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/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/autocomplete/autocomplete.h" | 13 #include "chrome/browser/autocomplete/autocomplete.h" |
14 #include "chrome/browser/autocomplete/autocomplete_match.h" | 14 #include "chrome/browser/autocomplete/autocomplete_match.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/custom_home_pages_table_model.h" | 16 #include "chrome/browser/custom_home_pages_table_model.h" |
17 #include "chrome/browser/instant/instant_confirm_dialog.h" | 17 #include "chrome/browser/instant/instant_confirm_dialog.h" |
18 #include "chrome/browser/metrics/user_metrics.h" | 18 #include "chrome/browser/metrics/user_metrics.h" |
19 #include "chrome/browser/net/url_fixer_upper.h" | 19 #include "chrome/browser/net/url_fixer_upper.h" |
20 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
21 #include "chrome/browser/prefs/session_startup_pref.h" | 21 #include "chrome/browser/prefs/session_startup_pref.h" |
22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/search_engines/template_url.h" | 23 #include "chrome/browser/search_engines/template_url.h" |
24 #include "chrome/browser/search_engines/template_url_model.h" | 24 #include "chrome/browser/search_engines/template_url_model.h" |
25 #include "chrome/browser/ui/options/options_window.h" | 25 #include "chrome/browser/ui/options/options_window.h" |
26 #include "chrome/browser/ui/webui/favicon_source.h" | 26 #include "chrome/browser/ui/webui/favicon_source.h" |
27 #include "chrome/browser/ui/webui/options/options_managed_banner_handler.h" | 27 #include "chrome/browser/ui/webui/options/options_managed_banner_handler.h" |
28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/url_constants.h" |
29 #include "chrome/installer/util/browser_distribution.h" | 30 #include "chrome/installer/util/browser_distribution.h" |
30 #include "content/browser/browser_thread.h" | 31 #include "content/browser/browser_thread.h" |
31 #include "grit/chromium_strings.h" | 32 #include "grit/chromium_strings.h" |
32 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
33 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
34 | 35 |
35 BrowserOptionsHandler::BrowserOptionsHandler() | 36 BrowserOptionsHandler::BrowserOptionsHandler() |
36 : template_url_model_(NULL), startup_custom_pages_table_model_(NULL) { | 37 : template_url_model_(NULL), startup_custom_pages_table_model_(NULL) { |
37 #if !defined(OS_MACOSX) | 38 #if !defined(OS_MACOSX) |
38 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); | 39 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 "requestAutocompleteSuggestions", | 113 "requestAutocompleteSuggestions", |
113 NewCallback(this, | 114 NewCallback(this, |
114 &BrowserOptionsHandler::RequestAutocompleteSuggestions)); | 115 &BrowserOptionsHandler::RequestAutocompleteSuggestions)); |
115 } | 116 } |
116 | 117 |
117 void BrowserOptionsHandler::Initialize() { | 118 void BrowserOptionsHandler::Initialize() { |
118 Profile* profile = web_ui_->GetProfile(); | 119 Profile* profile = web_ui_->GetProfile(); |
119 | 120 |
120 // Create our favicon data source. | 121 // Create our favicon data source. |
121 profile->GetChromeURLDataManager()->AddDataSource( | 122 profile->GetChromeURLDataManager()->AddDataSource( |
122 new FaviconSource(profile)); | 123 new FaviconSource(profile, chrome::kChromeUIFaviconHost)); |
123 | 124 |
124 homepage_.Init(prefs::kHomePage, profile->GetPrefs(), NULL); | 125 homepage_.Init(prefs::kHomePage, profile->GetPrefs(), NULL); |
125 default_browser_policy_.Init(prefs::kDefaultBrowserSettingEnabled, | 126 default_browser_policy_.Init(prefs::kDefaultBrowserSettingEnabled, |
126 g_browser_process->local_state(), | 127 g_browser_process->local_state(), |
127 this); | 128 this); |
128 UpdateDefaultBrowserState(); | 129 UpdateDefaultBrowserState(); |
129 UpdateStartupPages(); | 130 UpdateStartupPages(); |
130 UpdateSearchEngines(); | 131 UpdateSearchEngines(); |
131 banner_handler_.reset( | 132 banner_handler_.reset( |
132 new OptionsManagedBannerHandler(web_ui_, | 133 new OptionsManagedBannerHandler(web_ui_, |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 DictionaryValue* entry = new DictionaryValue(); | 433 DictionaryValue* entry = new DictionaryValue(); |
433 entry->SetString("title", match.description); | 434 entry->SetString("title", match.description); |
434 entry->SetString("displayURL", match.contents); | 435 entry->SetString("displayURL", match.contents); |
435 entry->SetString("url", match.destination_url.spec()); | 436 entry->SetString("url", match.destination_url.spec()); |
436 suggestions.Append(entry); | 437 suggestions.Append(entry); |
437 } | 438 } |
438 | 439 |
439 web_ui_->CallJavascriptFunction( | 440 web_ui_->CallJavascriptFunction( |
440 "BrowserOptions.updateAutocompleteSuggestions", suggestions); | 441 "BrowserOptions.updateAutocompleteSuggestions", suggestions); |
441 } | 442 } |
OLD | NEW |