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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/tab_dialogs_views.h"
7 #include "chrome/browser/ui/views/collected_cookies_views.h"
8 #include "chrome/browser/ui/views/hung_renderer_view.h"
9 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
10 #include "chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.h"
11 #include "chrome/browser/ui/views/validation_message_bubble_view.h"
12 #include "content/public/browser/web_contents.h"
15 void TabDialogs::CreateForWebContents(content::WebContents
* contents
) {
17 if (!FromWebContents(contents
))
18 contents
->SetUserData(UserDataKey(), new TabDialogsViews(contents
));
21 TabDialogsViews::TabDialogsViews(content::WebContents
* contents
)
22 : web_contents_(contents
) {
26 TabDialogsViews::~TabDialogsViews() {
29 gfx::NativeView
TabDialogsViews::GetDialogParentView() const {
30 return web_contents_
->GetNativeView();
33 void TabDialogsViews::ShowCollectedCookies() {
34 // Deletes itself on close.
35 new CollectedCookiesViews(web_contents_
);
38 void TabDialogsViews::ShowHungRendererDialog() {
39 HungRendererDialogView::Show(web_contents_
);
42 void TabDialogsViews::HideHungRendererDialog() {
43 HungRendererDialogView::Hide(web_contents_
);
46 void TabDialogsViews::ShowProfileSigninConfirmation(
49 const std::string
& username
,
50 ui::ProfileSigninConfirmationDelegate
* delegate
) {
51 ProfileSigninConfirmationDialogViews::ShowDialog(
52 browser
, profile
, username
, delegate
);
55 void TabDialogsViews::ShowManagePasswordsBubble(bool user_action
) {
56 if (ManagePasswordsBubbleView::manage_password_bubble()) {
57 // The bubble is currently shown for some other tab. We should close it now
58 // and open for |web_contents_|.
59 ManagePasswordsBubbleView::CloseBubble();
61 ManagePasswordsBubbleView::ShowBubble(
62 web_contents_
, user_action
? ManagePasswordsBubble::USER_ACTION
63 : ManagePasswordsBubble::AUTOMATIC
);
66 void TabDialogsViews::HideManagePasswordsBubble() {
67 if (!ManagePasswordsBubbleView::manage_password_bubble())
69 content::WebContents
* bubble_web_contents
=
70 ManagePasswordsBubbleView::manage_password_bubble()->web_contents();
71 if (web_contents_
== bubble_web_contents
)
72 ManagePasswordsBubbleView::CloseBubble();
75 scoped_ptr
<ValidationMessageBubble
> TabDialogsViews::ShowValidationMessage(
76 const gfx::Rect
& anchor_in_root_view
,
77 const base::string16
& main_text
,
78 const base::string16
& sub_text
) {
79 return make_scoped_ptr(new ValidationMessageBubbleView(
80 web_contents_
, anchor_in_root_view
, main_text
, sub_text
));