| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/dom_ui/new_tab_ui.h" | 7 #include "chrome/browser/dom_ui/new_tab_ui.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1539 public: | 1539 public: |
| 1540 MetricsHandler() {} | 1540 MetricsHandler() {} |
| 1541 virtual ~MetricsHandler() {} | 1541 virtual ~MetricsHandler() {} |
| 1542 | 1542 |
| 1543 // DOMMessageHandler implementation. | 1543 // DOMMessageHandler implementation. |
| 1544 virtual void RegisterMessages(); | 1544 virtual void RegisterMessages(); |
| 1545 | 1545 |
| 1546 // Callback which records a user action. | 1546 // Callback which records a user action. |
| 1547 void HandleMetrics(const Value* content); | 1547 void HandleMetrics(const Value* content); |
| 1548 | 1548 |
| 1549 // Callback for the "logEventTime" message. |
| 1550 void HandleLogEventTime(const Value* content); |
| 1551 |
| 1549 private: | 1552 private: |
| 1550 | 1553 |
| 1551 DISALLOW_COPY_AND_ASSIGN(MetricsHandler); | 1554 DISALLOW_COPY_AND_ASSIGN(MetricsHandler); |
| 1552 }; | 1555 }; |
| 1553 | 1556 |
| 1554 void MetricsHandler::RegisterMessages() { | 1557 void MetricsHandler::RegisterMessages() { |
| 1555 dom_ui_->RegisterMessageCallback("metrics", | 1558 dom_ui_->RegisterMessageCallback("metrics", |
| 1556 NewCallback(this, &MetricsHandler::HandleMetrics)); | 1559 NewCallback(this, &MetricsHandler::HandleMetrics)); |
| 1560 |
| 1561 dom_ui_->RegisterMessageCallback("logEventTime", |
| 1562 NewCallback(this, &MetricsHandler::HandleLogEventTime)); |
| 1557 } | 1563 } |
| 1558 | 1564 |
| 1559 void MetricsHandler::HandleMetrics(const Value* content) { | 1565 void MetricsHandler::HandleMetrics(const Value* content) { |
| 1560 if (content && content->GetType() == Value::TYPE_LIST) { | 1566 if (content && content->GetType() == Value::TYPE_LIST) { |
| 1561 const ListValue* list_value = static_cast<const ListValue*>(content); | 1567 const ListValue* list_value = static_cast<const ListValue*>(content); |
| 1562 Value* list_member; | 1568 Value* list_member; |
| 1563 if (list_value->Get(0, &list_member) && | 1569 if (list_value->Get(0, &list_member) && |
| 1564 list_member->GetType() == Value::TYPE_STRING) { | 1570 list_member->GetType() == Value::TYPE_STRING) { |
| 1565 const StringValue* string_value = | 1571 const StringValue* string_value = |
| 1566 static_cast<const StringValue*>(list_member); | 1572 static_cast<const StringValue*>(list_member); |
| 1567 std::wstring wstring_value; | 1573 std::wstring wstring_value; |
| 1568 if (string_value->GetAsString(&wstring_value)) { | 1574 if (string_value->GetAsString(&wstring_value)) { |
| 1569 UserMetrics::RecordComputedAction(wstring_value, dom_ui_->GetProfile()); | 1575 UserMetrics::RecordComputedAction(wstring_value, dom_ui_->GetProfile()); |
| 1570 } | 1576 } |
| 1571 } | 1577 } |
| 1572 } | 1578 } |
| 1573 } | 1579 } |
| 1574 | 1580 |
| 1581 void MetricsHandler::HandleLogEventTime(const Value* content) { |
| 1582 if (content && content->GetType() == Value::TYPE_LIST) { |
| 1583 const ListValue* list_value = static_cast<const ListValue*>(content); |
| 1584 Value* list_member; |
| 1585 if (list_value->Get(0, &list_member) && |
| 1586 list_member->GetType() == Value::TYPE_STRING) { |
| 1587 std::string event_name; |
| 1588 if (list_member->GetAsString(&event_name)) { |
| 1589 dom_ui_->tab_contents()->LogNewTabTime(event_name); |
| 1590 } |
| 1591 } |
| 1592 } |
| 1593 } |
| 1594 |
| 1575 /////////////////////////////////////////////////////////////////////////////// | 1595 /////////////////////////////////////////////////////////////////////////////// |
| 1576 // NewTabPageSetHomepageHandler | 1596 // NewTabPageSetHomepageHandler |
| 1577 | 1597 |
| 1578 // Sets the new tab page as homepage when user clicks on "make this my homepage" | 1598 // Sets the new tab page as homepage when user clicks on "make this my homepage" |
| 1579 // link. | 1599 // link. |
| 1580 class NewTabPageSetHomepageHandler : public DOMMessageHandler { | 1600 class NewTabPageSetHomepageHandler : public DOMMessageHandler { |
| 1581 public: | 1601 public: |
| 1582 NewTabPageSetHomepageHandler() {} | 1602 NewTabPageSetHomepageHandler() {} |
| 1583 virtual ~NewTabPageSetHomepageHandler() {} | 1603 virtual ~NewTabPageSetHomepageHandler() {} |
| 1584 | 1604 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1747 bool NewTabUI::WebResourcesEnabled() { | 1767 bool NewTabUI::WebResourcesEnabled() { |
| 1748 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1768 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 1749 return !command_line->HasSwitch(switches::kDisableWebResources); | 1769 return !command_line->HasSwitch(switches::kDisableWebResources); |
| 1750 } | 1770 } |
| 1751 | 1771 |
| 1752 // static | 1772 // static |
| 1753 bool NewTabUI::FirstRunDisabled() { | 1773 bool NewTabUI::FirstRunDisabled() { |
| 1754 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1774 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 1755 return command_line->HasSwitch(switches::kDisableNewTabFirstRun); | 1775 return command_line->HasSwitch(switches::kDisableNewTabFirstRun); |
| 1756 } | 1776 } |
| OLD | NEW |