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

Side by Side Diff: chrome/browser/ui/javascript_dialogs/javascript_dialog_views.h

Issue 2421943002: Make JavaScript dialogs auto-dismiss on tab switch. (Closed)
Patch Set: last fixes Created 4 years, 2 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_VIEWS_H_
6 #define CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_VIEWS_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "content/public/browser/javascript_dialog_manager.h"
13 #include "ui/views/window/dialog_delegate.h"
14
15 namespace views {
16 class MessageBoxView;
17 }
18
19 // A Views version of a JavaScript dialog that automatically dismisses itself
20 // when the user switches away to a different tab, used for WebContentses that
21 // are browser tabs.
22 class JavaScriptDialogViews : public views::DialogDelegate {
23 public:
24 ~JavaScriptDialogViews() override;
25
26 static base::WeakPtr<JavaScriptDialogViews> Create(
27 content::WebContents* parent_web_contents,
28 content::WebContents* alerting_web_contents,
29 const base::string16& title,
30 content::JavaScriptMessageType message_type,
31 const base::string16& message_text,
32 const base::string16& default_prompt_text,
33 const content::JavaScriptDialogManager::DialogClosedCallback&
34 dialog_callback);
35
36 // Closes the dialog without sending a callback. This is useful when the
37 // JavaScriptDialogTabHelper needs to make this dialog go away so that it can
38 // respond to a call that requires it to make no callback or make a customized
39 // one.
40 void CloseDialogWithoutCallback();
41
42 // views::DialogDelegate:
43 int GetDefaultDialogButton() const override;
44 int GetDialogButtons() const override;
45 base::string16 GetWindowTitle() const override;
46 bool Cancel() override;
47 bool Accept() override;
48 bool Close() override;
49 void DeleteDelegate() override;
50
51 // views::WidgetDelegate:
52 views::View* GetContentsView() override;
53 views::View* GetInitiallyFocusedView() override;
54 views::Widget* GetWidget() override;
55 const views::Widget* GetWidget() const override;
56 ui::ModalType GetModalType() const override;
57
58 private:
59 JavaScriptDialogViews(
60 content::WebContents* parent_web_contents,
61 content::WebContents* alerting_web_contents,
62 const base::string16& title,
63 content::JavaScriptMessageType message_type,
64 const base::string16& message_text,
65 const base::string16& default_prompt_text,
66 const content::JavaScriptDialogManager::DialogClosedCallback&
67 dialog_callback);
68
69 base::string16 title_;
70 content::JavaScriptMessageType message_type_;
71 base::string16 message_text_;
72 base::string16 default_prompt_text_;
73 content::JavaScriptDialogManager::DialogClosedCallback dialog_callback_;
74
75 // The message box view whose commands we handle.
76 views::MessageBoxView* message_box_view_;
77
78 base::WeakPtrFactory<JavaScriptDialogViews> weak_factory_;
79
80 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogViews);
81 };
82
83 #endif // CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_VIEWS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698