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/cocoa/tab_dialogs_cocoa.h"
7 #import "chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h"
8 #import "chrome/browser/ui/cocoa/hung_renderer_controller.h"
9 #import "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.h"
10 #import "chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.h"
11 #import "chrome/browser/ui/cocoa/validation_message_bubble_cocoa.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 TabDialogsCocoa(contents));
21 TabDialogsCocoa::TabDialogsCocoa(content::WebContents* contents)
22 : web_contents_(contents) {
26 TabDialogsCocoa::~TabDialogsCocoa() {
29 void TabDialogsCocoa::ShowCollectedCookies() {
30 // Deletes itself on close.
31 new CollectedCookiesMac(web_contents_);
34 void TabDialogsCocoa::ShowHungRendererDialog() {
35 [HungRendererController showForWebContents:web_contents_];
38 void TabDialogsCocoa::HideHungRendererDialog() {
39 [HungRendererController endForWebContents:web_contents_];
42 void TabDialogsCocoa::ShowProfileSigninConfirmation(
45 const std::string& username,
46 ui::ProfileSigninConfirmationDelegate* delegate) {
47 ProfileSigninConfirmationDialogCocoa::Show(
48 browser, web_contents_, profile, username, delegate);
51 void TabDialogsCocoa::ShowManagePasswordsBubble(bool user_action) {
52 ManagePasswordsBubbleCocoa::Show(web_contents_, user_action);
55 void TabDialogsCocoa::HideManagePasswordsBubble() {
56 // The bubble is closed when it loses the focus.
59 scoped_ptr<ValidationMessageBubble> TabDialogsCocoa::ShowValidationMessage(
60 const gfx::Rect& anchor_in_root_view,
61 const base::string16& main_text,
62 const base::string16& sub_text) {
63 return make_scoped_ptr(new ValidationMessageBubbleCocoa(
64 web_contents_, anchor_in_root_view, main_text, sub_text));