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

Side by Side Diff: chrome/browser/ui/views/session_crashed_bubble_view.h

Issue 1717453003: Introduce BubbleDialogDelegateView, which extends DialogDelegateView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 10 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
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 #ifndef CHROME_BROWSER_UI_VIEWS_SESSION_CRASHED_BUBBLE_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_SESSION_CRASHED_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_SESSION_CRASHED_BUBBLE_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_SESSION_CRASHED_BUBBLE_VIEW_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/ui/session_crashed_bubble.h" 10 #include "chrome/browser/ui/session_crashed_bubble.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" 11 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
12 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h" 13 #include "content/public/browser/notification_registrar.h"
14 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
15 #include "ui/views/bubble/bubble_delegate.h" 15 #include "ui/views/bubble/bubble_dialog_delegate.h"
16 #include "ui/views/controls/button/button.h"
17 #include "ui/views/controls/styled_label_listener.h" 16 #include "ui/views/controls/styled_label_listener.h"
18 17
19 namespace views { 18 namespace views {
20 class Checkbox; 19 class Checkbox;
21 class GridLayout; 20 class GridLayout;
22 class LabelButton;
23 class Widget; 21 class Widget;
24 } 22 }
25 23
26 namespace content { 24 namespace content {
27 class WebContents; 25 class WebContents;
28 class RenderViewHost; 26 class RenderViewHost;
29 } 27 }
30 28
31 class Browser; 29 class Browser;
32 30
33 // It creates a session restore request bubble when the previous session has 31 // It creates a session restore request bubble when the previous session has
34 // crashed. It also presents an option to enable metrics reporting, if it not 32 // crashed. It also presents an option to enable metrics reporting, if it not
35 // enabled already. 33 // enabled already.
36 class SessionCrashedBubbleView 34 class SessionCrashedBubbleView : public SessionCrashedBubble,
msw 2016/02/22 21:43:56 Does the appearance of this bubble change at all?
Evan Stade 2016/02/22 22:58:22 nope. Old on top, new on bottom: https://screensho
37 : public SessionCrashedBubble, 35 public views::BubbleDialogDelegateView,
38 public views::BubbleDelegateView, 36 public views::StyledLabelListener,
39 public views::ButtonListener, 37 public content::WebContentsObserver,
40 public views::StyledLabelListener, 38 public content::NotificationObserver,
41 public content::WebContentsObserver, 39 public TabStripModelObserver {
42 public content::NotificationObserver,
43 public TabStripModelObserver {
44 public: 40 public:
45 // A helper class that listens to browser removal event. 41 // A helper class that listens to browser removal event.
46 class BrowserRemovalObserver; 42 class BrowserRemovalObserver;
47 43
48 // Creates and shows the session crashed bubble, with |uma_opted_in_already| 44 // Creates and shows the session crashed bubble, with |uma_opted_in_already|
49 // indicating whether the user has already opted-in to UMA. It will be called 45 // indicating whether the user has already opted-in to UMA. It will be called
50 // by Show. It takes ownership of |browser_observer|. 46 // by Show. It takes ownership of |browser_observer|.
51 static void ShowForReal(scoped_ptr<BrowserRemovalObserver> browser_observer, 47 static void ShowForReal(scoped_ptr<BrowserRemovalObserver> browser_observer,
52 bool uma_opted_in_already); 48 bool uma_opted_in_already);
53 49
54 private: 50 private:
55 SessionCrashedBubbleView(views::View* anchor_view, 51 SessionCrashedBubbleView(views::View* anchor_view,
56 Browser* browser, 52 Browser* browser,
57 content::WebContents* web_contents, 53 content::WebContents* web_contents,
58 bool offer_uma_optin); 54 bool offer_uma_optin);
59 ~SessionCrashedBubbleView() override; 55 ~SessionCrashedBubbleView() override;
60 56
61 // WidgetDelegateView methods. 57 // WidgetDelegateView methods.
62 views::View* GetInitiallyFocusedView() override;
63 base::string16 GetWindowTitle() const override; 58 base::string16 GetWindowTitle() const override;
64 bool ShouldShowWindowTitle() const override; 59 bool ShouldShowWindowTitle() const override;
65 bool ShouldShowCloseButton() const override; 60 bool ShouldShowCloseButton() const override;
66 void OnWidgetDestroying(views::Widget* widget) override; 61 void OnWidgetDestroying(views::Widget* widget) override;
67 scoped_ptr<views::View> CreateFootnoteView() override; 62 scoped_ptr<views::View> CreateFootnoteView() override;
63 bool Accept(bool window_closing) override;
64 int GetDialogButtons() const override;
65 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
68 66
69 // views::BubbleDelegateView methods. 67 // views::BubbleDialogDelegateView methods.
70 void Init() override; 68 void Init() override;
71 69
72 // views::ButtonListener methods.
73 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
74
75 // views::StyledLabelListener methods. 70 // views::StyledLabelListener methods.
76 void StyledLabelLinkClicked(views::StyledLabel* label, 71 void StyledLabelLinkClicked(views::StyledLabel* label,
77 const gfx::Range& range, 72 const gfx::Range& range,
78 int event_flags) override; 73 int event_flags) override;
79 74
80 // content::WebContentsObserver methods. 75 // content::WebContentsObserver methods.
81 void DidStartNavigationToPendingEntry( 76 void DidStartNavigationToPendingEntry(
82 const GURL& url, 77 const GURL& url,
83 content::NavigationController::ReloadType reload_type) override; 78 content::NavigationController::ReloadType reload_type) override;
84 void DidFinishLoad(content::RenderFrameHost* render_frame_host, 79 void DidFinishLoad(content::RenderFrameHost* render_frame_host,
85 const GURL& validated_url) override; 80 const GURL& validated_url) override;
86 void WasShown() override; 81 void WasShown() override;
87 void WasHidden() override; 82 void WasHidden() override;
88 83
89 // content::NotificationObserver methods. 84 // content::NotificationObserver methods.
90 void Observe(int type, 85 void Observe(int type,
91 const content::NotificationSource& source, 86 const content::NotificationSource& source,
92 const content::NotificationDetails& details) override; 87 const content::NotificationDetails& details) override;
93 88
94 // TabStripModelObserver methods. 89 // TabStripModelObserver methods.
95 // When the tab with current bubble is being dragged and dropped to a new 90 // When the tab with current bubble is being dragged and dropped to a new
96 // window or to another window, the bubble will be dismissed as if the user 91 // window or to another window, the bubble will be dismissed as if the user
97 // chose not to restore the previous session. 92 // chose not to restore the previous session.
98 void TabDetachedAt(content::WebContents* contents, int index) override; 93 void TabDetachedAt(content::WebContents* contents, int index) override;
99 94
100 // Restore previous session after user selects so. 95 // Restore previous session after user selects so.
101 void RestorePreviousSession(views::Button* sender); 96 void RestorePreviousSession();
102 97
103 // Close and destroy the bubble. 98 // Close and destroy the bubble.
104 void CloseBubble(); 99 void CloseBubble();
105 100
106 content::NotificationRegistrar registrar_; 101 content::NotificationRegistrar registrar_;
107 102
108 // Used for opening the question mark link as well as access the tab strip. 103 // Used for opening the question mark link as well as access the tab strip.
109 Browser* browser_; 104 Browser* browser_;
110 105
111 // The web content associated with current bubble. 106 // The web content associated with current bubble.
112 content::WebContents* web_contents_; 107 content::WebContents* web_contents_;
113 108
114 // Button for the user to confirm a session restore.
115 views::LabelButton* restore_button_;
116
117 // Checkbox for the user to opt-in to UMA reporting. 109 // Checkbox for the user to opt-in to UMA reporting.
118 views::Checkbox* uma_option_; 110 views::Checkbox* uma_option_;
119 111
120 // Whether or not the UMA opt-in option should be shown. 112 // Whether or not the UMA opt-in option should be shown.
121 bool offer_uma_optin_; 113 bool offer_uma_optin_;
122 114
123 // Whether or not a navigation has started on current tab. 115 // Whether or not a navigation has started on current tab.
124 bool started_navigation_; 116 bool started_navigation_;
125 117
126 // Whether or not the user chose to restore previous session. It is used to 118 // Whether or not the user chose to restore previous session. It is used to
127 // collect bubble usage stats. 119 // collect bubble usage stats.
128 bool restored_; 120 bool restored_;
129 121
130 DISALLOW_COPY_AND_ASSIGN(SessionCrashedBubbleView); 122 DISALLOW_COPY_AND_ASSIGN(SessionCrashedBubbleView);
131 }; 123 };
132 124
133 #endif // CHROME_BROWSER_UI_VIEWS_SESSION_CRASHED_BUBBLE_VIEW_H_ 125 #endif // CHROME_BROWSER_UI_VIEWS_SESSION_CRASHED_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698