| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/browser_list.h" | 8 #include "chrome/browser/ui/browser_list.h" |
| 9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
| 10 #include "chrome/browser/ui/dialog_style.h" | 10 #include "chrome/browser/ui/dialog_style.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 // Heading font size correction. | 27 // Heading font size correction. |
| 28 const int kHeadingFontSizeDelta = 1; | 28 const int kHeadingFontSizeDelta = 1; |
| 29 const int kMinColumnWidth = 320; | 29 const int kMinColumnWidth = 320; |
| 30 | 30 |
| 31 // A dialog explaining to the user more about one click signin, and provides | 31 // A dialog explaining to the user more about one click signin, and provides |
| 32 // a way for the user to continue or backout. | 32 // a way for the user to continue or backout. |
| 33 class OneClickSigninDialogView : public views::DialogDelegateView { | 33 class OneClickSigninDialogView : public views::DialogDelegateView { |
| 34 public: | 34 public: |
| 35 OneClickSigninDialogView(Profile* profile, | 35 OneClickSigninDialogView(Profile* profile, |
| 36 const std::string& session_index, |
| 36 const std::string& email, | 37 const std::string& email, |
| 37 const std::string& password); | 38 const std::string& password); |
| 38 virtual ~OneClickSigninDialogView(); | 39 virtual ~OneClickSigninDialogView(); |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 // views::DialogDelegateView: | 42 // views::DialogDelegateView: |
| 42 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; | 43 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; |
| 43 virtual int GetDefaultDialogButton() const OVERRIDE; | 44 virtual int GetDefaultDialogButton() const OVERRIDE; |
| 44 virtual bool Cancel() OVERRIDE; | 45 virtual bool Cancel() OVERRIDE; |
| 45 virtual bool Accept() OVERRIDE; | 46 virtual bool Accept() OVERRIDE; |
| 46 | 47 |
| 47 // views::WidgetDelegate: | 48 // views::WidgetDelegate: |
| 48 virtual ui::ModalType GetModalType() const OVERRIDE; | 49 virtual ui::ModalType GetModalType() const OVERRIDE; |
| 49 virtual string16 GetWindowTitle() const OVERRIDE; | 50 virtual string16 GetWindowTitle() const OVERRIDE; |
| 50 virtual views::View* GetContentsView() OVERRIDE; | 51 virtual views::View* GetContentsView() OVERRIDE; |
| 51 | 52 |
| 52 Profile* profile_; | 53 Profile* profile_; |
| 53 views::Checkbox* checkbox_; | 54 views::Checkbox* checkbox_; |
| 54 | 55 |
| 55 // Email address and password of the account that has just logged in. | 56 // Information about the account that has just logged in. |
| 57 std::string session_index_; |
| 56 std::string email_; | 58 std::string email_; |
| 57 std::string password_; | 59 std::string password_; |
| 58 | 60 |
| 59 DISALLOW_COPY_AND_ASSIGN(OneClickSigninDialogView); | 61 DISALLOW_COPY_AND_ASSIGN(OneClickSigninDialogView); |
| 60 }; | 62 }; |
| 61 | 63 |
| 62 OneClickSigninDialogView::OneClickSigninDialogView( | 64 OneClickSigninDialogView::OneClickSigninDialogView( |
| 63 Profile* profile, | 65 Profile* profile, |
| 66 const std::string& session_index, |
| 64 const std::string& email, | 67 const std::string& email, |
| 65 const std::string& password) | 68 const std::string& password) |
| 66 : profile_(profile), | 69 : profile_(profile), |
| 67 checkbox_(NULL), | 70 checkbox_(NULL), |
| 71 session_index_(session_index), |
| 68 email_(email), | 72 email_(email), |
| 69 password_(password) { | 73 password_(password) { |
| 70 views::GridLayout* layout = views::GridLayout::CreatePanel(this); | 74 views::GridLayout* layout = views::GridLayout::CreatePanel(this); |
| 71 SetLayoutManager(layout); | 75 SetLayoutManager(layout); |
| 72 const int kColumnSetId = 0; | 76 const int kColumnSetId = 0; |
| 73 views::ColumnSet* column_set = layout->AddColumnSet(kColumnSetId); | 77 views::ColumnSet* column_set = layout->AddColumnSet(kColumnSetId); |
| 74 column_set->AddColumn(views::GridLayout::FILL, | 78 column_set->AddColumn(views::GridLayout::FILL, |
| 75 views::GridLayout::FILL, | 79 views::GridLayout::FILL, |
| 76 1, // resizable | 80 1, // resizable |
| 77 views::GridLayout::USE_PREF, | 81 views::GridLayout::USE_PREF, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 return ui::DIALOG_BUTTON_OK; | 128 return ui::DIALOG_BUTTON_OK; |
| 125 } | 129 } |
| 126 | 130 |
| 127 bool OneClickSigninDialogView::Cancel() { | 131 bool OneClickSigninDialogView::Cancel() { |
| 128 return true; | 132 return true; |
| 129 } | 133 } |
| 130 | 134 |
| 131 bool OneClickSigninDialogView::Accept() { | 135 bool OneClickSigninDialogView::Accept() { |
| 132 // The starter deletes itself once its done. | 136 // The starter deletes itself once its done. |
| 133 OneClickSigninSyncStarter* starter = | 137 OneClickSigninSyncStarter* starter = |
| 134 new OneClickSigninSyncStarter(email_, password_, profile_, | 138 new OneClickSigninSyncStarter(session_index_, email_, password_, profile_, |
| 135 checkbox_->checked()); | 139 checkbox_->checked()); |
| 136 return true; | 140 return true; |
| 137 } | 141 } |
| 138 | 142 |
| 139 ui::ModalType OneClickSigninDialogView::GetModalType() const { | 143 ui::ModalType OneClickSigninDialogView::GetModalType() const { |
| 140 return ui::MODAL_TYPE_WINDOW; | 144 return ui::MODAL_TYPE_WINDOW; |
| 141 } | 145 } |
| 142 | 146 |
| 143 string16 OneClickSigninDialogView::GetWindowTitle() const { | 147 string16 OneClickSigninDialogView::GetWindowTitle() const { |
| 144 return l10n_util::GetStringUTF16(IDS_ONE_CLICK_SIGNIN_DIALOG_TITLE); | 148 return l10n_util::GetStringUTF16(IDS_ONE_CLICK_SIGNIN_DIALOG_TITLE); |
| 145 } | 149 } |
| 146 | 150 |
| 147 views::View* OneClickSigninDialogView::GetContentsView() { | 151 views::View* OneClickSigninDialogView::GetContentsView() { |
| 148 return this; | 152 return this; |
| 149 } | 153 } |
| 150 | 154 |
| 151 } // namespace | 155 } // namespace |
| 152 | 156 |
| 153 | 157 |
| 154 void ShowOneClickSigninDialog(Profile* profile, | 158 void ShowOneClickSigninDialog(Profile* profile, |
| 159 const std::string& session_index, |
| 155 const std::string& email, | 160 const std::string& email, |
| 156 const std::string& password) { | 161 const std::string& password) { |
| 157 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); | 162 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); |
| 158 if (!browser) | 163 if (!browser) |
| 159 return; | 164 return; |
| 160 | 165 |
| 161 BrowserWindow* browser_window = browser->window(); | 166 BrowserWindow* browser_window = browser->window(); |
| 162 if (!browser_window) | 167 if (!browser_window) |
| 163 return; | 168 return; |
| 164 | 169 |
| 165 OneClickSigninDialogView* dialog = new OneClickSigninDialogView( | 170 OneClickSigninDialogView* dialog = new OneClickSigninDialogView( |
| 166 profile, email, password); | 171 profile, session_index, email, password); |
| 167 | 172 |
| 168 views::Widget* window = browser::CreateViewsWindow( | 173 views::Widget* window = browser::CreateViewsWindow( |
| 169 browser_window->GetNativeHandle(), dialog, STYLE_GENERIC); | 174 browser_window->GetNativeHandle(), dialog, STYLE_GENERIC); |
| 170 | 175 |
| 171 window->Show(); | 176 window->Show(); |
| 172 } | 177 } |
| OLD | NEW |