Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: chrome/browser/views/select_profile_dialog.cc

Issue 113991: Make Combobox portable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/views/select_profile_dialog.h ('k') | views/controls/combo_box.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/select_profile_dialog.h" 5 #include "chrome/browser/views/select_profile_dialog.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "chrome/browser/user_data_manager.h" 12 #include "chrome/browser/user_data_manager.h"
13 #include "chrome/browser/views/new_profile_dialog.h" 13 #include "chrome/browser/views/new_profile_dialog.h"
14 #include "grit/chromium_strings.h" 14 #include "grit/chromium_strings.h"
15 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
16 #include "grit/locale_settings.h" 16 #include "grit/locale_settings.h"
17 #include "views/controls/combo_box.h"
18 #include "views/controls/label.h" 17 #include "views/controls/label.h"
19 #include "views/controls/message_box_view.h" 18 #include "views/controls/message_box_view.h"
20 #include "views/grid_layout.h" 19 #include "views/grid_layout.h"
21 #include "views/standard_layout.h" 20 #include "views/standard_layout.h"
22 #include "views/view.h" 21 #include "views/view.h"
23 #include "views/window/window.h" 22 #include "views/window/window.h"
24 23
25 using views::ColumnSet; 24 using views::ColumnSet;
26 using views::GridLayout; 25 using views::GridLayout;
27 26
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 76
78 views::View* SelectProfileDialog::GetInitiallyFocusedView() { 77 views::View* SelectProfileDialog::GetInitiallyFocusedView() {
79 return profile_combobox_; 78 return profile_combobox_;
80 } 79 }
81 80
82 std::wstring SelectProfileDialog::GetWindowTitle() const { 81 std::wstring SelectProfileDialog::GetWindowTitle() const {
83 return l10n_util::GetString(IDS_SELECT_PROFILE_DIALOG_TITLE); 82 return l10n_util::GetString(IDS_SELECT_PROFILE_DIALOG_TITLE);
84 } 83 }
85 84
86 bool SelectProfileDialog::Accept() { 85 bool SelectProfileDialog::Accept() {
87 int index = profile_combobox_->GetSelectedItem(); 86 int index = profile_combobox_->selected_item();
88 if (index < 0) { 87 if (index < 0) {
89 NOTREACHED(); 88 NOTREACHED();
90 return true; 89 return true;
91 } 90 }
92 91
93 // If the user has selected <New Profile> from the drop down, then show the 92 // If the user has selected <New Profile> from the drop down, then show the
94 // new profile dialog to the user. 93 // new profile dialog to the user.
95 if (index == profiles_.size()) { 94 if (index == profiles_.size()) {
96 NewProfileDialog::RunDialog(); 95 NewProfileDialog::RunDialog();
97 return true; 96 return true;
98 } 97 }
99 98
100 std::wstring profile_name = profiles_[index]; 99 std::wstring profile_name = profiles_[index];
101 UserDataManager::Get()->LaunchChromeForProfile(profile_name); 100 UserDataManager::Get()->LaunchChromeForProfile(profile_name);
102 return true; 101 return true;
103 } 102 }
104 103
105 bool SelectProfileDialog::Cancel() { 104 bool SelectProfileDialog::Cancel() {
106 return true; 105 return true;
107 } 106 }
108 107
109 views::View* SelectProfileDialog::GetContentsView() { 108 views::View* SelectProfileDialog::GetContentsView() {
110 return this; 109 return this;
111 } 110 }
112 111
113 int SelectProfileDialog::GetItemCount(views::ComboBox* source) { 112 int SelectProfileDialog::GetItemCount(views::Combobox* source) {
114 // Always show one more item in the combo box that allows the user to select 113 // Always show one more item in the combo box that allows the user to select
115 // <New Profile>. 114 // <New Profile>.
116 return profiles_.size() + 1; 115 return profiles_.size() + 1;
117 } 116 }
118 117
119 std::wstring SelectProfileDialog::GetItemAt(views::ComboBox* source, 118 std::wstring SelectProfileDialog::GetItemAt(views::Combobox* source,
120 int index) { 119 int index) {
121 DCHECK(source == profile_combobox_); 120 DCHECK(source == profile_combobox_);
122 DCHECK(index >= 0 && index <= static_cast<int>(profiles_.size())); 121 DCHECK(index >= 0 && index <= static_cast<int>(profiles_.size()));
123 // For the last item in the drop down, return the <New Profile> text, 122 // For the last item in the drop down, return the <New Profile> text,
124 // otherwise return the corresponding profile name from the vector. 123 // otherwise return the corresponding profile name from the vector.
125 return index == profiles_.size() ? 124 return index == profiles_.size() ?
126 l10n_util::GetString(IDS_SELECT_PROFILE_DIALOG_NEW_PROFILE_ENTRY) : 125 l10n_util::GetString(IDS_SELECT_PROFILE_DIALOG_NEW_PROFILE_ENTRY) :
127 profiles_[index]; 126 profiles_[index];
128 } 127 }
129 128
130 void SelectProfileDialog::OnGetProfilesDone( 129 void SelectProfileDialog::OnGetProfilesDone(
131 const std::vector<std::wstring>& profiles) { 130 const std::vector<std::wstring>& profiles) {
132 PopulateProfilesComboBox(profiles); 131 PopulateProfilesComboBox(profiles);
133 } 132 }
134 133
135 void SelectProfileDialog::SetupControls() { 134 void SelectProfileDialog::SetupControls() {
136 // Adds all controls. 135 // Adds all controls.
137 select_profile_label_ = new views::Label( 136 select_profile_label_ = new views::Label(
138 l10n_util::GetString(IDS_SELECT_PROFILE_DIALOG_LABEL_TEXT)); 137 l10n_util::GetString(IDS_SELECT_PROFILE_DIALOG_LABEL_TEXT));
139 profile_combobox_ = new views::ComboBox(this); 138 profile_combobox_ = new views::Combobox(this);
140 139
141 // Arranges controls by using GridLayout. 140 // Arranges controls by using GridLayout.
142 const int column_set_id = 0; 141 const int column_set_id = 0;
143 GridLayout* layout = CreatePanelGridLayout(this); 142 GridLayout* layout = CreatePanelGridLayout(this);
144 SetLayoutManager(layout); 143 SetLayoutManager(layout);
145 ColumnSet* column_set = layout->AddColumnSet(column_set_id); 144 ColumnSet* column_set = layout->AddColumnSet(column_set_id);
146 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 145 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
147 GridLayout::USE_PREF, 0, 0); 146 GridLayout::USE_PREF, 0, 0);
148 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); 147 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
149 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, 148 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0,
150 GridLayout::FIXED, 200, 0); 149 GridLayout::FIXED, 200, 0);
151 150
152 layout->StartRow(0, column_set_id); 151 layout->StartRow(0, column_set_id);
153 layout->AddView(select_profile_label_); 152 layout->AddView(select_profile_label_);
154 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 153 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
155 layout->StartRow(0, column_set_id); 154 layout->StartRow(0, column_set_id);
156 layout->AddView(profile_combobox_); 155 layout->AddView(profile_combobox_);
157 } 156 }
OLDNEW
« no previous file with comments | « chrome/browser/views/select_profile_dialog.h ('k') | views/controls/combo_box.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698