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

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

Issue 107033003: Stop using GetDefaultProfile() in Chrome OS implementation of platform_util::OpenExternal() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove is_valid check Created 7 years 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
« no previous file with comments | « chrome/browser/ui/gtk/first_run_dialog.h ('k') | chrome/browser/ui/gtk/protocol_dialog_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/gtk/first_run_dialog.h" 5 #include "chrome/browser/ui/gtk/first_run_dialog.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 19 matching lines...) Expand all
30 #include "ui/base/resource/resource_bundle.h" 30 #include "ui/base/resource/resource_bundle.h"
31 31
32 #if defined(GOOGLE_CHROME_BUILD) 32 #if defined(GOOGLE_CHROME_BUILD)
33 #include "base/prefs/pref_service.h" 33 #include "base/prefs/pref_service.h"
34 #include "chrome/browser/browser_process.h" 34 #include "chrome/browser/browser_process.h"
35 #endif 35 #endif
36 36
37 namespace first_run { 37 namespace first_run {
38 38
39 bool ShowFirstRunDialog(Profile* profile) { 39 bool ShowFirstRunDialog(Profile* profile) {
40 return FirstRunDialog::Show(); 40 return FirstRunDialog::Show(profile);
41 } 41 }
42 42
43 } // namespace first_run 43 } // namespace first_run
44 44
45 // static 45 // static
46 bool FirstRunDialog::Show() { 46 bool FirstRunDialog::Show(Profile* profile) {
47 bool dialog_shown = false; 47 bool dialog_shown = false;
48 #if defined(GOOGLE_CHROME_BUILD) 48 #if defined(GOOGLE_CHROME_BUILD)
49 // If the metrics reporting is managed, we won't ask. 49 // If the metrics reporting is managed, we won't ask.
50 const PrefService::Preference* metrics_reporting_pref = 50 const PrefService::Preference* metrics_reporting_pref =
51 g_browser_process->local_state()->FindPreference( 51 g_browser_process->local_state()->FindPreference(
52 prefs::kMetricsReportingEnabled); 52 prefs::kMetricsReportingEnabled);
53 bool show_reporting_dialog = !metrics_reporting_pref || 53 bool show_reporting_dialog = !metrics_reporting_pref ||
54 !metrics_reporting_pref->IsManaged(); 54 !metrics_reporting_pref->IsManaged();
55 55
56 if (show_reporting_dialog) { 56 if (show_reporting_dialog) {
57 // Object deletes itself. 57 // Object deletes itself.
58 new FirstRunDialog(); 58 new FirstRunDialog(profile);
59 dialog_shown = true; 59 dialog_shown = true;
60 60
61 // TODO(port): it should be sufficient to just run the dialog: 61 // TODO(port): it should be sufficient to just run the dialog:
62 // int response = gtk_dialog_run(GTK_DIALOG(dialog)); 62 // int response = gtk_dialog_run(GTK_DIALOG(dialog));
63 // but that spins a nested message loop and hoses us. :( 63 // but that spins a nested message loop and hoses us. :(
64 // http://code.google.com/p/chromium/issues/detail?id=12552 64 // http://code.google.com/p/chromium/issues/detail?id=12552
65 // Instead, run a loop directly here. 65 // Instead, run a loop directly here.
66 base::MessageLoop::current()->Run(); 66 base::MessageLoop::current()->Run();
67 } 67 }
68 #endif // defined(GOOGLE_CHROME_BUILD) 68 #endif // defined(GOOGLE_CHROME_BUILD)
69 return dialog_shown; 69 return dialog_shown;
70 } 70 }
71 71
72 FirstRunDialog::FirstRunDialog() 72 FirstRunDialog::FirstRunDialog(Profile* profile)
73 : dialog_(NULL), 73 : profile_(profile),
74 dialog_(NULL),
74 report_crashes_(NULL), 75 report_crashes_(NULL),
75 make_default_(NULL) { 76 make_default_(NULL) {
76 ShowReportingDialog(); 77 ShowReportingDialog();
77 } 78 }
78 79
79 FirstRunDialog::~FirstRunDialog() { 80 FirstRunDialog::~FirstRunDialog() {
80 } 81 }
81 82
82 void FirstRunDialog::ShowReportingDialog() { 83 void FirstRunDialog::ShowReportingDialog() {
83 dialog_ = gtk_dialog_new_with_buttons( 84 dialog_ = gtk_dialog_new_with_buttons(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // If selected set as default browser. 144 // If selected set as default browser.
144 if (make_default_ && 145 if (make_default_ &&
145 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(make_default_))) { 146 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(make_default_))) {
146 ShellIntegration::SetAsDefaultBrowser(); 147 ShellIntegration::SetAsDefaultBrowser();
147 } 148 }
148 149
149 FirstRunDone(); 150 FirstRunDone();
150 } 151 }
151 152
152 void FirstRunDialog::OnLearnMoreLinkClicked(GtkButton* button) { 153 void FirstRunDialog::OnLearnMoreLinkClicked(GtkButton* button) {
153 platform_util::OpenExternal(GURL(chrome::kLearnMoreReportingURL)); 154 platform_util::OpenExternal(profile_, GURL(chrome::kLearnMoreReportingURL));
154 } 155 }
155 156
156 void FirstRunDialog::FirstRunDone() { 157 void FirstRunDialog::FirstRunDone() {
157 first_run::SetShouldShowWelcomePage(); 158 first_run::SetShouldShowWelcomePage();
158 159
159 if (dialog_) 160 if (dialog_)
160 gtk_widget_destroy(dialog_); 161 gtk_widget_destroy(dialog_);
161 base::MessageLoop::current()->Quit(); 162 base::MessageLoop::current()->Quit();
162 delete this; 163 delete this;
163 } 164 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/first_run_dialog.h ('k') | chrome/browser/ui/gtk/protocol_dialog_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698