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

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

Issue 231733005: Delete the GTK+ port of Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remerge to ToT Created 6 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/gtk/chrome_browser_main_extra_parts_gtk.h"
6
7 #include <gtk/gtk.h>
8
9 #include "base/command_line.h"
10 #include "chrome/browser/chrome_browser_main.h"
11 #include "chrome/common/chrome_switches.h"
12 #include "grit/chromium_strings.h"
13 #include "grit/generated_resources.h"
14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/gtk_util.h"
17
18 ChromeBrowserMainExtraPartsGtk::ChromeBrowserMainExtraPartsGtk() {
19 }
20
21 void ChromeBrowserMainExtraPartsGtk::PreEarlyInitialization() {
22 DetectRunningAsRoot();
23 }
24
25
26 void ChromeBrowserMainExtraPartsGtk::DetectRunningAsRoot() {
27 if (geteuid() == 0) {
28 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
29 if (command_line.HasSwitch(switches::kUserDataDir))
30 return;
31
32 gfx::GtkInitFromCommandLine(command_line);
33
34 // Get just enough of our resource machinery up so we can extract the
35 // locale appropriate string. Note that the GTK implementation ignores the
36 // passed in parameter and checks the LANG environment variables instead.
37 ResourceBundle::InitSharedInstanceWithLocale(std::string(), NULL);
38
39 std::string message = l10n_util::GetStringFUTF8(
40 IDS_REFUSE_TO_RUN_AS_ROOT,
41 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
42 GtkWidget* dialog = gtk_message_dialog_new(
43 NULL,
44 static_cast<GtkDialogFlags>(0),
45 GTK_MESSAGE_ERROR,
46 GTK_BUTTONS_CLOSE,
47 "%s",
48 message.c_str());
49
50 LOG(ERROR) << "Startup refusing to run as root.";
51 message = l10n_util::GetStringFUTF8(
52 IDS_REFUSE_TO_RUN_AS_ROOT_2,
53 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
54 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
55 "%s",
56 message.c_str());
57
58 message = l10n_util::GetStringUTF8(IDS_PRODUCT_NAME);
59 gtk_window_set_title(GTK_WINDOW(dialog), message.c_str());
60
61 gtk_dialog_run(GTK_DIALOG(dialog));
62 gtk_widget_destroy(dialog);
63 exit(EXIT_FAILURE);
64 }
65 }
66
67 // static
68 void ChromeBrowserMainExtraPartsGtk::ShowMessageBox(const char* message) {
69 GtkWidget* dialog = gtk_message_dialog_new(
70 NULL,
71 static_cast<GtkDialogFlags>(0),
72 GTK_MESSAGE_ERROR,
73 GTK_BUTTONS_CLOSE,
74 "%s",
75 message);
76
77 gtk_window_set_title(GTK_WINDOW(dialog), message);
78 gtk_dialog_run(GTK_DIALOG(dialog));
79 gtk_widget_destroy(dialog);
80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698