OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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.h" | 7 #include "app/gfx/font.h" |
8 #include "app/gfx/font_util.h" | 8 #include "app/gfx/font_util.h" |
9 #include "base/histogram.h" | 9 #include "base/histogram.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 SyncSetupFlow::~SyncSetupFlow() { | 148 SyncSetupFlow::~SyncSetupFlow() { |
149 flow_handler_->set_flow(NULL); | 149 flow_handler_->set_flow(NULL); |
150 } | 150 } |
151 | 151 |
152 void SyncSetupFlow::GetDialogSize(gfx::Size* size) const { | 152 void SyncSetupFlow::GetDialogSize(gfx::Size* size) const { |
153 PrefService* prefs = service_->profile()->GetPrefs(); | 153 PrefService* prefs = service_->profile()->GetPrefs(); |
154 gfx::Font approximate_web_font = gfx::Font::CreateFont( | 154 gfx::Font approximate_web_font = gfx::Font::CreateFont( |
155 prefs->GetString(prefs::kWebKitSansSerifFontFamily), | 155 prefs->GetString(prefs::kWebKitSansSerifFontFamily), |
156 prefs->GetInteger(prefs::kWebKitDefaultFontSize)); | 156 prefs->GetInteger(prefs::kWebKitDefaultFontSize)); |
157 | 157 |
158 gfx::Size s = gfx::GetLocalizedContentsSizeForFont( | 158 *size = gfx::GetLocalizedContentsSizeForFont( |
159 IDS_SYNC_SETUP_WIZARD_WIDTH_CHARS, | 159 IDS_SYNC_SETUP_WIZARD_WIDTH_CHARS, |
160 IDS_SYNC_SETUP_WIZARD_HEIGHT_LINES, | 160 IDS_SYNC_SETUP_WIZARD_HEIGHT_LINES, |
161 approximate_web_font); | 161 approximate_web_font); |
162 | 162 |
163 size->set_width(s.width()); | 163 #if !defined(OS_WIN) |
164 size->set_height(s.height()); | 164 // NOTE(akalin): This is a hack to work around a problem with font height on |
| 165 // windows. Basically font metrics are incorrectly returned in logical units |
| 166 // instead of pixels on Windows. Logical units are very commonly 96 DPI |
| 167 // so our localized char/line counts are too small by a factor of 96/72. |
| 168 // So we compensate for this on non-windows platform. |
| 169 // |
| 170 // TODO(akalin): Remove this hack once we fix the windows font problem (or at |
| 171 // least work around it in some other place). |
| 172 float scale_hack = 96.f/72.f; |
| 173 size->set_width(size->width() * scale_hack); |
| 174 size->set_height(size->height() * scale_hack); |
| 175 #endif |
165 } | 176 } |
166 | 177 |
167 // A callback to notify the delegate that the dialog closed. | 178 // A callback to notify the delegate that the dialog closed. |
168 void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) { | 179 void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) { |
169 DCHECK(json_retval.empty()); | 180 DCHECK(json_retval.empty()); |
170 container_->set_flow(NULL); // Sever ties from the wizard. | 181 container_->set_flow(NULL); // Sever ties from the wizard. |
171 if (current_state_ == SyncSetupWizard::DONE || | 182 if (current_state_ == SyncSetupWizard::DONE || |
172 current_state_ == SyncSetupWizard::DONE_FIRST_TIME) { | 183 current_state_ == SyncSetupWizard::DONE_FIRST_TIME) { |
173 service_->SetSyncSetupCompleted(); | 184 service_->SetSyncSetupCompleted(); |
174 } | 185 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 if (!b) | 302 if (!b) |
292 return NULL; | 303 return NULL; |
293 | 304 |
294 FlowHandler* handler = new FlowHandler(); | 305 FlowHandler* handler = new FlowHandler(); |
295 SyncSetupFlow* flow = new SyncSetupFlow(start, end, json_args, | 306 SyncSetupFlow* flow = new SyncSetupFlow(start, end, json_args, |
296 container, handler, service); | 307 container, handler, service); |
297 handler->set_flow(flow); | 308 handler->set_flow(flow); |
298 b->BrowserShowHtmlDialog(flow, NULL); | 309 b->BrowserShowHtmlDialog(flow, NULL); |
299 return flow; | 310 return flow; |
300 } | 311 } |
OLD | NEW |