| 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 choose credentials for |
| 178 // authentication. Contains a list of CredentialsItemView, along with a |
| 179 // "Cancel" button. |
| 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 // TODO(vasilii): this is a stub instead of actual data. We temporary show 2 |
| 213 // credentials. |
| 214 for (int i = 0; i < 2; ++i) { |
| 215 base::string16 name = |
| 216 l10n_util::GetStringFUTF16Int(IDS_NUMBERED_PROFILE_NAME, i); |
| 217 CredentialsItemView* credential_view = new CredentialsItemView(this, name); |
| 218 // Add the title to the layout with appropriate padding. |
| 219 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
| 220 layout->AddView(credential_view); |
| 221 } |
| 222 |
| 223 // Button row. |
| 224 BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET); |
| 225 layout->StartRowWithPadding( |
| 226 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); |
| 227 layout->AddView(cancel_button_); |
| 228 |
| 229 // Extra padding for visual awesomeness. |
| 230 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 231 |
| 232 parent_->set_initially_focused_view(cancel_button_); |
| 233 } |
| 234 |
| 235 ManagePasswordsBubbleView::AccountChooserView::~AccountChooserView() { |
| 236 } |
| 237 |
| 238 void ManagePasswordsBubbleView::AccountChooserView::ButtonPressed( |
| 239 views::Button* sender, const ui::Event& event) { |
| 240 parent_->Close(); |
| 241 } |
| 242 |
| 174 // ManagePasswordsBubbleView::PendingView ------------------------------------- | 243 // ManagePasswordsBubbleView::PendingView ------------------------------------- |
| 175 | 244 |
| 176 // A view offering the user the ability to save credentials. Contains a | 245 // A view offering the user the ability to save credentials. Contains a |
| 177 // single ManagePasswordItemView, along with a "Save Passwords" button | 246 // single ManagePasswordItemView, along with a "Save Passwords" button |
| 178 // and a rejection combobox. | 247 // and a rejection combobox. |
| 179 class ManagePasswordsBubbleView::PendingView : public views::View, | 248 class ManagePasswordsBubbleView::PendingView : public views::View, |
| 180 public views::ButtonListener, | 249 public views::ButtonListener, |
| 181 public views::ComboboxListener { | 250 public views::ComboboxListener { |
| 182 public: | 251 public: |
| 183 explicit PendingView(ManagePasswordsBubbleView* parent); | 252 explicit PendingView(ManagePasswordsBubbleView* parent); |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 } | 933 } |
| 865 | 934 |
| 866 void ManagePasswordsBubbleView::Observe( | 935 void ManagePasswordsBubbleView::Observe( |
| 867 int type, | 936 int type, |
| 868 const content::NotificationSource& source, | 937 const content::NotificationSource& source, |
| 869 const content::NotificationDetails& details) { | 938 const content::NotificationDetails& details) { |
| 870 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); | 939 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); |
| 871 GetWidget()->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE); | 940 GetWidget()->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE); |
| 872 CloseBubble(); | 941 CloseBubble(); |
| 873 } | 942 } |
| OLD | NEW |