diff options
author | brg@chromium.com <brg@chromium.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-04 19:54:49 +0000 |
---|---|---|
committer | brg@chromium.com <brg@chromium.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-04 19:54:49 +0000 |
commit | fbe8c251fa3252c95bc62ba61854a530aad1889f (patch) | |
tree | 99796a806a831a18227d423e4f4f6d847465156a /chrome/browser/views/importer_view.cc | |
parent | cd378ab1cd7da8fa26d99826e63f5a0981eb457d (diff) | |
download | chromium_src-fbe8c251fa3252c95bc62ba61854a530aad1889f.zip chromium_src-fbe8c251fa3252c95bc62ba61854a530aad1889f.tar.gz chromium_src-fbe8c251fa3252c95bc62ba61854a530aad1889f.tar.bz2 |
Toolbar Import - Issue 8801, migrated from public tree to svn enlistment.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4633 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/importer_view.cc')
-rw-r--r-- | chrome/browser/views/importer_view.cc | 114 |
1 files changed, 103 insertions, 11 deletions
diff --git a/chrome/browser/views/importer_view.cc b/chrome/browser/views/importer_view.cc index eedce0b..3d9e93f 100644 --- a/chrome/browser/views/importer_view.cc +++ b/chrome/browser/views/importer_view.cc @@ -41,6 +41,7 @@ void ImporterView::SetupControl() { new views::Label(l10n_util::GetString(IDS_IMPORT_FROM_LABEL)); profile_combobox_ = new views::ComboBox(this); + profile_combobox_->SetListener(this); import_items_label_ = new views::Label(l10n_util::GetString(IDS_IMPORT_ITEMS_LABEL)); @@ -120,16 +121,7 @@ bool ImporterView::Accept() { return false; } - uint16 items = NONE; - if (history_checkbox_->IsEnabled() && history_checkbox_->IsSelected()) - items |= HISTORY; - if (favorites_checkbox_->IsEnabled() && favorites_checkbox_->IsSelected()) - items |= FAVORITES; - if (passwords_checkbox_->IsEnabled() && passwords_checkbox_->IsSelected()) - items |= PASSWORDS; - if (search_engines_checkbox_->IsEnabled() && - search_engines_checkbox_->IsSelected()) - items |= SEARCH_ENGINES; + uint16 items = GetCheckedItems(); Browser* browser = BrowserList::GetLastActive(); int selected_index = profile_combobox_->GetSelectedItem(); @@ -149,7 +141,10 @@ views::View* ImporterView::GetContentsView() { int ImporterView::GetItemCount(views::ComboBox* source) { DCHECK(source == profile_combobox_); DCHECK(importer_host_.get()); - return importer_host_->GetAvailableProfileCount(); + int item_count = importer_host_->GetAvailableProfileCount(); + if (checkbox_items_.size() < static_cast<size_t>(item_count)) + checkbox_items_.resize(item_count, ALL); + return item_count; } std::wstring ImporterView::GetItemAt(views::ComboBox* source, int index) { @@ -158,6 +153,29 @@ std::wstring ImporterView::GetItemAt(views::ComboBox* source, int index) { return importer_host_->GetSourceProfileNameAt(index); } +void ImporterView::ItemChanged(views::ComboBox* combo_box, + int prev_index, int new_index) { + DCHECK(combo_box); + DCHECK(checkbox_items_.size() >= + static_cast<size_t>(importer_host_->GetAvailableProfileCount())); + + if (prev_index == new_index) + return; + + // Save the current state + uint16 prev_items = GetCheckedItems(); + checkbox_items_[prev_index] = prev_items; + + // Enable/Disable the checkboxes for this Item + uint16 new_enabled_items = importer_host_->GetSourceProfileInfoAt( + new_index).services_supported; + SetCheckedItemsState(new_enabled_items); + + // Set the checked items for this Item + uint16 new_items = checkbox_items_[new_index]; + SetCheckedItems(new_items); +} + void ImporterView::ImportCanceled() { ImportComplete(); } @@ -174,3 +192,77 @@ views::CheckBox* ImporterView::InitCheckbox(const std::wstring& text, return checkbox; } +uint16 ImporterView::GetCheckedItems() { + uint16 items = NONE; + if (history_checkbox_->IsEnabled() && history_checkbox_->IsSelected()) + items |= HISTORY; + if (favorites_checkbox_->IsEnabled() && favorites_checkbox_->IsSelected()) + items |= FAVORITES; + if (passwords_checkbox_->IsEnabled() && passwords_checkbox_->IsSelected()) + items |= PASSWORDS; + if (search_engines_checkbox_->IsEnabled() && + search_engines_checkbox_->IsSelected()) + items |= SEARCH_ENGINES; + return items; +} + +void ImporterView::SetCheckedItemsState(uint16 items) { + if (items & HISTORY) { + history_checkbox_->SetEnabled(true); + } else { + history_checkbox_->SetEnabled(false); + history_checkbox_->SetIsSelected(false); + } + if (items & FAVORITES) { + favorites_checkbox_->SetEnabled(true); + } else { + favorites_checkbox_->SetEnabled(false); + favorites_checkbox_->SetIsSelected(false); + } + if (items & PASSWORDS) { + passwords_checkbox_->SetEnabled(true); + } else { + passwords_checkbox_->SetEnabled(false); + passwords_checkbox_->SetIsSelected(false); + } + if (items & SEARCH_ENGINES) { + search_engines_checkbox_->SetEnabled(true); + } else { + search_engines_checkbox_->SetEnabled(false); + search_engines_checkbox_->SetIsSelected(false); + } +} + +void ImporterView::SetCheckedItems(uint16 items) { + if (history_checkbox_->IsEnabled()) { + if (items & HISTORY) { + history_checkbox_->SetIsSelected(true); + } else { + history_checkbox_->SetIsSelected(false); + } + } + + if (favorites_checkbox_->IsEnabled()) { + if (items & FAVORITES) { + favorites_checkbox_->SetIsSelected(true); + } else { + favorites_checkbox_->SetIsSelected(false); + } + } + + if (passwords_checkbox_->IsEnabled()) { + if (items & PASSWORDS) { + passwords_checkbox_->SetIsSelected(true); + } else { + passwords_checkbox_->SetIsSelected(false); + } + } + + if (search_engines_checkbox_->IsEnabled()) { + if (items & SEARCH_ENGINES) { + search_engines_checkbox_->SetIsSelected(true); + } else { + search_engines_checkbox_->SetIsSelected(false); + } + } +} |