| 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 #ifdef CHROME_PERSONALIZATION | 5 #ifdef CHROME_PERSONALIZATION |
| 6 | 6 |
| 7 #include "chrome/browser/views/sync/sync_setup_flow.h" | 7 #include "chrome/browser/sync/sync_setup_flow.h" |
| 8 | 8 |
| 9 #include "app/gfx/font.h" | 9 #include "app/gfx/font.h" |
| 10 #include "app/gfx/font_util.h" |
| 10 #include "base/histogram.h" | 11 #include "base/histogram.h" |
| 11 #include "base/json_reader.h" | 12 #include "base/json_reader.h" |
| 12 #include "base/json_writer.h" | 13 #include "base/json_writer.h" |
| 13 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/utf_string_conversions.h" |
| 14 #include "base/values.h" | 16 #include "base/values.h" |
| 15 #include "chrome/browser/browser.h" | 17 #include "chrome/browser/browser.h" |
| 16 #include "chrome/browser/browser_list.h" | 18 #include "chrome/browser/browser_list.h" |
| 17 #include "chrome/browser/renderer_host/render_view_host.h" | 19 #include "chrome/browser/renderer_host/render_view_host.h" |
| 18 #include "chrome/browser/sync/auth_error_state.h" | 20 #include "chrome/browser/sync/auth_error_state.h" |
| 19 #include "chrome/browser/sync/profile_sync_service.h" | 21 #include "chrome/browser/sync/profile_sync_service.h" |
| 20 #include "chrome/browser/tab_contents/tab_contents.h" | 22 #include "chrome/browser/tab_contents/tab_contents.h" |
| 21 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 22 #include "grit/locale_settings.h" | 24 #include "grit/locale_settings.h" |
| 23 #include "views/window/window.h" | |
| 24 | 25 |
| 25 // XPath expression for finding specific iframes. | 26 // XPath expression for finding specific iframes. |
| 26 static const wchar_t* kLoginIFrameXPath = L"//iframe[@id='login']"; | 27 static const wchar_t* kLoginIFrameXPath = L"//iframe[@id='login']"; |
| 27 static const wchar_t* kMergeIFrameXPath = L"//iframe[@id='merge']"; | 28 static const wchar_t* kMergeIFrameXPath = L"//iframe[@id='merge']"; |
| 28 static const wchar_t* kDoneIframeXPath = L"//iframe[@id='done']"; | 29 static const wchar_t* kDoneIframeXPath = L"//iframe[@id='done']"; |
| 29 | 30 |
| 30 // Helper function to read the JSON string from the Value parameter. | 31 // Helper function to read the JSON string from the Value parameter. |
| 31 static std::string GetJsonResponse(const Value* content) { | 32 static std::string GetJsonResponse(const Value* content) { |
| 32 if (!content || !content->IsType(Value::TYPE_LIST)) { | 33 if (!content || !content->IsType(Value::TYPE_LIST)) { |
| 33 NOTREACHED(); | 34 NOTREACHED(); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 SyncSetupFlow::~SyncSetupFlow() { | 150 SyncSetupFlow::~SyncSetupFlow() { |
| 150 flow_handler_->set_flow(NULL); | 151 flow_handler_->set_flow(NULL); |
| 151 } | 152 } |
| 152 | 153 |
| 153 void SyncSetupFlow::GetDialogSize(gfx::Size* size) const { | 154 void SyncSetupFlow::GetDialogSize(gfx::Size* size) const { |
| 154 PrefService* prefs = service_->profile()->GetPrefs(); | 155 PrefService* prefs = service_->profile()->GetPrefs(); |
| 155 gfx::Font approximate_web_font = gfx::Font::CreateFont( | 156 gfx::Font approximate_web_font = gfx::Font::CreateFont( |
| 156 prefs->GetString(prefs::kWebKitSansSerifFontFamily), | 157 prefs->GetString(prefs::kWebKitSansSerifFontFamily), |
| 157 prefs->GetInteger(prefs::kWebKitDefaultFontSize)); | 158 prefs->GetInteger(prefs::kWebKitDefaultFontSize)); |
| 158 | 159 |
| 159 gfx::Size s = views::Window::GetLocalizedContentsSizeForFont( | 160 gfx::Size s = gfx::GetLocalizedContentsSizeForFont( |
| 160 IDS_SYNC_SETUP_WIZARD_WIDTH_CHARS, | 161 IDS_SYNC_SETUP_WIZARD_WIDTH_CHARS, |
| 161 IDS_SYNC_SETUP_WIZARD_HEIGHT_LINES, | 162 IDS_SYNC_SETUP_WIZARD_HEIGHT_LINES, |
| 162 approximate_web_font); | 163 approximate_web_font); |
| 163 | 164 |
| 164 size->set_width(s.width()); | 165 size->set_width(s.width()); |
| 165 size->set_height(s.height()); | 166 size->set_height(s.height()); |
| 166 } | 167 } |
| 167 | 168 |
| 168 // A callback to notify the delegate that the dialog closed. | 169 // A callback to notify the delegate that the dialog closed. |
| 169 void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) { | 170 void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 flow_handler_->ShowGaiaSuccessAndSettingUp(); | 258 flow_handler_->ShowGaiaSuccessAndSettingUp(); |
| 258 break; | 259 break; |
| 259 case SyncSetupWizard::MERGE_AND_SYNC: | 260 case SyncSetupWizard::MERGE_AND_SYNC: |
| 260 flow_handler_->ShowMergeAndSync(); | 261 flow_handler_->ShowMergeAndSync(); |
| 261 break; | 262 break; |
| 262 case SyncSetupWizard::FATAL_ERROR: | 263 case SyncSetupWizard::FATAL_ERROR: |
| 263 if (current_state_ == SyncSetupWizard::MERGE_AND_SYNC) | 264 if (current_state_ == SyncSetupWizard::MERGE_AND_SYNC) |
| 264 flow_handler_->ShowMergeAndSyncError(); | 265 flow_handler_->ShowMergeAndSyncError(); |
| 265 break; | 266 break; |
| 266 case SyncSetupWizard::DONE_FIRST_TIME: | 267 case SyncSetupWizard::DONE_FIRST_TIME: |
| 267 flow_handler_->ShowFirstTimeDone(service_->GetAuthenticatedUsername()); | 268 flow_handler_->ShowFirstTimeDone( |
| 269 UTF16ToWide(service_->GetAuthenticatedUsername())); |
| 268 break; | 270 break; |
| 269 case SyncSetupWizard::DONE: | 271 case SyncSetupWizard::DONE: |
| 270 flow_handler_->ShowSetupDone(service_->GetAuthenticatedUsername()); | 272 flow_handler_->ShowSetupDone( |
| 273 UTF16ToWide(service_->GetAuthenticatedUsername())); |
| 271 break; | 274 break; |
| 272 default: | 275 default: |
| 273 NOTREACHED() << "Invalid advance state: " << advance_state; | 276 NOTREACHED() << "Invalid advance state: " << advance_state; |
| 274 } | 277 } |
| 275 current_state_ = advance_state; | 278 current_state_ = advance_state; |
| 276 } | 279 } |
| 277 | 280 |
| 278 // static | 281 // static |
| 279 SyncSetupFlow* SyncSetupFlow::Run(ProfileSyncService* service, | 282 SyncSetupFlow* SyncSetupFlow::Run(ProfileSyncService* service, |
| 280 SyncSetupFlowContainer* container, | 283 SyncSetupFlowContainer* container, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 292 | 295 |
| 293 FlowHandler* handler = new FlowHandler(); | 296 FlowHandler* handler = new FlowHandler(); |
| 294 SyncSetupFlow* flow = new SyncSetupFlow(start, end, json_args, | 297 SyncSetupFlow* flow = new SyncSetupFlow(start, end, json_args, |
| 295 container, handler, service); | 298 container, handler, service); |
| 296 handler->set_flow(flow); | 299 handler->set_flow(flow); |
| 297 b->BrowserShowHtmlDialog(flow, NULL); | 300 b->BrowserShowHtmlDialog(flow, NULL); |
| 298 return flow; | 301 return flow; |
| 299 } | 302 } |
| 300 | 303 |
| 301 #endif // CHROME_PERSONALIZATION | 304 #endif // CHROME_PERSONALIZATION |
| OLD | NEW |