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

Side by Side Diff: chrome/browser/ui/views/first_run_dialog.cc

Issue 182753002: Revert of Use the default dispatcher where possible for nested message loops. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 #include "chrome/browser/ui/views/first_run_dialog.h" 5 #include "chrome/browser/ui/views/first_run_dialog.h"
6 6
7 #include "chrome/browser/first_run/first_run.h" 7 #include "chrome/browser/first_run/first_run.h"
8 #include "chrome/browser/platform_util.h" 8 #include "chrome/browser/platform_util.h"
9 #include "chrome/browser/shell_integration.h" 9 #include "chrome/browser/shell_integration.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 // Use the widget's window itself so that the message loop 59 // Use the widget's window itself so that the message loop
60 // exists when the dialog is closed by some other means than 60 // exists when the dialog is closed by some other means than
61 // |Accept|. 61 // |Accept|.
62 // 62 //
63 // This is the same trick used in simple_message_box_views.cc, minus the 63 // This is the same trick used in simple_message_box_views.cc, minus the
64 // refcounting. 64 // refcounting.
65 aura::Window* anchor = dialog->GetWidget()->GetNativeWindow(); 65 aura::Window* anchor = dialog->GetWidget()->GetNativeWindow();
66 aura::client::DispatcherClient* client = 66 aura::client::DispatcherClient* client =
67 aura::client::GetDispatcherClient(anchor->GetRootWindow()); 67 aura::client::GetDispatcherClient(anchor->GetRootWindow());
68 client->RunWithDispatcher(NULL, anchor); 68 client->RunWithDispatcher(dialog, anchor);
69 dialog_shown = true; 69 dialog_shown = true;
70 } 70 }
71 #endif // defined(GOOGLE_CHROME_BUILD) 71 #endif // defined(GOOGLE_CHROME_BUILD)
72 72
73 return dialog_shown; 73 return dialog_shown;
74 } 74 }
75 75
76 FirstRunDialog::FirstRunDialog(Profile* profile) 76 FirstRunDialog::FirstRunDialog(Profile* profile)
77 : profile_(profile), 77 : profile_(profile),
78 make_default_(NULL), 78 make_default_(NULL),
79 report_crashes_(NULL) { 79 report_crashes_(NULL),
80 should_show_dialog_(true) {
80 GridLayout* layout = GridLayout::CreatePanel(this); 81 GridLayout* layout = GridLayout::CreatePanel(this);
81 SetLayoutManager(layout); 82 SetLayoutManager(layout);
82 83
83 const int related_y = views::kRelatedControlVerticalSpacing; 84 const int related_y = views::kRelatedControlVerticalSpacing;
84 85
85 views::ColumnSet* column_set = layout->AddColumnSet(0); 86 views::ColumnSet* column_set = layout->AddColumnSet(0);
86 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, 87 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0,
87 GridLayout::USE_PREF, 0, 0); 88 GridLayout::USE_PREF, 0, 0);
88 89
89 layout->StartRow(0, 0); 90 layout->StartRow(0, 0);
90 make_default_ = new views::Checkbox(l10n_util::GetStringUTF16( 91 make_default_ = new views::Checkbox(l10n_util::GetStringUTF16(
91 IDS_FR_CUSTOMIZE_DEFAULT_BROWSER)); 92 IDS_FR_CUSTOMIZE_DEFAULT_BROWSER));
92 make_default_->SetChecked(true); 93 make_default_->SetChecked(true);
93 layout->AddView(make_default_); 94 layout->AddView(make_default_);
94 95
95 layout->StartRowWithPadding(0, 0, 0, related_y); 96 layout->StartRowWithPadding(0, 0, 0, related_y);
96 report_crashes_ = new views::Checkbox(l10n_util::GetStringUTF16( 97 report_crashes_ = new views::Checkbox(l10n_util::GetStringUTF16(
97 IDS_OPTIONS_ENABLE_LOGGING)); 98 IDS_OPTIONS_ENABLE_LOGGING));
98 layout->AddView(report_crashes_); 99 layout->AddView(report_crashes_);
99 } 100 }
100 101
101 FirstRunDialog::~FirstRunDialog() { 102 FirstRunDialog::~FirstRunDialog() {
102 } 103 }
103 104
104 void FirstRunDialog::Done() {
105 aura::Window* window = GetWidget()->GetNativeView();
106 aura::client::DispatcherClient* client =
107 aura::client::GetDispatcherClient(window->GetRootWindow());
108 client->QuitNestedMessageLoop();
109 }
110
111 views::View* FirstRunDialog::CreateExtraView() { 105 views::View* FirstRunDialog::CreateExtraView() {
112 views::Link* link = new views::Link(l10n_util::GetStringUTF16( 106 views::Link* link = new views::Link(l10n_util::GetStringUTF16(
113 IDS_LEARN_MORE)); 107 IDS_LEARN_MORE));
114 link->set_listener(this); 108 link->set_listener(this);
115 return link; 109 return link;
116 } 110 }
117 111
118 void FirstRunDialog::OnClosed() { 112 void FirstRunDialog::OnClosed() {
113 should_show_dialog_ = false;
119 first_run::SetShouldShowWelcomePage(); 114 first_run::SetShouldShowWelcomePage();
120 Done();
121 } 115 }
122 116
123 bool FirstRunDialog::Accept() { 117 bool FirstRunDialog::Accept() {
118 should_show_dialog_ = false;
124 GetWidget()->Hide(); 119 GetWidget()->Hide();
125 120
126 if (report_crashes_ && report_crashes_->checked()) { 121 if (report_crashes_ && report_crashes_->checked()) {
127 if (GoogleUpdateSettings::SetCollectStatsConsent(true)) 122 if (GoogleUpdateSettings::SetCollectStatsConsent(true))
128 breakpad::InitCrashReporter(std::string()); 123 breakpad::InitCrashReporter(std::string());
129 } else { 124 } else {
130 GoogleUpdateSettings::SetCollectStatsConsent(false); 125 GoogleUpdateSettings::SetCollectStatsConsent(false);
131 } 126 }
132 127
133 if (make_default_ && make_default_->checked()) 128 if (make_default_ && make_default_->checked())
134 ShellIntegration::SetAsDefaultBrowser(); 129 ShellIntegration::SetAsDefaultBrowser();
135 130
136 Done();
137 return true; 131 return true;
138 } 132 }
139 133
140 int FirstRunDialog::GetDialogButtons() const { 134 int FirstRunDialog::GetDialogButtons() const {
141 return ui::DIALOG_BUTTON_OK; 135 return ui::DIALOG_BUTTON_OK;
142 } 136 }
143 137
144 void FirstRunDialog::LinkClicked(views::Link* source, int event_flags) { 138 void FirstRunDialog::LinkClicked(views::Link* source, int event_flags) {
145 platform_util::OpenExternal(profile_, GURL(chrome::kLearnMoreReportingURL)); 139 platform_util::OpenExternal(profile_, GURL(chrome::kLearnMoreReportingURL));
146 } 140 }
141
142 uint32_t FirstRunDialog::Dispatch(const base::NativeEvent& event) {
143 uint32_t action = POST_DISPATCH_PERFORM_DEFAULT;
144 if (!should_show_dialog_)
145 action |= POST_DISPATCH_QUIT_LOOP;
146 return action;
147 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/first_run_dialog.h ('k') | chrome/browser/ui/views/simple_message_box_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698