OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/sync/sync_setup_flow.h" | 5 #include "chrome/browser/sync/sync_setup_flow.h" |
6 | 6 |
7 #include "app/gfx/font_util.h" | |
8 #include "base/callback.h" | 7 #include "base/callback.h" |
9 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
11 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
12 #include "base/string_util.h" | 11 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
14 #include "base/values.h" | 13 #include "base/values.h" |
15 #include "chrome/browser/dom_ui/dom_ui_util.h" | 14 #include "chrome/browser/dom_ui/dom_ui_util.h" |
16 #include "chrome/browser/platform_util.h" | 15 #include "chrome/browser/platform_util.h" |
17 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
18 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/renderer_host/render_view_host.h" | 18 #include "chrome/browser/renderer_host/render_view_host.h" |
20 #include "chrome/browser/sync/profile_sync_service.h" | 19 #include "chrome/browser/sync/profile_sync_service.h" |
21 #include "chrome/browser/tab_contents/tab_contents.h" | 20 #include "chrome/browser/tab_contents/tab_contents.h" |
22 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
23 #include "chrome/browser/ui/browser_list.h" | 22 #include "chrome/browser/ui/browser_list.h" |
24 #if defined(OS_MACOSX) | |
25 #include "chrome/browser/ui/cocoa/html_dialog_window_controller_cppsafe.h" | |
26 #endif | |
27 #include "chrome/common/net/gaia/google_service_auth_error.h" | 23 #include "chrome/common/net/gaia/google_service_auth_error.h" |
28 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
29 #include "gfx/font.h" | 25 #include "gfx/font.h" |
30 #include "grit/locale_settings.h" | 26 #include "grit/locale_settings.h" |
| 27 #include "ui/base/l10n/l10n_font_util.h" |
| 28 |
| 29 #if defined(OS_MACOSX) |
| 30 #include "chrome/browser/ui/cocoa/html_dialog_window_controller_cppsafe.h" |
| 31 #endif |
31 | 32 |
32 // XPath expression for finding specific iframes. | 33 // XPath expression for finding specific iframes. |
33 static const wchar_t* kLoginIFrameXPath = L"//iframe[@id='login']"; | 34 static const wchar_t* kLoginIFrameXPath = L"//iframe[@id='login']"; |
34 static const wchar_t* kChooseDataTypesIFrameXPath = | 35 static const wchar_t* kChooseDataTypesIFrameXPath = |
35 L"//iframe[@id='configure']"; | 36 L"//iframe[@id='configure']"; |
36 static const wchar_t* kPassphraseIFrameXPath = | 37 static const wchar_t* kPassphraseIFrameXPath = |
37 L"//iframe[@id='passphrase']"; | 38 L"//iframe[@id='passphrase']"; |
38 static const wchar_t* kDoneIframeXPath = L"//iframe[@id='done']"; | 39 static const wchar_t* kDoneIframeXPath = L"//iframe[@id='done']"; |
39 | 40 |
40 void FlowHandler::RegisterMessages() { | 41 void FlowHandler::RegisterMessages() { |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 delete flow_handler_; | 367 delete flow_handler_; |
367 } | 368 } |
368 } | 369 } |
369 | 370 |
370 void SyncSetupFlow::GetDialogSize(gfx::Size* size) const { | 371 void SyncSetupFlow::GetDialogSize(gfx::Size* size) const { |
371 PrefService* prefs = service_->profile()->GetPrefs(); | 372 PrefService* prefs = service_->profile()->GetPrefs(); |
372 gfx::Font approximate_web_font = gfx::Font( | 373 gfx::Font approximate_web_font = gfx::Font( |
373 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)), | 374 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)), |
374 prefs->GetInteger(prefs::kWebKitDefaultFontSize)); | 375 prefs->GetInteger(prefs::kWebKitDefaultFontSize)); |
375 | 376 |
376 *size = gfx::GetLocalizedContentsSizeForFont( | 377 *size = ui::GetLocalizedContentsSizeForFont( |
377 IDS_SYNC_SETUP_WIZARD_WIDTH_CHARS, | 378 IDS_SYNC_SETUP_WIZARD_WIDTH_CHARS, |
378 IDS_SYNC_SETUP_WIZARD_HEIGHT_LINES, | 379 IDS_SYNC_SETUP_WIZARD_HEIGHT_LINES, |
379 approximate_web_font); | 380 approximate_web_font); |
380 | 381 |
381 #if defined(OS_MACOSX) | 382 #if defined(OS_MACOSX) |
382 // NOTE(akalin): This is a hack to work around a problem with font height on | 383 // NOTE(akalin): This is a hack to work around a problem with font height on |
383 // windows. Basically font metrics are incorrectly returned in logical units | 384 // windows. Basically font metrics are incorrectly returned in logical units |
384 // instead of pixels on Windows. Logical units are very commonly 96 DPI | 385 // instead of pixels on Windows. Logical units are very commonly 96 DPI |
385 // so our localized char/line counts are too small by a factor of 96/72. | 386 // so our localized char/line counts are too small by a factor of 96/72. |
386 // So we compensate for this on non-windows platform. | 387 // So we compensate for this on non-windows platform. |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 service_->OnUserChoseDatatypes(false, registered_types); | 750 service_->OnUserChoseDatatypes(false, registered_types); |
750 } else if (option == "google") { | 751 } else if (option == "google") { |
751 // Implicit passphrase already set up. | 752 // Implicit passphrase already set up. |
752 Advance(SyncSetupWizard::DONE); | 753 Advance(SyncSetupWizard::DONE); |
753 } | 754 } |
754 } | 755 } |
755 | 756 |
756 void SyncSetupFlow::OnGoToDashboard() { | 757 void SyncSetupFlow::OnGoToDashboard() { |
757 BrowserList::GetLastActive()->OpenPrivacyDashboardTabAndActivate(); | 758 BrowserList::GetLastActive()->OpenPrivacyDashboardTabAndActivate(); |
758 } | 759 } |
OLD | NEW |