| 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/local_discovery/privet_notifications.h" | 5 #include "chrome/browser/local_discovery/privet_notifications.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 : profile_(profile) { | 363 : profile_(profile) { |
| 364 } | 364 } |
| 365 | 365 |
| 366 PrivetNotificationDelegate::~PrivetNotificationDelegate() { | 366 PrivetNotificationDelegate::~PrivetNotificationDelegate() { |
| 367 } | 367 } |
| 368 | 368 |
| 369 std::string PrivetNotificationDelegate::id() const { | 369 std::string PrivetNotificationDelegate::id() const { |
| 370 return kPrivetNotificationID; | 370 return kPrivetNotificationID; |
| 371 } | 371 } |
| 372 | 372 |
| 373 void PrivetNotificationDelegate::Display() { | |
| 374 } | |
| 375 | |
| 376 void PrivetNotificationDelegate::Error() { | 373 void PrivetNotificationDelegate::Error() { |
| 377 LOG(ERROR) << "Error displaying privet notification"; | 374 LOG(ERROR) << "Error displaying privet notification"; |
| 378 } | 375 } |
| 379 | 376 |
| 380 void PrivetNotificationDelegate::Close(bool by_user) { | |
| 381 } | |
| 382 | |
| 383 void PrivetNotificationDelegate::Click() { | |
| 384 } | |
| 385 | |
| 386 void PrivetNotificationDelegate::ButtonClick(int button_index) { | 377 void PrivetNotificationDelegate::ButtonClick(int button_index) { |
| 387 if (button_index == 0) { | 378 if (button_index == 0) { |
| 388 ReportPrivetUmaEvent(PRIVET_NOTIFICATION_CLICKED); | 379 ReportPrivetUmaEvent(PRIVET_NOTIFICATION_CLICKED); |
| 389 OpenTab(GURL(kPrivetNotificationOriginUrl)); | 380 OpenTab(GURL(kPrivetNotificationOriginUrl)); |
| 390 } else if (button_index == 1) { | 381 } else if (button_index == 1) { |
| 391 ReportPrivetUmaEvent(PRIVET_DISABLE_NOTIFICATIONS_CLICKED); | 382 ReportPrivetUmaEvent(PRIVET_DISABLE_NOTIFICATIONS_CLICKED); |
| 392 DisableNotifications(); | 383 DisableNotifications(); |
| 393 } | 384 } |
| 394 } | 385 } |
| 395 | 386 |
| 396 void PrivetNotificationDelegate::OpenTab(const GURL& url) { | 387 void PrivetNotificationDelegate::OpenTab(const GURL& url) { |
| 397 Profile* profile_obj = Profile::FromBrowserContext(profile_); | 388 Profile* profile_obj = Profile::FromBrowserContext(profile_); |
| 398 | 389 |
| 399 chrome::NavigateParams params(profile_obj, | 390 chrome::NavigateParams params(profile_obj, |
| 400 url, | 391 url, |
| 401 ui::PAGE_TRANSITION_AUTO_TOPLEVEL); | 392 ui::PAGE_TRANSITION_AUTO_TOPLEVEL); |
| 402 params.disposition = NEW_FOREGROUND_TAB; | 393 params.disposition = NEW_FOREGROUND_TAB; |
| 403 chrome::Navigate(¶ms); | 394 chrome::Navigate(¶ms); |
| 404 } | 395 } |
| 405 | 396 |
| 406 void PrivetNotificationDelegate::DisableNotifications() { | 397 void PrivetNotificationDelegate::DisableNotifications() { |
| 407 Profile* profile_obj = Profile::FromBrowserContext(profile_); | 398 Profile* profile_obj = Profile::FromBrowserContext(profile_); |
| 408 | 399 |
| 409 profile_obj->GetPrefs()->SetBoolean( | 400 profile_obj->GetPrefs()->SetBoolean( |
| 410 prefs::kLocalDiscoveryNotificationsEnabled, | 401 prefs::kLocalDiscoveryNotificationsEnabled, |
| 411 false); | 402 false); |
| 412 } | 403 } |
| 413 | 404 |
| 414 } // namespace local_discovery | 405 } // namespace local_discovery |
| OLD | NEW |