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/views/autofill_profiles_view_win.h" | 5 #include "chrome/browser/views/autofill_profiles_view_win.h" |
6 | 6 |
7 #include <vsstyle.h> | 7 #include <vsstyle.h> |
8 #include <vssym32.h> | 8 #include <vssym32.h> |
9 | 9 |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
11 #include "app/resource_bundle.h" | 11 #include "app/resource_bundle.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "chrome/browser/autofill/autofill_manager.h" | 17 #include "chrome/browser/autofill/autofill_manager.h" |
18 #include "chrome/browser/autofill/phone_number.h" | 18 #include "chrome/browser/autofill/phone_number.h" |
19 #include "chrome/browser/browser.h" | 19 #include "chrome/browser/browser.h" |
20 #include "chrome/browser/browser_list.h" | 20 #include "chrome/browser/browser_list.h" |
21 #include "chrome/browser/browser_window.h" | 21 #include "chrome/browser/browser_window.h" |
22 #include "chrome/browser/metrics/user_metrics.h" | 22 #include "chrome/browser/metrics/user_metrics.h" |
23 #include "chrome/browser/pref_service.h" | 23 #include "chrome/browser/pref_service.h" |
24 #include "chrome/browser/profile.h" | 24 #include "chrome/browser/profile.h" |
25 #include "chrome/browser/views/list_background.h" | 25 #include "chrome/browser/views/list_background.h" |
26 #include "chrome/browser/window_sizer.h" | 26 #include "chrome/browser/window_sizer.h" |
| 27 #include "chrome/common/notification_details.h" |
27 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
28 #include "gfx/canvas.h" | 29 #include "gfx/canvas.h" |
29 #include "gfx/native_theme_win.h" | 30 #include "gfx/native_theme_win.h" |
30 #include "gfx/size.h" | 31 #include "gfx/size.h" |
31 #include "grit/app_resources.h" | 32 #include "grit/app_resources.h" |
32 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
33 #include "grit/theme_resources.h" | 34 #include "grit/theme_resources.h" |
34 #include "grit/locale_settings.h" | 35 #include "grit/locale_settings.h" |
35 #include "grit/theme_resources.h" | 36 #include "grit/theme_resources.h" |
36 #include "views/border.h" | 37 #include "views/border.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 enable_auto_fill_button_(NULL), | 78 enable_auto_fill_button_(NULL), |
78 add_address_button_(NULL), | 79 add_address_button_(NULL), |
79 add_credit_card_button_(NULL), | 80 add_credit_card_button_(NULL), |
80 edit_button_(NULL), | 81 edit_button_(NULL), |
81 remove_button_(NULL), | 82 remove_button_(NULL), |
82 scroll_view_(NULL), | 83 scroll_view_(NULL), |
83 focus_manager_(NULL), | 84 focus_manager_(NULL), |
84 billing_model_(true), | 85 billing_model_(true), |
85 child_dialog_opened_(false) { | 86 child_dialog_opened_(false) { |
86 DCHECK(preferences_); | 87 DCHECK(preferences_); |
| 88 enable_auto_fill_.Init(prefs::kAutoFillEnabled, preferences_, this); |
87 if (imported_profile) { | 89 if (imported_profile) { |
88 profiles_set_.push_back(EditableSetInfo(imported_profile)); | 90 profiles_set_.push_back(EditableSetInfo(imported_profile)); |
89 } | 91 } |
90 if (imported_credit_card) { | 92 if (imported_credit_card) { |
91 credit_card_set_.push_back( | 93 credit_card_set_.push_back( |
92 EditableSetInfo(imported_credit_card)); | 94 EditableSetInfo(imported_credit_card)); |
93 } | 95 } |
94 } | 96 } |
95 | 97 |
96 AutoFillProfilesView::~AutoFillProfilesView() { | 98 AutoFillProfilesView::~AutoFillProfilesView() { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 } | 147 } |
146 | 148 |
147 EditableSetViewContents *edit_view = new | 149 EditableSetViewContents *edit_view = new |
148 EditableSetViewContents(this, &billing_model_, true, it); | 150 EditableSetViewContents(this, &billing_model_, true, it); |
149 views::Window::CreateChromeWindow(window()->GetNativeWindow(), gfx::Rect(), | 151 views::Window::CreateChromeWindow(window()->GetNativeWindow(), gfx::Rect(), |
150 edit_view); | 152 edit_view); |
151 edit_view->window()->Show(); | 153 edit_view->window()->Show(); |
152 } | 154 } |
153 | 155 |
154 void AutoFillProfilesView::EditClicked() { | 156 void AutoFillProfilesView::EditClicked() { |
155 DCHECK(scroll_view_); | |
156 int index = scroll_view_->FirstSelectedRow(); | 157 int index = scroll_view_->FirstSelectedRow(); |
157 if (index == -1) | 158 if (index == -1) |
158 return; // Happens if user double clicks and the table is empty. | 159 return; // Happens if user double clicks and the table is empty. |
159 DCHECK(index >= 0); | 160 DCHECK(index >= 0); |
160 DCHECK(index < static_cast<int>(profiles_set_.size() + | 161 DCHECK(index < static_cast<int>(profiles_set_.size() + |
161 credit_card_set_.size())); | 162 credit_card_set_.size())); |
162 std::vector<EditableSetInfo>::iterator it; | 163 std::vector<EditableSetInfo>::iterator it; |
163 if (index < static_cast<int>(profiles_set_.size())) | 164 if (index < static_cast<int>(profiles_set_.size())) |
164 it = profiles_set_.begin() + index; | 165 it = profiles_set_.begin() + index; |
165 else | 166 else |
166 it = credit_card_set_.begin() + (index - profiles_set_.size()); | 167 it = credit_card_set_.begin() + (index - profiles_set_.size()); |
167 | 168 |
168 EditableSetViewContents *edit_view = new | 169 EditableSetViewContents *edit_view = new |
169 EditableSetViewContents(this, &billing_model_, false, it); | 170 EditableSetViewContents(this, &billing_model_, false, it); |
170 views::Window::CreateChromeWindow(window()->GetNativeWindow(), gfx::Rect(), | 171 views::Window::CreateChromeWindow(window()->GetNativeWindow(), gfx::Rect(), |
171 edit_view); | 172 edit_view); |
172 edit_view->window()->Show(); | 173 edit_view->window()->Show(); |
173 } | 174 } |
174 | 175 |
175 void AutoFillProfilesView::DeleteClicked() { | 176 void AutoFillProfilesView::DeleteClicked() { |
176 DCHECK(scroll_view_); | |
177 DCHECK(table_model_.get()); | |
178 DCHECK_GT(scroll_view_->SelectedRowCount(), 0); | 177 DCHECK_GT(scroll_view_->SelectedRowCount(), 0); |
179 int last_view_row = -1; | 178 int last_view_row = -1; |
180 for (views::TableView::iterator i = scroll_view_->SelectionBegin(); | 179 for (views::TableView::iterator i = scroll_view_->SelectionBegin(); |
181 i != scroll_view_->SelectionEnd(); ++i) { | 180 i != scroll_view_->SelectionEnd(); ++i) { |
182 last_view_row = scroll_view_->ModelToView(*i); | 181 last_view_row = scroll_view_->ModelToView(*i); |
183 table_model_->RemoveItem(*i); | 182 table_model_->RemoveItem(*i); |
184 } | 183 } |
185 if (last_view_row >= table_model_->RowCount()) | 184 if (last_view_row >= table_model_->RowCount()) |
186 last_view_row = table_model_->RowCount() - 1; | 185 last_view_row = table_model_->RowCount() - 1; |
187 if (last_view_row >= 0) | 186 if (last_view_row >= 0) |
188 scroll_view_->Select(scroll_view_->ViewToModel(last_view_row)); | 187 scroll_view_->Select(scroll_view_->ViewToModel(last_view_row)); |
189 UpdateBillingModel(); | 188 UpdateBillingModel(); |
190 UpdateButtonState(); | 189 UpdateWidgetState(); |
191 } | 190 } |
192 | 191 |
193 void AutoFillProfilesView::UpdateButtonState() { | 192 void AutoFillProfilesView::UpdateWidgetState() { |
194 DCHECK(personal_data_manager_); | 193 bool autofill_enabled = enable_auto_fill_.GetValue(); |
195 DCHECK(scroll_view_); | 194 enable_auto_fill_button_->SetChecked(autofill_enabled); |
196 DCHECK(add_address_button_); | 195 enable_auto_fill_button_->SetEnabled(!enable_auto_fill_.IsManaged()); |
197 DCHECK(add_credit_card_button_); | |
198 DCHECK(edit_button_); | |
199 DCHECK(remove_button_); | |
200 bool autofill_enabled = preferences_->GetBoolean(prefs::kAutoFillEnabled); | |
201 scroll_view_->SetEnabled(autofill_enabled); | 196 scroll_view_->SetEnabled(autofill_enabled); |
202 add_address_button_->SetEnabled(personal_data_manager_->IsDataLoaded() && | 197 add_address_button_->SetEnabled(personal_data_manager_->IsDataLoaded() && |
203 !child_dialog_opened_ && autofill_enabled); | 198 !child_dialog_opened_ && autofill_enabled); |
204 add_credit_card_button_->SetEnabled(personal_data_manager_->IsDataLoaded() && | 199 add_credit_card_button_->SetEnabled(personal_data_manager_->IsDataLoaded() && |
205 !child_dialog_opened_ && | 200 !child_dialog_opened_ && |
206 autofill_enabled); | 201 autofill_enabled); |
207 | 202 |
208 int selected_row_count = scroll_view_->SelectedRowCount(); | 203 int selected_row_count = scroll_view_->SelectedRowCount(); |
209 edit_button_->SetEnabled(selected_row_count == 1 && !child_dialog_opened_ && | 204 edit_button_->SetEnabled(selected_row_count == 1 && !child_dialog_opened_ && |
210 autofill_enabled); | 205 autofill_enabled); |
211 remove_button_->SetEnabled(selected_row_count > 0 && !child_dialog_opened_ && | 206 remove_button_->SetEnabled(selected_row_count > 0 && !child_dialog_opened_ && |
212 autofill_enabled); | 207 autofill_enabled); |
213 } | 208 } |
214 | 209 |
215 void AutoFillProfilesView::UpdateProfileLabels() { | 210 void AutoFillProfilesView::UpdateProfileLabels() { |
216 std::vector<AutoFillProfile*> profiles; | 211 std::vector<AutoFillProfile*> profiles; |
217 profiles.resize(profiles_set_.size()); | 212 profiles.resize(profiles_set_.size()); |
218 for (size_t i = 0; i < profiles_set_.size(); ++i) { | 213 for (size_t i = 0; i < profiles_set_.size(); ++i) { |
219 profiles[i] = &(profiles_set_[i].address); | 214 profiles[i] = &(profiles_set_[i].address); |
220 } | 215 } |
221 AutoFillProfile::AdjustInferredLabels(&profiles); | 216 AutoFillProfile::AdjustInferredLabels(&profiles); |
222 } | 217 } |
223 | 218 |
224 void AutoFillProfilesView::UpdateBillingModel() { | 219 void AutoFillProfilesView::UpdateBillingModel() { |
225 billing_model_.SetAddressLabels(profiles_set_); | 220 billing_model_.SetAddressLabels(profiles_set_); |
226 } | 221 } |
227 | 222 |
228 void AutoFillProfilesView::ChildWindowOpened() { | 223 void AutoFillProfilesView::ChildWindowOpened() { |
229 child_dialog_opened_ = true; | 224 child_dialog_opened_ = true; |
230 UpdateButtonState(); | 225 UpdateWidgetState(); |
231 } | 226 } |
232 | 227 |
233 void AutoFillProfilesView::ChildWindowClosed() { | 228 void AutoFillProfilesView::ChildWindowClosed() { |
234 child_dialog_opened_ = false; | 229 child_dialog_opened_ = false; |
235 UpdateButtonState(); | 230 UpdateWidgetState(); |
236 } | 231 } |
237 | 232 |
238 SkBitmap* AutoFillProfilesView::GetWarningBitmap(bool good) { | 233 SkBitmap* AutoFillProfilesView::GetWarningBitmap(bool good) { |
239 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 234 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
240 return rb.GetBitmapNamed(good ? IDR_INPUT_GOOD : IDR_INPUT_ALERT); | 235 return rb.GetBitmapNamed(good ? IDR_INPUT_GOOD : IDR_INPUT_ALERT); |
241 } | 236 } |
242 | 237 |
243 | 238 |
244 ///////////////////////////////////////////////////////////////////////////// | 239 ///////////////////////////////////////////////////////////////////////////// |
245 // AutoFillProfilesView, views::View implementations | 240 // AutoFillProfilesView, views::View implementations |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 NOTREACHED(); | 306 NOTREACHED(); |
312 return false; | 307 return false; |
313 } | 308 } |
314 | 309 |
315 | 310 |
316 std::wstring AutoFillProfilesView::GetWindowTitle() const { | 311 std::wstring AutoFillProfilesView::GetWindowTitle() const { |
317 return l10n_util::GetString(IDS_AUTOFILL_OPTIONS_TITLE); | 312 return l10n_util::GetString(IDS_AUTOFILL_OPTIONS_TITLE); |
318 } | 313 } |
319 | 314 |
320 void AutoFillProfilesView::WindowClosing() { | 315 void AutoFillProfilesView::WindowClosing() { |
321 DCHECK(focus_manager_); | |
322 focus_manager_->RemoveFocusChangeListener(this); | 316 focus_manager_->RemoveFocusChangeListener(this); |
323 instance_ = NULL; | 317 instance_ = NULL; |
324 } | 318 } |
325 | 319 |
326 views::View* AutoFillProfilesView::GetContentsView() { | 320 views::View* AutoFillProfilesView::GetContentsView() { |
327 return this; | 321 return this; |
328 } | 322 } |
329 | 323 |
330 bool AutoFillProfilesView::Cancel() { | 324 bool AutoFillProfilesView::Cancel() { |
331 // No way to cancel - we save back all the info always. | 325 // No way to cancel - we save back all the info always. |
332 return Accept(); | 326 return Accept(); |
333 } | 327 } |
334 | 328 |
335 bool AutoFillProfilesView::Accept() { | 329 bool AutoFillProfilesView::Accept() { |
336 DCHECK(observer_); | |
337 std::vector<AutoFillProfile> profiles; | 330 std::vector<AutoFillProfile> profiles; |
338 profiles.reserve(profiles_set_.size()); | 331 profiles.reserve(profiles_set_.size()); |
339 std::vector<EditableSetInfo>::iterator it; | 332 std::vector<EditableSetInfo>::iterator it; |
340 for (it = profiles_set_.begin(); it != profiles_set_.end(); ++it) { | 333 for (it = profiles_set_.begin(); it != profiles_set_.end(); ++it) { |
341 profiles.push_back(it->address); | 334 profiles.push_back(it->address); |
342 } | 335 } |
343 std::vector<CreditCard> credit_cards; | 336 std::vector<CreditCard> credit_cards; |
344 credit_cards.reserve(credit_card_set_.size()); | 337 credit_cards.reserve(credit_card_set_.size()); |
345 for (it = credit_card_set_.begin(); it != credit_card_set_.end(); ++it) { | 338 for (it = credit_card_set_.begin(); it != credit_card_set_.end(); ++it) { |
346 credit_cards.push_back(it->credit_card); | 339 credit_cards.push_back(it->credit_card); |
347 } | 340 } |
348 DCHECK(preferences_); | |
349 observer_->OnAutoFillDialogApply(&profiles, &credit_cards); | 341 observer_->OnAutoFillDialogApply(&profiles, &credit_cards); |
350 return true; | 342 return true; |
351 } | 343 } |
352 | 344 |
353 ///////////////////////////////////////////////////////////////////////////// | 345 ///////////////////////////////////////////////////////////////////////////// |
354 // AutoFillProfilesView, views::ButtonListener implementations: | 346 // AutoFillProfilesView, views::ButtonListener implementations: |
355 void AutoFillProfilesView::ButtonPressed(views::Button* sender, | 347 void AutoFillProfilesView::ButtonPressed(views::Button* sender, |
356 const views::Event& event) { | 348 const views::Event& event) { |
357 if (sender == add_address_button_) { | 349 if (sender == add_address_button_) { |
358 AddClicked(ContentListTableModel::kAddressGroup); | 350 AddClicked(ContentListTableModel::kAddressGroup); |
359 } else if (sender == add_credit_card_button_) { | 351 } else if (sender == add_credit_card_button_) { |
360 AddClicked(ContentListTableModel::kCreditCardGroup); | 352 AddClicked(ContentListTableModel::kCreditCardGroup); |
361 } else if (sender == edit_button_) { | 353 } else if (sender == edit_button_) { |
362 EditClicked(); | 354 EditClicked(); |
363 } else if (sender == remove_button_) { | 355 } else if (sender == remove_button_) { |
364 DeleteClicked(); | 356 DeleteClicked(); |
365 } else if (sender == enable_auto_fill_button_) { | 357 } else if (sender == enable_auto_fill_button_) { |
366 bool enabled = enable_auto_fill_button_->checked(); | 358 bool enabled = enable_auto_fill_button_->checked(); |
367 UserMetricsAction action(enabled ? "Options_FormAutofill_Enable" : | 359 UserMetricsAction action(enabled ? "Options_FormAutofill_Enable" : |
368 "Options_FormAutofill_Disable"); | 360 "Options_FormAutofill_Disable"); |
369 UserMetrics::RecordAction(action, profile_); | 361 UserMetrics::RecordAction(action, profile_); |
370 preferences_->SetBoolean(prefs::kAutoFillEnabled, enabled); | 362 enable_auto_fill_.SetValueIfNotManaged(enabled); |
371 preferences_->ScheduleSavePersistentPrefs(); | 363 preferences_->ScheduleSavePersistentPrefs(); |
372 UpdateButtonState(); | 364 UpdateWidgetState(); |
373 } | 365 } |
374 } | 366 } |
375 | 367 |
376 ///////////////////////////////////////////////////////////////////////////// | 368 ///////////////////////////////////////////////////////////////////////////// |
377 // AutoFillProfilesView, views::LinkController implementations: | 369 // AutoFillProfilesView, views::LinkController implementations: |
378 void AutoFillProfilesView::LinkActivated(views::Link* source, int event_flags) { | 370 void AutoFillProfilesView::LinkActivated(views::Link* source, int event_flags) { |
379 Browser* browser = BrowserList::GetLastActive(); | 371 Browser* browser = BrowserList::GetLastActive(); |
380 browser->OpenURL(GURL(kAutoFillLearnMoreUrl), GURL(), NEW_FOREGROUND_TAB, | 372 browser->OpenURL(GURL(kAutoFillLearnMoreUrl), GURL(), NEW_FOREGROUND_TAB, |
381 PageTransition::TYPED); | 373 PageTransition::TYPED); |
382 } | 374 } |
383 | 375 |
384 | 376 |
385 ///////////////////////////////////////////////////////////////////////////// | 377 ///////////////////////////////////////////////////////////////////////////// |
386 // AutoFillProfilesView, views::FocusChangeListener implementations: | 378 // AutoFillProfilesView, views::FocusChangeListener implementations: |
387 void AutoFillProfilesView::FocusWillChange(views::View* focused_before, | 379 void AutoFillProfilesView::FocusWillChange(views::View* focused_before, |
388 views::View* focused_now) { | 380 views::View* focused_now) { |
389 if (focused_now) { | 381 if (focused_now) { |
390 focused_now->ScrollRectToVisible(gfx::Rect(focused_now->width(), | 382 focused_now->ScrollRectToVisible(gfx::Rect(focused_now->width(), |
391 focused_now->height())); | 383 focused_now->height())); |
392 } | 384 } |
393 } | 385 } |
394 | 386 |
395 ///////////////////////////////////////////////////////////////////////////// | 387 ///////////////////////////////////////////////////////////////////////////// |
396 // AutoFillProfilesView, views::TableViewObserver implementations: | 388 // AutoFillProfilesView, views::TableViewObserver implementations: |
397 void AutoFillProfilesView::OnSelectionChanged() { | 389 void AutoFillProfilesView::OnSelectionChanged() { |
398 UpdateButtonState(); | 390 UpdateWidgetState(); |
399 } | 391 } |
400 | 392 |
401 void AutoFillProfilesView::OnDoubleClick() { | 393 void AutoFillProfilesView::OnDoubleClick() { |
402 if (!child_dialog_opened_) | 394 if (!child_dialog_opened_) |
403 EditClicked(); | 395 EditClicked(); |
404 } | 396 } |
405 | 397 |
406 | 398 |
407 ///////////////////////////////////////////////////////////////////////////// | 399 ///////////////////////////////////////////////////////////////////////////// |
408 // AutoFillProfilesView, PersonalDataManager::Observer implementation. | 400 // AutoFillProfilesView, PersonalDataManager::Observer implementation. |
409 void AutoFillProfilesView::OnPersonalDataLoaded() { | 401 void AutoFillProfilesView::OnPersonalDataLoaded() { |
410 personal_data_manager_->RemoveObserver(this); | 402 personal_data_manager_->RemoveObserver(this); |
411 GetData(); | 403 GetData(); |
412 } | 404 } |
413 | 405 |
414 ///////////////////////////////////////////////////////////////////////////// | 406 ///////////////////////////////////////////////////////////////////////////// |
| 407 // AutoFillProfilesView, NotificationObserver implementation. |
| 408 void AutoFillProfilesView::Observe(NotificationType type, |
| 409 const NotificationSource& source, |
| 410 const NotificationDetails& details) { |
| 411 DCHECK_EQ(NotificationType::PREF_CHANGED, type.value); |
| 412 const std::string* pref_name = Details<std::string>(details).ptr(); |
| 413 if (!pref_name || *pref_name == prefs::kAutoFillEnabled) |
| 414 UpdateWidgetState(); |
| 415 } |
| 416 |
| 417 ///////////////////////////////////////////////////////////////////////////// |
415 // AutoFillProfilesView, private: | 418 // AutoFillProfilesView, private: |
416 void AutoFillProfilesView::Init() { | 419 void AutoFillProfilesView::Init() { |
417 GetData(); | 420 GetData(); |
418 | 421 |
419 enable_auto_fill_button_ = new views::Checkbox( | 422 enable_auto_fill_button_ = new views::Checkbox( |
420 l10n_util::GetString(IDS_OPTIONS_AUTOFILL_ENABLE)); | 423 l10n_util::GetString(IDS_OPTIONS_AUTOFILL_ENABLE)); |
421 enable_auto_fill_button_->set_listener(this); | 424 enable_auto_fill_button_->set_listener(this); |
422 enable_auto_fill_button_->SetChecked( | |
423 preferences_->GetBoolean(prefs::kAutoFillEnabled)); | |
424 | 425 |
425 billing_model_.SetAddressLabels(profiles_set_); | 426 billing_model_.SetAddressLabels(profiles_set_); |
426 | 427 |
427 table_model_.reset(new ContentListTableModel(&profiles_set_, | 428 table_model_.reset(new ContentListTableModel(&profiles_set_, |
428 &credit_card_set_)); | 429 &credit_card_set_)); |
429 std::vector<TableColumn> columns; | 430 std::vector<TableColumn> columns; |
430 columns.push_back(TableColumn()); | 431 columns.push_back(TableColumn()); |
431 scroll_view_ = new views::TableView(table_model_.get(), columns, | 432 scroll_view_ = new views::TableView(table_model_.get(), columns, |
432 views::TEXT_ONLY, false, true, true); | 433 views::TEXT_ONLY, false, true, true); |
433 scroll_view_->SetObserver(this); | 434 scroll_view_->SetObserver(this); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 476 |
476 layout->StartRowWithPadding(0, table_with_buttons_column_view_set_id, 0, | 477 layout->StartRowWithPadding(0, table_with_buttons_column_view_set_id, 0, |
477 kRelatedControlVerticalSpacing); | 478 kRelatedControlVerticalSpacing); |
478 layout->SkipColumns(2); | 479 layout->SkipColumns(2); |
479 layout->AddView(remove_button_); | 480 layout->AddView(remove_button_); |
480 | 481 |
481 layout->AddPaddingRow(1, table_with_buttons_column_view_set_id); | 482 layout->AddPaddingRow(1, table_with_buttons_column_view_set_id); |
482 | 483 |
483 | 484 |
484 focus_manager_ = GetFocusManager(); | 485 focus_manager_ = GetFocusManager(); |
485 DCHECK(focus_manager_); | |
486 focus_manager_->AddFocusChangeListener(this); | 486 focus_manager_->AddFocusChangeListener(this); |
487 | 487 |
488 UpdateButtonState(); | 488 UpdateWidgetState(); |
489 } | 489 } |
490 | 490 |
491 void AutoFillProfilesView::GetData() { | 491 void AutoFillProfilesView::GetData() { |
492 if (!personal_data_manager_->IsDataLoaded()) { | 492 if (!personal_data_manager_->IsDataLoaded()) { |
493 personal_data_manager_->SetObserver(this); | 493 personal_data_manager_->SetObserver(this); |
494 return; | 494 return; |
495 } | 495 } |
496 bool imported_data_present = !profiles_set_.empty() || | 496 bool imported_data_present = !profiles_set_.empty() || |
497 !credit_card_set_.empty(); | 497 !credit_card_set_.empty(); |
498 if (!imported_data_present) { | 498 if (!imported_data_present) { |
(...skipping 14 matching lines...) Expand all Loading... |
513 cc_it != personal_data_manager_->credit_cards().end(); | 513 cc_it != personal_data_manager_->credit_cards().end(); |
514 ++cc_it) { | 514 ++cc_it) { |
515 credit_card_set_.push_back(EditableSetInfo(*cc_it)); | 515 credit_card_set_.push_back(EditableSetInfo(*cc_it)); |
516 } | 516 } |
517 } | 517 } |
518 if (table_model_.get()) | 518 if (table_model_.get()) |
519 table_model_->Refresh(); | 519 table_model_->Refresh(); |
520 | 520 |
521 // Update state only if buttons already created. | 521 // Update state only if buttons already created. |
522 if (add_address_button_) { | 522 if (add_address_button_) { |
523 UpdateButtonState(); | 523 UpdateWidgetState(); |
524 } | 524 } |
525 } | 525 } |
526 | 526 |
527 bool AutoFillProfilesView::IsDataReady() const { | 527 bool AutoFillProfilesView::IsDataReady() const { |
528 return personal_data_manager_->IsDataLoaded(); | 528 return personal_data_manager_->IsDataLoaded(); |
529 } | 529 } |
530 | 530 |
531 ///////////////////////////////////////////////////////////////////////////// | 531 ///////////////////////////////////////////////////////////////////////////// |
532 // AutoFillProfilesView::PhoneSubView, public: | 532 // AutoFillProfilesView::PhoneSubView, public: |
533 AutoFillProfilesView::PhoneSubView::PhoneSubView( | 533 AutoFillProfilesView::PhoneSubView::PhoneSubView( |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 AutoFillDialogObserver* observer, | 1396 AutoFillDialogObserver* observer, |
1397 Profile* profile) { | 1397 Profile* profile) { |
1398 DCHECK(profile); | 1398 DCHECK(profile); |
1399 | 1399 |
1400 PersonalDataManager* personal_data_manager = | 1400 PersonalDataManager* personal_data_manager = |
1401 profile->GetPersonalDataManager(); | 1401 profile->GetPersonalDataManager(); |
1402 DCHECK(personal_data_manager); | 1402 DCHECK(personal_data_manager); |
1403 AutoFillProfilesView::Show(parent, observer, personal_data_manager, profile, | 1403 AutoFillProfilesView::Show(parent, observer, personal_data_manager, profile, |
1404 profile->GetPrefs(), NULL, NULL); | 1404 profile->GetPrefs(), NULL, NULL); |
1405 } | 1405 } |
OLD | NEW |