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 20 matching lines...) Expand all Loading... |
31 #include "content/common/notification_service.h" | 31 #include "content/common/notification_service.h" |
32 #include "content/common/notification_source.h" | 32 #include "content/common/notification_source.h" |
33 #include "content/common/notification_type.h" | 33 #include "content/common/notification_type.h" |
34 #include "grit/chromium_strings.h" | 34 #include "grit/chromium_strings.h" |
35 #include "grit/generated_resources.h" | 35 #include "grit/generated_resources.h" |
36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
37 | 37 |
38 BrowserOptionsHandler::BrowserOptionsHandler() | 38 BrowserOptionsHandler::BrowserOptionsHandler() |
39 : template_url_model_(NULL), startup_custom_pages_table_model_(NULL) { | 39 : template_url_model_(NULL), startup_custom_pages_table_model_(NULL) { |
40 #if !defined(OS_MACOSX) | 40 #if !defined(OS_MACOSX) |
41 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); | 41 default_browser_worker_ = new ShellIntegration::DefaultClientAppWorker(this); |
42 #endif | 42 #endif |
43 } | 43 } |
44 | 44 |
45 BrowserOptionsHandler::~BrowserOptionsHandler() { | 45 BrowserOptionsHandler::~BrowserOptionsHandler() { |
46 if (default_browser_worker_.get()) | 46 if (default_browser_worker_.get()) |
47 default_browser_worker_->ObserverDestroyed(); | 47 default_browser_worker_->ObserverDestroyed(); |
48 if (template_url_model_) | 48 if (template_url_model_) |
49 template_url_model_->RemoveObserver(this); | 49 template_url_model_->RemoveObserver(this); |
50 } | 50 } |
51 | 51 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 160 } |
161 | 161 |
162 void BrowserOptionsHandler::UpdateDefaultBrowserState() { | 162 void BrowserOptionsHandler::UpdateDefaultBrowserState() { |
163 // Check for side-by-side first. | 163 // Check for side-by-side first. |
164 if (!platform_util::CanSetAsDefaultBrowser()) { | 164 if (!platform_util::CanSetAsDefaultBrowser()) { |
165 SetDefaultBrowserUIString(IDS_OPTIONS_DEFAULTBROWSER_SXS); | 165 SetDefaultBrowserUIString(IDS_OPTIONS_DEFAULTBROWSER_SXS); |
166 return; | 166 return; |
167 } | 167 } |
168 | 168 |
169 #if defined(OS_MACOSX) | 169 #if defined(OS_MACOSX) |
170 ShellIntegration::DefaultBrowserState state = | 170 ShellIntegration::DefaultClientAppState state = |
171 ShellIntegration::IsDefaultBrowser(); | 171 ShellIntegration::IsDefaultBrowser(); |
172 int status_string_id; | 172 int status_string_id; |
173 if (state == ShellIntegration::IS_DEFAULT_BROWSER) | 173 if (state == ShellIntegration::IS_DEFAULT_CLIENT_APP) |
174 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_DEFAULT; | 174 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_DEFAULT; |
175 else if (state == ShellIntegration::NOT_DEFAULT_BROWSER) | 175 else if (state == ShellIntegration::NOT_DEFAULT_CLIENT_APP) |
176 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT; | 176 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT; |
177 else | 177 else |
178 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN; | 178 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN; |
179 | 179 |
180 SetDefaultBrowserUIString(status_string_id); | 180 SetDefaultBrowserUIString(status_string_id); |
181 #else | 181 #else |
182 default_browser_worker_->StartCheckDefaultBrowser(); | 182 default_browser_worker_->StartCheckDefaultBrowser(); |
183 #endif | 183 #endif |
184 } | 184 } |
185 | 185 |
(...skipping 12 matching lines...) Expand all Loading... |
198 // Callback takes care of updating UI. | 198 // Callback takes care of updating UI. |
199 #endif | 199 #endif |
200 | 200 |
201 // If the user attempted to make Chrome the default browser, then he/she | 201 // If the user attempted to make Chrome the default browser, then he/she |
202 // arguably wants to be notified when that changes. | 202 // arguably wants to be notified when that changes. |
203 PrefService* prefs = web_ui_->GetProfile()->GetPrefs(); | 203 PrefService* prefs = web_ui_->GetProfile()->GetPrefs(); |
204 prefs->SetBoolean(prefs::kCheckDefaultBrowser, true); | 204 prefs->SetBoolean(prefs::kCheckDefaultBrowser, true); |
205 } | 205 } |
206 | 206 |
207 int BrowserOptionsHandler::StatusStringIdForState( | 207 int BrowserOptionsHandler::StatusStringIdForState( |
208 ShellIntegration::DefaultBrowserState state) { | 208 ShellIntegration::DefaultClientAppState state) { |
209 if (state == ShellIntegration::IS_DEFAULT_BROWSER) | 209 if (state == ShellIntegration::IS_DEFAULT_CLIENT_APP) |
210 return IDS_OPTIONS_DEFAULTBROWSER_DEFAULT; | 210 return IDS_OPTIONS_DEFAULTBROWSER_DEFAULT; |
211 if (state == ShellIntegration::NOT_DEFAULT_BROWSER) | 211 if (state == ShellIntegration::NOT_DEFAULT_CLIENT_APP) |
212 return IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT; | 212 return IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT; |
213 return IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN; | 213 return IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN; |
214 } | 214 } |
215 | 215 |
216 void BrowserOptionsHandler::SetDefaultBrowserUIState( | 216 void BrowserOptionsHandler::SetDefaultClientAppUIState( |
217 ShellIntegration::DefaultBrowserUIState state) { | 217 ShellIntegration::DefaultClientAppUIState state) { |
218 int status_string_id; | 218 int status_string_id; |
219 if (state == ShellIntegration::STATE_IS_DEFAULT) | 219 if (state == ShellIntegration::STATE_IS_DEFAULT) |
220 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_DEFAULT; | 220 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_DEFAULT; |
221 else if (state == ShellIntegration::STATE_NOT_DEFAULT) | 221 else if (state == ShellIntegration::STATE_NOT_DEFAULT) |
222 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT; | 222 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT; |
223 else if (state == ShellIntegration::STATE_UNKNOWN) | 223 else if (state == ShellIntegration::STATE_UNKNOWN) |
224 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN; | 224 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN; |
225 else | 225 else |
226 return; // Still processing. | 226 return; // Still processing. |
227 | 227 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 DictionaryValue* entry = new DictionaryValue(); | 445 DictionaryValue* entry = new DictionaryValue(); |
446 entry->SetString("title", match.description); | 446 entry->SetString("title", match.description); |
447 entry->SetString("displayURL", match.contents); | 447 entry->SetString("displayURL", match.contents); |
448 entry->SetString("url", match.destination_url.spec()); | 448 entry->SetString("url", match.destination_url.spec()); |
449 suggestions.Append(entry); | 449 suggestions.Append(entry); |
450 } | 450 } |
451 | 451 |
452 web_ui_->CallJavascriptFunction( | 452 web_ui_->CallJavascriptFunction( |
453 "BrowserOptions.updateAutocompleteSuggestions", suggestions); | 453 "BrowserOptions.updateAutocompleteSuggestions", suggestions); |
454 } | 454 } |
OLD | NEW |