| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/tab_dialogs_views.h" | 5 #include "chrome/browser/ui/views/tab_dialogs_views.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 8 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
| 9 #include "chrome/browser/ui/views/collected_cookies_views.h" | 9 #include "chrome/browser/ui/views/collected_cookies_views.h" |
| 10 #include "chrome/browser/ui/views/hung_renderer_view.h" | 10 #include "chrome/browser/ui/views/hung_renderer_view.h" |
| 11 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" | 11 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
| 12 #include "chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.
h" | |
| 13 #include "chrome/browser/ui/views/validation_message_bubble_view.h" | 12 #include "chrome/browser/ui/views/validation_message_bubble_view.h" |
| 14 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 15 | 14 |
| 15 #if !defined(OS_CHROMEOS) |
| 16 #include "chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.
h" |
| 17 #endif |
| 18 |
| 16 // static | 19 // static |
| 17 void TabDialogs::CreateForWebContents(content::WebContents* contents) { | 20 void TabDialogs::CreateForWebContents(content::WebContents* contents) { |
| 18 DCHECK(contents); | 21 DCHECK(contents); |
| 19 if (!FromWebContents(contents)) | 22 if (!FromWebContents(contents)) |
| 20 contents->SetUserData(UserDataKey(), new TabDialogsViews(contents)); | 23 contents->SetUserData(UserDataKey(), new TabDialogsViews(contents)); |
| 21 } | 24 } |
| 22 | 25 |
| 23 TabDialogsViews::TabDialogsViews(content::WebContents* contents) | 26 TabDialogsViews::TabDialogsViews(content::WebContents* contents) |
| 24 : web_contents_(contents) { | 27 : web_contents_(contents) { |
| 25 DCHECK(contents); | 28 DCHECK(contents); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 43 | 46 |
| 44 void TabDialogsViews::HideHungRendererDialog() { | 47 void TabDialogsViews::HideHungRendererDialog() { |
| 45 HungRendererDialogView::Hide(web_contents_); | 48 HungRendererDialogView::Hide(web_contents_); |
| 46 } | 49 } |
| 47 | 50 |
| 48 void TabDialogsViews::ShowProfileSigninConfirmation( | 51 void TabDialogsViews::ShowProfileSigninConfirmation( |
| 49 Browser* browser, | 52 Browser* browser, |
| 50 Profile* profile, | 53 Profile* profile, |
| 51 const std::string& username, | 54 const std::string& username, |
| 52 ui::ProfileSigninConfirmationDelegate* delegate) { | 55 ui::ProfileSigninConfirmationDelegate* delegate) { |
| 56 #if !defined(OS_CHROMEOS) |
| 53 ProfileSigninConfirmationDialogViews::ShowDialog( | 57 ProfileSigninConfirmationDialogViews::ShowDialog( |
| 54 browser, profile, username, delegate); | 58 browser, profile, username, delegate); |
| 59 #else |
| 60 NOTREACHED(); |
| 61 #endif |
| 55 } | 62 } |
| 56 | 63 |
| 57 void TabDialogsViews::ShowManagePasswordsBubble(bool user_action) { | 64 void TabDialogsViews::ShowManagePasswordsBubble(bool user_action) { |
| 58 if (ManagePasswordsBubbleView::manage_password_bubble()) { | 65 if (ManagePasswordsBubbleView::manage_password_bubble()) { |
| 59 // The bubble is currently shown for some other tab. We should close it now | 66 // The bubble is currently shown for some other tab. We should close it now |
| 60 // and open for |web_contents_|. | 67 // and open for |web_contents_|. |
| 61 ManagePasswordsBubbleView::CloseCurrentBubble(); | 68 ManagePasswordsBubbleView::CloseCurrentBubble(); |
| 62 } | 69 } |
| 63 ManagePasswordsBubbleView::ShowBubble( | 70 ManagePasswordsBubbleView::ShowBubble( |
| 64 web_contents_, user_action ? ManagePasswordsBubbleView::USER_GESTURE | 71 web_contents_, user_action ? ManagePasswordsBubbleView::USER_GESTURE |
| 65 : ManagePasswordsBubbleView::AUTOMATIC); | 72 : ManagePasswordsBubbleView::AUTOMATIC); |
| 66 } | 73 } |
| 67 | 74 |
| 68 void TabDialogsViews::HideManagePasswordsBubble() { | 75 void TabDialogsViews::HideManagePasswordsBubble() { |
| 69 if (!ManagePasswordsBubbleView::manage_password_bubble()) | 76 if (!ManagePasswordsBubbleView::manage_password_bubble()) |
| 70 return; | 77 return; |
| 71 content::WebContents* bubble_web_contents = | 78 content::WebContents* bubble_web_contents = |
| 72 ManagePasswordsBubbleView::manage_password_bubble()->web_contents(); | 79 ManagePasswordsBubbleView::manage_password_bubble()->web_contents(); |
| 73 if (web_contents_ == bubble_web_contents) | 80 if (web_contents_ == bubble_web_contents) |
| 74 ManagePasswordsBubbleView::CloseCurrentBubble(); | 81 ManagePasswordsBubbleView::CloseCurrentBubble(); |
| 75 } | 82 } |
| 76 | 83 |
| 77 base::WeakPtr<ValidationMessageBubble> TabDialogsViews::ShowValidationMessage( | 84 base::WeakPtr<ValidationMessageBubble> TabDialogsViews::ShowValidationMessage( |
| 78 const gfx::Rect& anchor_in_root_view, | 85 const gfx::Rect& anchor_in_root_view, |
| 79 const base::string16& main_text, | 86 const base::string16& main_text, |
| 80 const base::string16& sub_text) { | 87 const base::string16& sub_text) { |
| 81 return (new ValidationMessageBubbleView( | 88 return (new ValidationMessageBubbleView( |
| 82 web_contents_, anchor_in_root_view, main_text, sub_text))->AsWeakPtr(); | 89 web_contents_, anchor_in_root_view, main_text, sub_text))->AsWeakPtr(); |
| 83 } | 90 } |
| OLD | NEW |