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

Side by Side Diff: chrome/browser/cookie_modal_dialog_gtk.cc

Issue 2964003: Make kCookiePromptExpanded a profile pref rather than a local state pref so it can be synced. (Closed)
Patch Set: Windows changes. Created 10 years, 5 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/cookie_modal_dialog.h" 5 #include "chrome/browser/cookie_modal_dialog.h"
6 6
7 #include "app/gtk_util.h" 7 #include "app/gtk_util.h"
8 #include "app/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/gtk/gtk_chrome_cookie_view.h" 13 #include "chrome/browser/gtk/gtk_chrome_cookie_view.h"
14 #include "chrome/browser/gtk/gtk_chrome_link_button.h" 14 #include "chrome/browser/gtk/gtk_chrome_link_button.h"
15 #include "chrome/browser/gtk/gtk_util.h" 15 #include "chrome/browser/gtk/gtk_util.h"
16 #include "chrome/browser/pref_service.h" 16 #include "chrome/browser/pref_service.h"
17 #include "chrome/browser/profile.h"
17 #include "chrome/browser/views/cookie_prompt_view.h" 18 #include "chrome/browser/views/cookie_prompt_view.h"
18 #include "chrome/browser/tab_contents/tab_contents.h" 19 #include "chrome/browser/tab_contents/tab_contents.h"
19 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
20 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
21 #include "grit/locale_settings.h" 22 #include "grit/locale_settings.h"
22 23
23 namespace {
24
25 void OnExpanderActivate(GtkExpander* expander) {
26 g_browser_process->local_state()->
27 SetBoolean(prefs::kCookiePromptExpanded,
28 gtk_expander_get_expanded(GTK_EXPANDER(expander)));
29 }
30
31 } // namespace
32
33 void CookiePromptModalDialog::CreateAndShowDialog() { 24 void CookiePromptModalDialog::CreateAndShowDialog() {
34 dialog_ = CreateNativeDialog(); 25 dialog_ = CreateNativeDialog();
35 gtk_util::ShowModalDialogWithMinLocalizedWidth(GTK_WIDGET(dialog_), 26 gtk_util::ShowModalDialogWithMinLocalizedWidth(GTK_WIDGET(dialog_),
36 IDS_ALERT_DIALOG_WIDTH_CHARS); 27 IDS_ALERT_DIALOG_WIDTH_CHARS);
37 } 28 }
38 29
39 void CookiePromptModalDialog::AcceptWindow() { 30 void CookiePromptModalDialog::AcceptWindow() {
40 HandleDialogResponse(GTK_DIALOG(dialog_), GTK_RESPONSE_ACCEPT); 31 HandleDialogResponse(GTK_DIALOG(dialog_), GTK_RESPONSE_ACCEPT);
41 } 32 }
42 33
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 GtkWidget* ask_radio = gtk_radio_button_new_with_label_from_widget( 76 GtkWidget* ask_radio = gtk_radio_button_new_with_label_from_widget(
86 GTK_RADIO_BUTTON(remember_radio_), 77 GTK_RADIO_BUTTON(remember_radio_),
87 l10n_util::GetStringUTF8(IDS_COOKIE_ALERT_ASK_RADIO).c_str()); 78 l10n_util::GetStringUTF8(IDS_COOKIE_ALERT_ASK_RADIO).c_str());
88 gtk_box_pack_start(GTK_BOX(radio_box), ask_radio, FALSE, FALSE, 0); 79 gtk_box_pack_start(GTK_BOX(radio_box), ask_radio, FALSE, FALSE, 0);
89 80
90 gtk_box_pack_start(GTK_BOX(content_area), radio_box, FALSE, FALSE, 0); 81 gtk_box_pack_start(GTK_BOX(content_area), radio_box, FALSE, FALSE, 0);
91 82
92 GtkWidget* expander = gtk_expander_new( 83 GtkWidget* expander = gtk_expander_new(
93 l10n_util::GetStringUTF8(IDS_COOKIE_SHOW_DETAILS_LABEL).c_str()); 84 l10n_util::GetStringUTF8(IDS_COOKIE_SHOW_DETAILS_LABEL).c_str());
94 gtk_expander_set_expanded(GTK_EXPANDER(expander), 85 gtk_expander_set_expanded(GTK_EXPANDER(expander),
95 g_browser_process->local_state()-> 86 tab_contents_->profile()->GetPrefs()->
96 GetBoolean(prefs::kCookiePromptExpanded)); 87 GetBoolean(prefs::kCookiePromptExpanded));
97 g_signal_connect(expander, "notify::expanded", 88 g_signal_connect(expander, "notify::expanded",
98 G_CALLBACK(OnExpanderActivate), NULL); 89 G_CALLBACK(OnExpanderActivateThunk), this);
99
100 cookie_view_ = gtk_chrome_cookie_view_new(TRUE); 90 cookie_view_ = gtk_chrome_cookie_view_new(TRUE);
101 gtk_chrome_cookie_view_clear(GTK_CHROME_COOKIE_VIEW(cookie_view_)); 91 gtk_chrome_cookie_view_clear(GTK_CHROME_COOKIE_VIEW(cookie_view_));
102 if (type == CookiePromptModalDialog::DIALOG_TYPE_COOKIE) { 92 if (type == CookiePromptModalDialog::DIALOG_TYPE_COOKIE) {
103 gtk_chrome_cookie_view_display_cookie_string( 93 gtk_chrome_cookie_view_display_cookie_string(
104 GTK_CHROME_COOKIE_VIEW(cookie_view_), 94 GTK_CHROME_COOKIE_VIEW(cookie_view_),
105 origin(), cookie_line()); 95 origin(), cookie_line());
106 } else if (type == CookiePromptModalDialog::DIALOG_TYPE_LOCAL_STORAGE) { 96 } else if (type == CookiePromptModalDialog::DIALOG_TYPE_LOCAL_STORAGE) {
107 gtk_chrome_cookie_view_display_local_storage_item( 97 gtk_chrome_cookie_view_display_local_storage_item(
108 GTK_CHROME_COOKIE_VIEW(cookie_view_), 98 GTK_CHROME_COOKIE_VIEW(cookie_view_),
109 origin().host(), 99 origin().host(),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } else { 139 } else {
150 BlockSiteData(false); 140 BlockSiteData(false);
151 } 141 }
152 gtk_widget_destroy(GTK_WIDGET(dialog)); 142 gtk_widget_destroy(GTK_WIDGET(dialog));
153 143
154 CompleteDialog(); 144 CompleteDialog();
155 145
156 gtk_util::AppModalDismissedUngroupWindows(); 146 gtk_util::AppModalDismissedUngroupWindows();
157 delete this; 147 delete this;
158 } 148 }
149
150 void CookiePromptModalDialog::OnExpanderActivate(GtkWidget* expander,
151 GParamSpec* property) {
152 tab_contents_->profile()->GetPrefs()->
153 SetBoolean(prefs::kCookiePromptExpanded,
154 gtk_expander_get_expanded(GTK_EXPANDER(expander)));
155 }
OLDNEW
« no previous file with comments | « chrome/browser/cookie_modal_dialog.cc ('k') | chrome/browser/sync/glue/synchronized_preferences.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698