| 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 = |
| 118 components::UserPrefs::GetInstance()->Lookup(browser_->profile()); |
| 117 prefs->SetBoolean(prefs::kHomePageIsNewTabPage, undo_value_is_ntp_); | 119 prefs->SetBoolean(prefs::kHomePageIsNewTabPage, undo_value_is_ntp_); |
| 118 prefs->SetString(prefs::kHomePage, undo_url_.spec()); | 120 prefs->SetString(prefs::kHomePage, undo_url_.spec()); |
| 119 | 121 |
| 120 HideBubble(); | 122 HideBubble(); |
| 121 } | 123 } |
| 122 | 124 |
| 123 void HomePageUndoBubble::WindowClosing() { | 125 void HomePageUndoBubble::WindowClosing() { |
| 124 // We have to reset |home_page_undo_bubble_| here, not in our destructor, | 126 // 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 | 127 // 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 | 128 // 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); | 172 bool old_is_ntp = prefs->GetBoolean(prefs::kHomePageIsNewTabPage); |
| 171 GURL old_homepage(prefs->GetString(prefs::kHomePage)); | 173 GURL old_homepage(prefs->GetString(prefs::kHomePage)); |
| 172 | 174 |
| 173 prefs->SetBoolean(prefs::kHomePageIsNewTabPage, false); | 175 prefs->SetBoolean(prefs::kHomePageIsNewTabPage, false); |
| 174 prefs->SetString(prefs::kHomePage, new_homepage_url.spec()); | 176 prefs->SetString(prefs::kHomePage, new_homepage_url.spec()); |
| 175 | 177 |
| 176 HomePageUndoBubble::ShowBubble(browser_, old_is_ntp, old_homepage, this); | 178 HomePageUndoBubble::ShowBubble(browser_, old_is_ntp, old_homepage, this); |
| 177 } | 179 } |
| 178 return ui::DragDropTypes::DRAG_NONE; | 180 return ui::DragDropTypes::DRAG_NONE; |
| 179 } | 181 } |
| OLD | NEW |