Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/views/passwords/manage_passwords_bubble_view.h" | 5 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
| 10 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 10 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
| 11 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 11 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
| 12 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 12 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
| 13 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" | 13 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" |
| 14 #include "chrome/browser/ui/views/frame/browser_view.h" | 14 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 16 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" | |
| 16 #include "chrome/browser/ui/views/passwords/manage_password_item_view.h" | 17 #include "chrome/browser/ui/views/passwords/manage_password_item_view.h" |
| 17 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" | 18 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" |
| 18 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
| 19 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
| 20 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
| 21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
| 25 #include "ui/views/controls/button/blue_button.h" | 26 #include "ui/views/controls/button/blue_button.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 return; | 165 return; |
| 165 content::WebContents* bubble_web_contents = | 166 content::WebContents* bubble_web_contents = |
| 166 ManagePasswordsBubbleView::manage_password_bubble()->web_contents(); | 167 ManagePasswordsBubbleView::manage_password_bubble()->web_contents(); |
| 167 if (web_contents == bubble_web_contents) | 168 if (web_contents == bubble_web_contents) |
| 168 ManagePasswordsBubbleView::CloseBubble(); | 169 ManagePasswordsBubbleView::CloseBubble(); |
| 169 } | 170 } |
| 170 | 171 |
| 171 } // namespace chrome | 172 } // namespace chrome |
| 172 | 173 |
| 173 | 174 |
| 175 // ManagePasswordsBubbleView::AccountChooserView ------------------------------ | |
| 176 | |
| 177 // A view offering the user the ability to save credentials. Contains a | |
| 178 // single ManagePasswordItemView, along with a "Save Passwords" button | |
| 179 // and a rejection combobox. ------------------------------------- | |
|
Mike West
2014/11/13 10:06:26
Nit: drop the ----- from this line.
vasilii
2014/11/13 12:00:19
The whole comment was pure copy-paste.
| |
| 180 class ManagePasswordsBubbleView::AccountChooserView | |
| 181 : public views::View, | |
| 182 public views::ButtonListener { | |
| 183 public: | |
| 184 explicit AccountChooserView(ManagePasswordsBubbleView* parent); | |
| 185 ~AccountChooserView() override; | |
| 186 | |
| 187 private: | |
| 188 // views::ButtonListener: | |
| 189 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | |
| 190 | |
| 191 ManagePasswordsBubbleView* parent_; | |
| 192 views::LabelButton* cancel_button_; | |
| 193 }; | |
| 194 | |
| 195 ManagePasswordsBubbleView::AccountChooserView::AccountChooserView( | |
| 196 ManagePasswordsBubbleView* parent) | |
| 197 : parent_(parent) { | |
| 198 views::GridLayout* layout = new views::GridLayout(this); | |
| 199 SetLayoutManager(layout); | |
| 200 | |
| 201 cancel_button_ = | |
| 202 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_CANCEL)); | |
| 203 cancel_button_->SetStyle(views::Button::STYLE_BUTTON); | |
| 204 cancel_button_->SetFontList( | |
| 205 ui::ResourceBundle::GetSharedInstance().GetFontList( | |
| 206 ui::ResourceBundle::SmallFont)); | |
| 207 | |
| 208 // Title row. | |
| 209 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | |
| 210 AddTitleRow(layout, parent_->model()); | |
| 211 | |
| 212 for (int i = 0; i < 2; ++i) { | |
| 213 base::string16 name = | |
| 214 l10n_util::GetStringFUTF16Int(IDS_NUMBERED_PROFILE_NAME, i); | |
|
Mike West
2014/11/13 10:06:26
This doesn't seem robust. Is this going to crash i
vasilii
2014/11/13 12:00:19
It just reads the string "User $1" from the resour
| |
| 215 CredentialsItemView* credential_view = new CredentialsItemView(this, name); | |
| 216 // Add the title to the layout with appropriate padding. | |
| 217 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | |
| 218 layout->AddView(credential_view); | |
|
Mike West
2014/11/13 10:06:26
Where do you plan to handle clicks on individual c
vasilii
2014/11/13 12:00:19
That's a good question. For consistency with other
| |
| 219 } | |
| 220 | |
| 221 // Button row. | |
| 222 BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET); | |
| 223 layout->StartRowWithPadding( | |
| 224 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); | |
| 225 layout->AddView(cancel_button_); | |
| 226 | |
| 227 // Extra padding for visual awesomeness. | |
| 228 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | |
| 229 | |
| 230 parent_->set_initially_focused_view(cancel_button_); | |
| 231 } | |
| 232 | |
| 233 ManagePasswordsBubbleView::AccountChooserView::~AccountChooserView() { | |
| 234 } | |
| 235 | |
| 236 void ManagePasswordsBubbleView::AccountChooserView::ButtonPressed( | |
| 237 views::Button* sender, const ui::Event& event) { | |
| 238 parent_->Close(); | |
| 239 } | |
| 240 | |
| 174 // ManagePasswordsBubbleView::PendingView ------------------------------------- | 241 // ManagePasswordsBubbleView::PendingView ------------------------------------- |
| 175 | 242 |
| 176 // A view offering the user the ability to save credentials. Contains a | 243 // A view offering the user the ability to save credentials. Contains a |
| 177 // single ManagePasswordItemView, along with a "Save Passwords" button | 244 // single ManagePasswordItemView, along with a "Save Passwords" button |
| 178 // and a rejection combobox. | 245 // and a rejection combobox. |
| 179 class ManagePasswordsBubbleView::PendingView : public views::View, | 246 class ManagePasswordsBubbleView::PendingView : public views::View, |
| 180 public views::ButtonListener, | 247 public views::ButtonListener, |
| 181 public views::ComboboxListener { | 248 public views::ComboboxListener { |
| 182 public: | 249 public: |
| 183 explicit PendingView(ManagePasswordsBubbleView* parent); | 250 explicit PendingView(ManagePasswordsBubbleView* parent); |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 864 } | 931 } |
| 865 | 932 |
| 866 void ManagePasswordsBubbleView::Observe( | 933 void ManagePasswordsBubbleView::Observe( |
| 867 int type, | 934 int type, |
| 868 const content::NotificationSource& source, | 935 const content::NotificationSource& source, |
| 869 const content::NotificationDetails& details) { | 936 const content::NotificationDetails& details) { |
| 870 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); | 937 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); |
| 871 GetWidget()->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE); | 938 GetWidget()->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE); |
| 872 CloseBubble(); | 939 CloseBubble(); |
| 873 } | 940 } |
| OLD | NEW |