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

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

Issue 2253001: Revert 48186, 48196, 48198 (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 7 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
« no previous file with comments | « chrome/browser/sync/syncable/syncable.cc ('k') | chrome/installer/util/l10n_string_util.cc » ('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) 2010 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"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 views::View* SelectProfileDialog::GetInitiallyFocusedView() { 77 views::View* SelectProfileDialog::GetInitiallyFocusedView() {
78 return profile_combobox_; 78 return profile_combobox_;
79 } 79 }
80 80
81 std::wstring SelectProfileDialog::GetWindowTitle() const { 81 std::wstring SelectProfileDialog::GetWindowTitle() const {
82 return l10n_util::GetString(IDS_SELECT_PROFILE_DIALOG_TITLE); 82 return l10n_util::GetString(IDS_SELECT_PROFILE_DIALOG_TITLE);
83 } 83 }
84 84
85 bool SelectProfileDialog::Accept() { 85 bool SelectProfileDialog::Accept() {
86 size_t index = profile_combobox_->selected_item(); 86 int index = profile_combobox_->selected_item();
87 if (index > profiles_.size()) { 87 if (index < 0) {
88 NOTREACHED(); 88 NOTREACHED();
89 return true; 89 return true;
90 } 90 }
91 91
92 // 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
93 // new profile dialog to the user. 93 // new profile dialog to the user.
94 if (index == profiles_.size()) { 94 if (index == profiles_.size()) {
95 NewProfileDialog::RunDialog(); 95 NewProfileDialog::RunDialog();
96 } else { 96 return true;
97 std::wstring profile_name = profiles_[index];
98 UserDataManager::Get()->LaunchChromeForProfile(profile_name);
99 } 97 }
98
99 std::wstring profile_name = profiles_[index];
100 UserDataManager::Get()->LaunchChromeForProfile(profile_name);
100 return true; 101 return true;
101 } 102 }
102 103
103 bool SelectProfileDialog::Cancel() { 104 bool SelectProfileDialog::Cancel() {
104 return true; 105 return true;
105 } 106 }
106 107
107 views::View* SelectProfileDialog::GetContentsView() { 108 views::View* SelectProfileDialog::GetContentsView() {
108 return this; 109 return this;
109 } 110 }
110 111
111 int SelectProfileDialog::GetItemCount() { 112 int SelectProfileDialog::GetItemCount() {
112 // 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
113 // <New Profile>. 114 // <New Profile>.
114 return profiles_.size() + 1; 115 return profiles_.size() + 1;
115 } 116 }
116 117
117 std::wstring SelectProfileDialog::GetItemAt(int index) { 118 std::wstring SelectProfileDialog::GetItemAt(int index) {
118 size_t index_size_t = index; 119 DCHECK(index >= 0 && index <= static_cast<int>(profiles_.size()));
119 DCHECK_LE(index_size_t, profiles_.size());
120 // For the last item in the drop down, return the <New Profile> text, 120 // For the last item in the drop down, return the <New Profile> text,
121 // otherwise return the corresponding profile name from the vector. 121 // otherwise return the corresponding profile name from the vector.
122 return index_size_t == profiles_.size() ? 122 return index == profiles_.size() ?
123 l10n_util::GetString(IDS_SELECT_PROFILE_DIALOG_NEW_PROFILE_ENTRY) : 123 l10n_util::GetString(IDS_SELECT_PROFILE_DIALOG_NEW_PROFILE_ENTRY) :
124 profiles_[index]; 124 profiles_[index];
125 } 125 }
126 126
127 void SelectProfileDialog::OnGetProfilesDone( 127 void SelectProfileDialog::OnGetProfilesDone(
128 const std::vector<std::wstring>& profiles) { 128 const std::vector<std::wstring>& profiles) {
129 PopulateProfilesComboBox(profiles); 129 PopulateProfilesComboBox(profiles);
130 } 130 }
131 131
132 void SelectProfileDialog::SetupControls() { 132 void SelectProfileDialog::SetupControls() {
(...skipping 12 matching lines...) Expand all
145 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); 145 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
146 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, 146 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0,
147 GridLayout::FIXED, 200, 0); 147 GridLayout::FIXED, 200, 0);
148 148
149 layout->StartRow(0, column_set_id); 149 layout->StartRow(0, column_set_id);
150 layout->AddView(select_profile_label_); 150 layout->AddView(select_profile_label_);
151 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 151 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
152 layout->StartRow(0, column_set_id); 152 layout->StartRow(0, column_set_id);
153 layout->AddView(profile_combobox_); 153 layout->AddView(profile_combobox_);
154 } 154 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/syncable/syncable.cc ('k') | chrome/installer/util/l10n_string_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698