NaCl docs: add sanitizers to GSoC ideas
[chromium-blink-merge.git] / chrome / browser / ui / views / tab_dialogs_views.cc
blobbecdb5796ad7ad4ddf762562ed9c15a630474d23
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"
14 // static
15 void TabDialogs::CreateForWebContents(content::WebContents* contents) {
16 DCHECK(contents);
17 if (!FromWebContents(contents))
18 contents->SetUserData(UserDataKey(), new TabDialogsViews(contents));
21 TabDialogsViews::TabDialogsViews(content::WebContents* contents)
22 : web_contents_(contents) {
23 DCHECK(contents);
26 TabDialogsViews::~TabDialogsViews() {
29 void TabDialogsViews::ShowCollectedCookies() {
30 // Deletes itself on close.
31 new CollectedCookiesViews(web_contents_);
34 void TabDialogsViews::ShowHungRendererDialog() {
35 HungRendererDialogView::Show(web_contents_);
38 void TabDialogsViews::HideHungRendererDialog() {
39 HungRendererDialogView::Hide(web_contents_);
42 void TabDialogsViews::ShowProfileSigninConfirmation(
43 Browser* browser,
44 Profile* profile,
45 const std::string& username,
46 ui::ProfileSigninConfirmationDelegate* delegate) {
47 ProfileSigninConfirmationDialogViews::ShowDialog(
48 browser, profile, username, delegate);
51 void TabDialogsViews::ShowManagePasswordsBubble(bool user_action) {
52 if (ManagePasswordsBubbleView::IsShowing()) {
53 // The bubble is currently shown for some other tab. We should close it now
54 // and open for |web_contents_|.
55 ManagePasswordsBubbleView::CloseBubble();
57 ManagePasswordsBubbleView::ShowBubble(
58 web_contents_, user_action ? ManagePasswordsBubble::USER_ACTION
59 : ManagePasswordsBubble::AUTOMATIC);
62 void TabDialogsViews::HideManagePasswordsBubble() {
63 if (!ManagePasswordsBubbleView::IsShowing())
64 return;
65 content::WebContents* bubble_web_contents =
66 ManagePasswordsBubbleView::manage_password_bubble()->web_contents();
67 if (web_contents_ == bubble_web_contents)
68 ManagePasswordsBubbleView::CloseBubble();
71 scoped_ptr<ValidationMessageBubble> TabDialogsViews::ShowValidationMessage(
72 const gfx::Rect& anchor_in_root_view,
73 const base::string16& main_text,
74 const base::string16& sub_text) {
75 return make_scoped_ptr(new ValidationMessageBubbleView(
76 web_contents_, anchor_in_root_view, main_text, sub_text));