OLD | NEW |
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/views/home_button.h" | 5 #include "chrome/browser/ui/views/home_button.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 11 #include "components/user_prefs/user_prefs.h" |
11 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
12 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
13 #include "ui/views/bubble/bubble_delegate.h" | 14 #include "ui/views/bubble/bubble_delegate.h" |
14 #include "ui/views/controls/label.h" | 15 #include "ui/views/controls/label.h" |
15 #include "ui/views/controls/link.h" | 16 #include "ui/views/controls/link.h" |
16 #include "ui/views/controls/link_listener.h" | 17 #include "ui/views/controls/link_listener.h" |
17 #include "ui/views/layout/grid_layout.h" | 18 #include "ui/views/layout/grid_layout.h" |
18 #include "ui/views/layout/layout_constants.h" | 19 #include "ui/views/layout/layout_constants.h" |
19 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
20 | 21 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 layout->StartRow(0, 1); | 107 layout->StartRow(0, 1); |
107 layout->AddView(message_label); | 108 layout->AddView(message_label); |
108 | 109 |
109 views::Link* undo_link = new views::Link( | 110 views::Link* undo_link = new views::Link( |
110 l10n_util::GetStringUTF16(IDS_ONE_CLICK_BUBBLE_UNDO)); | 111 l10n_util::GetStringUTF16(IDS_ONE_CLICK_BUBBLE_UNDO)); |
111 undo_link->set_listener(this); | 112 undo_link->set_listener(this); |
112 layout->AddView(undo_link); | 113 layout->AddView(undo_link); |
113 } | 114 } |
114 | 115 |
115 void HomePageUndoBubble::LinkClicked(views::Link* source, int event_flags) { | 116 void HomePageUndoBubble::LinkClicked(views::Link* source, int event_flags) { |
116 PrefService* prefs = PrefServiceFromBrowserContext(browser_->profile()); | 117 PrefService* prefs = components::UserPrefs::Get(browser_->profile()); |
117 prefs->SetBoolean(prefs::kHomePageIsNewTabPage, undo_value_is_ntp_); | 118 prefs->SetBoolean(prefs::kHomePageIsNewTabPage, undo_value_is_ntp_); |
118 prefs->SetString(prefs::kHomePage, undo_url_.spec()); | 119 prefs->SetString(prefs::kHomePage, undo_url_.spec()); |
119 | 120 |
120 HideBubble(); | 121 HideBubble(); |
121 } | 122 } |
122 | 123 |
123 void HomePageUndoBubble::WindowClosing() { | 124 void HomePageUndoBubble::WindowClosing() { |
124 // We have to reset |home_page_undo_bubble_| here, not in our destructor, | 125 // We have to reset |home_page_undo_bubble_| here, not in our destructor, |
125 // because we'll be hidden first, then destroyed asynchronously. If we wait | 126 // because we'll be hidden first, then destroyed asynchronously. If we wait |
126 // to reset this, and the user triggers a call to ShowBubble() while the | 127 // to reset this, and the user triggers a call to ShowBubble() while the |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 bool old_is_ntp = prefs->GetBoolean(prefs::kHomePageIsNewTabPage); | 171 bool old_is_ntp = prefs->GetBoolean(prefs::kHomePageIsNewTabPage); |
171 GURL old_homepage(prefs->GetString(prefs::kHomePage)); | 172 GURL old_homepage(prefs->GetString(prefs::kHomePage)); |
172 | 173 |
173 prefs->SetBoolean(prefs::kHomePageIsNewTabPage, false); | 174 prefs->SetBoolean(prefs::kHomePageIsNewTabPage, false); |
174 prefs->SetString(prefs::kHomePage, new_homepage_url.spec()); | 175 prefs->SetString(prefs::kHomePage, new_homepage_url.spec()); |
175 | 176 |
176 HomePageUndoBubble::ShowBubble(browser_, old_is_ntp, old_homepage, this); | 177 HomePageUndoBubble::ShowBubble(browser_, old_is_ntp, old_homepage, this); |
177 } | 178 } |
178 return ui::DragDropTypes::DRAG_NONE; | 179 return ui::DragDropTypes::DRAG_NONE; |
179 } | 180 } |
OLD | NEW |