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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/signin_view_controller_delegate_mac.mm

Issue 2784823002: Reland "Use the same browser instance in the sync confirmation dialog. (Closed)
Patch Set: Rebase and fix conflicts Created 3 years, 8 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/cocoa/profiles/signin_view_controller_delegate_mac.h " 5 #include "chrome/browser/ui/cocoa/profiles/signin_view_controller_delegate_mac.h "
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 11 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
12 #include "chrome/browser/signin/signin_promo.h" 12 #include "chrome/browser/signin/signin_promo.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #import "chrome/browser/ui/cocoa/browser_window_utils.h" 14 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
15 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_s heet.h" 15 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_s heet.h"
16 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_w indow.h" 16 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_w indow.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/browser/ui/webui/signin/sync_confirmation_ui.h"
18 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
19 #include "components/signin/core/common/profile_management_switches.h" 20 #include "components/signin/core/common/profile_management_switches.h"
20 #include "content/public/browser/native_web_keyboard_event.h" 21 #include "content/public/browser/native_web_keyboard_event.h"
21 #include "content/public/browser/render_widget_host_view.h" 22 #include "content/public/browser/render_widget_host_view.h"
22 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
23 24
24 namespace { 25 namespace {
25 26
26 // Dimensions of the web contents containing the old-style signin flow with the 27 // Dimensions of the web contents containing the old-style signin flow with the
27 // username and password challenge on the same form. 28 // username and password challenge on the same form.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView(); 108 content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
108 if (rwhv) 109 if (rwhv)
109 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); 110 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor);
110 111
111 return web_contents; 112 return web_contents;
112 } 113 }
113 114
114 // static 115 // static
115 std::unique_ptr<content::WebContents> 116 std::unique_ptr<content::WebContents>
116 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents( 117 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents(
117 Profile* profile) { 118 Browser* browser) {
118 std::unique_ptr<content::WebContents> web_contents( 119 std::unique_ptr<content::WebContents> web_contents(
119 content::WebContents::Create( 120 content::WebContents::Create(
120 content::WebContents::CreateParams(profile))); 121 content::WebContents::CreateParams(browser->profile())));
121 web_contents->GetController().LoadURL( 122 web_contents->GetController().LoadURL(
122 GURL(chrome::kChromeUISyncConfirmationURL), content::Referrer(), 123 GURL(chrome::kChromeUISyncConfirmationURL), content::Referrer(),
123 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); 124 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
125 SyncConfirmationUI* sync_confirmation_ui = static_cast<SyncConfirmationUI*>(
126 web_contents->GetWebUI()->GetController());
127 sync_confirmation_ui->InitializeMessageHandlerWithBrowser(browser);
124 128
125 NSView* webview = web_contents->GetNativeView(); 129 NSView* webview = web_contents->GetNativeView();
126 [webview setFrameSize:NSMakeSize( 130 [webview setFrameSize:NSMakeSize(kModalDialogWidth,
127 kModalDialogWidth, 131 GetSyncConfirmationDialogPreferredHeight(
128 GetSyncConfirmationDialogPreferredHeight(profile))]; 132 browser->profile()))];
129 133
130 return web_contents; 134 return web_contents;
131 } 135 }
132 136
133 // static 137 // static
134 std::unique_ptr<content::WebContents> 138 std::unique_ptr<content::WebContents>
135 SigninViewControllerDelegateMac::CreateSigninErrorWebContents( 139 SigninViewControllerDelegateMac::CreateSigninErrorWebContents(
136 Profile* profile) { 140 Profile* profile) {
137 std::unique_ptr<content::WebContents> web_contents( 141 std::unique_ptr<content::WebContents> web_contents(
138 content::WebContents::Create( 142 content::WebContents::Create(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 243 }
240 244
241 // static 245 // static
242 SigninViewControllerDelegate* 246 SigninViewControllerDelegate*
243 SigninViewControllerDelegate::CreateSyncConfirmationDelegate( 247 SigninViewControllerDelegate::CreateSyncConfirmationDelegate(
244 SigninViewController* signin_view_controller, 248 SigninViewController* signin_view_controller,
245 Browser* browser) { 249 Browser* browser) {
246 return new SigninViewControllerDelegateMac( 250 return new SigninViewControllerDelegateMac(
247 signin_view_controller, 251 signin_view_controller,
248 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents( 252 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents(
249 browser->profile()), 253 browser),
250 browser, 254 browser,
251 NSMakeRect(0, 0, kModalDialogWidth, 255 NSMakeRect(0, 0, kModalDialogWidth,
252 GetSyncConfirmationDialogPreferredHeight(browser->profile())), 256 GetSyncConfirmationDialogPreferredHeight(browser->profile())),
253 ui::MODAL_TYPE_WINDOW, true /* wait_for_size */); 257 ui::MODAL_TYPE_WINDOW, true /* wait_for_size */);
254 } 258 }
255 259
256 // static 260 // static
257 SigninViewControllerDelegate* 261 SigninViewControllerDelegate*
258 SigninViewControllerDelegate::CreateSigninErrorDelegate( 262 SigninViewControllerDelegate::CreateSigninErrorDelegate(
259 SigninViewController* signin_view_controller, 263 SigninViewController* signin_view_controller,
260 Browser* browser) { 264 Browser* browser) {
261 return new SigninViewControllerDelegateMac( 265 return new SigninViewControllerDelegateMac(
262 signin_view_controller, 266 signin_view_controller,
263 SigninViewControllerDelegateMac::CreateSigninErrorWebContents( 267 SigninViewControllerDelegateMac::CreateSigninErrorWebContents(
264 browser->profile()), 268 browser->profile()),
265 browser, NSMakeRect(0, 0, kModalDialogWidth, kSigninErrorDialogHeight), 269 browser, NSMakeRect(0, 0, kModalDialogWidth, kSigninErrorDialogHeight),
266 ui::MODAL_TYPE_WINDOW, true /* wait_for_size */); 270 ui::MODAL_TYPE_WINDOW, true /* wait_for_size */);
267 } 271 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698