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