| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar/home_button.h" | 5 #include "chrome/browser/ui/views/toolbar/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" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // 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 |
| 128 // window is hidden but not destroyed, GetWidget()->Close() would be | 128 // window is hidden but not destroyed, GetWidget()->Close() would be |
| 129 // called twice. | 129 // called twice. |
| 130 DCHECK_EQ(this, home_page_undo_bubble_); | 130 DCHECK_EQ(this, home_page_undo_bubble_); |
| 131 home_page_undo_bubble_ = NULL; | 131 home_page_undo_bubble_ = NULL; |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace | 134 } // namespace |
| 135 | 135 |
| 136 | 136 |
| 137 // HomeImageButton ----------------------------------------------------------- | 137 // HomeButton ----------------------------------------------------------- |
| 138 | 138 |
| 139 HomeImageButton::HomeImageButton( | 139 HomeButton::HomeButton( |
| 140 views::ButtonListener* listener, | 140 views::ButtonListener* listener, |
| 141 Browser* browser) | 141 Browser* browser) |
| 142 : views::ImageButton(listener), | 142 : ToolbarButton(listener, NULL), |
| 143 browser_(browser) { | 143 browser_(browser) { |
| 144 } | 144 } |
| 145 | 145 |
| 146 HomeImageButton::~HomeImageButton() { | 146 HomeButton::~HomeButton() { |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool HomeImageButton::GetDropFormats( | 149 bool HomeButton::GetDropFormats( |
| 150 int* formats, | 150 int* formats, |
| 151 std::set<OSExchangeData::CustomFormat>* custom_formats) { | 151 std::set<OSExchangeData::CustomFormat>* custom_formats) { |
| 152 *formats = ui::OSExchangeData::URL; | 152 *formats = ui::OSExchangeData::URL; |
| 153 return true; | 153 return true; |
| 154 } | 154 } |
| 155 | 155 |
| 156 bool HomeImageButton::CanDrop(const OSExchangeData& data) { | 156 bool HomeButton::CanDrop(const OSExchangeData& data) { |
| 157 return data.HasURL(); | 157 return data.HasURL(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 int HomeImageButton::OnDragUpdated(const ui::DropTargetEvent& event) { | 160 int HomeButton::OnDragUpdated(const ui::DropTargetEvent& event) { |
| 161 return (event.source_operations() & ui::DragDropTypes::DRAG_LINK) ? | 161 return (event.source_operations() & ui::DragDropTypes::DRAG_LINK) ? |
| 162 ui::DragDropTypes::DRAG_LINK : ui::DragDropTypes::DRAG_NONE; | 162 ui::DragDropTypes::DRAG_LINK : ui::DragDropTypes::DRAG_NONE; |
| 163 } | 163 } |
| 164 | 164 |
| 165 int HomeImageButton::OnPerformDrop(const ui::DropTargetEvent& event) { | 165 int HomeButton::OnPerformDrop(const ui::DropTargetEvent& event) { |
| 166 GURL new_homepage_url; | 166 GURL new_homepage_url; |
| 167 string16 title; | 167 string16 title; |
| 168 if (event.data().GetURLAndTitle(&new_homepage_url, &title) && | 168 if (event.data().GetURLAndTitle(&new_homepage_url, &title) && |
| 169 new_homepage_url.is_valid()) { | 169 new_homepage_url.is_valid()) { |
| 170 PrefService* prefs = browser_->profile()->GetPrefs(); | 170 PrefService* prefs = browser_->profile()->GetPrefs(); |
| 171 bool old_is_ntp = prefs->GetBoolean(prefs::kHomePageIsNewTabPage); | 171 bool old_is_ntp = prefs->GetBoolean(prefs::kHomePageIsNewTabPage); |
| 172 GURL old_homepage(prefs->GetString(prefs::kHomePage)); | 172 GURL old_homepage(prefs->GetString(prefs::kHomePage)); |
| 173 | 173 |
| 174 prefs->SetBoolean(prefs::kHomePageIsNewTabPage, false); | 174 prefs->SetBoolean(prefs::kHomePageIsNewTabPage, false); |
| 175 prefs->SetString(prefs::kHomePage, new_homepage_url.spec()); | 175 prefs->SetString(prefs::kHomePage, new_homepage_url.spec()); |
| 176 | 176 |
| 177 HomePageUndoBubble::ShowBubble(browser_, old_is_ntp, old_homepage, this); | 177 HomePageUndoBubble::ShowBubble(browser_, old_is_ntp, old_homepage, this); |
| 178 } | 178 } |
| 179 return ui::DragDropTypes::DRAG_NONE; | 179 return ui::DragDropTypes::DRAG_NONE; |
| 180 } | 180 } |
| OLD | NEW |