Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: chrome/browser/renderer_host/render_view_host.cc

Issue 4591001: Display a warning when autofill is disabled for a website. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile on ChromeOS... Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/renderer_host/render_view_host.h" 5 #include "chrome/browser/renderer_host/render_view_host.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 1683
1684 RenderViewHostDelegate::RendererManagement* management_delegate = 1684 RenderViewHostDelegate::RendererManagement* management_delegate =
1685 delegate_->GetRendererManagementDelegate(); 1685 delegate_->GetRendererManagementDelegate();
1686 if (management_delegate) { 1686 if (management_delegate) {
1687 management_delegate->ShouldClosePage( 1687 management_delegate->ShouldClosePage(
1688 unload_ack_is_for_cross_site_transition_, proceed); 1688 unload_ack_is_for_cross_site_transition_, proceed);
1689 } 1689 }
1690 } 1690 }
1691 1691
1692 void RenderViewHost::OnQueryFormFieldAutoFill( 1692 void RenderViewHost::OnQueryFormFieldAutoFill(
1693 int query_id, bool form_autofilled, const webkit_glue::FormField& field) { 1693 int query_id, bool field_autofilled, const webkit_glue::FormField& field) {
1694 ResetAutoFillState(query_id);
1695
1696 // We first query the autofill delegate for suggestions. We keep track of the
1697 // results it gives us, which we will later combine with the autocomplete
1698 // suggestions.
1694 RenderViewHostDelegate::AutoFill* autofill_delegate = 1699 RenderViewHostDelegate::AutoFill* autofill_delegate =
1695 delegate_->GetAutoFillDelegate(); 1700 delegate_->GetAutoFillDelegate();
1696 // We first save the AutoFill delegate's suggestions. Then we fetch the 1701 if (autofill_delegate) {
1697 // Autocomplete delegate's suggestions and send the combined results back to 1702 autofill_delegate->GetAutoFillSuggestions(field_autofilled, field);
1698 // the render view.
1699 if (autofill_delegate &&
1700 autofill_delegate->GetAutoFillSuggestions(query_id,
1701 form_autofilled,
1702 field)) {
1703 } else {
1704 // No suggestions provided, so supply an empty vector as the results.
1705 AutoFillSuggestionsReturned(query_id,
1706 std::vector<string16>(),
1707 std::vector<string16>(),
1708 std::vector<string16>(),
1709 std::vector<int>());
1710 } 1703 }
1711 1704
1705 // Now query the Autocomplete delegate for suggestions. These will be combined
1706 // with the saved autofill suggestions in |AutocompleteSuggestionsReturned()|.
1712 RenderViewHostDelegate::Autocomplete* autocomplete_delegate = 1707 RenderViewHostDelegate::Autocomplete* autocomplete_delegate =
1713 delegate_->GetAutocompleteDelegate(); 1708 delegate_->GetAutocompleteDelegate();
1714 if (autocomplete_delegate && 1709 if (autocomplete_delegate) {
1715 autocomplete_delegate->GetAutocompleteSuggestions( 1710 autocomplete_delegate->GetAutocompleteSuggestions(field.name(),
1716 query_id, field.name(), field.value())) { 1711 field.value());
1717 } else { 1712 } else {
1718 // No suggestions provided, so send an empty vector as the results. 1713 AutocompleteSuggestionsReturned(std::vector<string16>());
1719 AutocompleteSuggestionsReturned(query_id, std::vector<string16>());
1720 } 1714 }
1721 } 1715 }
1722 1716
1723 void RenderViewHost::OnDidShowAutoFillSuggestions() { 1717 void RenderViewHost::OnDidShowAutoFillSuggestions() {
1724 NotificationService::current()->Notify( 1718 NotificationService::current()->Notify(
1725 NotificationType::AUTOFILL_DID_SHOW_SUGGESTIONS, 1719 NotificationType::AUTOFILL_DID_SHOW_SUGGESTIONS,
1726 Source<RenderViewHost>(this), 1720 Source<RenderViewHost>(this),
1727 NotificationService::NoDetails()); 1721 NotificationService::NoDetails());
1728 } 1722 }
1729 1723
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 autofill_delegate->FillAutoFillFormData(query_id, form, unique_id); 1757 autofill_delegate->FillAutoFillFormData(query_id, form, unique_id);
1764 } 1758 }
1765 1759
1766 void RenderViewHost::OnDidFillAutoFillFormData() { 1760 void RenderViewHost::OnDidFillAutoFillFormData() {
1767 NotificationService::current()->Notify( 1761 NotificationService::current()->Notify(
1768 NotificationType::AUTOFILL_DID_FILL_FORM_DATA, 1762 NotificationType::AUTOFILL_DID_FILL_FORM_DATA,
1769 Source<RenderViewHost>(this), 1763 Source<RenderViewHost>(this),
1770 NotificationService::NoDetails()); 1764 NotificationService::NoDetails());
1771 } 1765 }
1772 1766
1767 void RenderViewHost::ResetAutoFillState(int query_id) {
1768 autofill_query_id_ = query_id;
1769
1770 autofill_values_.clear();
1771 autofill_labels_.clear();
1772 autofill_icons_.clear();
1773 autofill_unique_ids_.clear();
1774 }
1775
1773 void RenderViewHost::AutoFillSuggestionsReturned( 1776 void RenderViewHost::AutoFillSuggestionsReturned(
1774 int query_id, 1777 const std::vector<string16>& values,
1775 const std::vector<string16>& names,
1776 const std::vector<string16>& labels, 1778 const std::vector<string16>& labels,
1777 const std::vector<string16>& icons, 1779 const std::vector<string16>& icons,
1778 const std::vector<int>& unique_ids) { 1780 const std::vector<int>& unique_ids) {
1779 autofill_values_.assign(names.begin(), names.end()); 1781 autofill_values_.assign(values.begin(), values.end());
1780 autofill_labels_.assign(labels.begin(), labels.end()); 1782 autofill_labels_.assign(labels.begin(), labels.end());
1781 autofill_icons_.assign(icons.begin(), icons.end()); 1783 autofill_icons_.assign(icons.begin(), icons.end());
1782 autofill_unique_ids_.assign(unique_ids.begin(), unique_ids.end()); 1784 autofill_unique_ids_.assign(unique_ids.begin(), unique_ids.end());
1783 } 1785 }
1784 1786
1785 void RenderViewHost::AutocompleteSuggestionsReturned( 1787 void RenderViewHost::AutocompleteSuggestionsReturned(
1786 int query_id, const std::vector<string16>& suggestions) { 1788 const std::vector<string16>& suggestions) {
1787 // Combine AutoFill and Autocomplete values into values and labels. 1789 // Combine AutoFill and Autocomplete values into values and labels.
1788 for (size_t i = 0; i < suggestions.size(); ++i) { 1790 for (size_t i = 0; i < suggestions.size(); ++i) {
1789 bool unique = true; 1791 bool unique = true;
1790 for (size_t j = 0; j < autofill_values_.size(); ++j) { 1792 for (size_t j = 0; j < autofill_values_.size(); ++j) {
1793 // TODO(isherman): Why just when the label is empty?
1791 // If the AutoFill label is empty, we need to make sure we don't add a 1794 // If the AutoFill label is empty, we need to make sure we don't add a
1792 // duplicate value. 1795 // duplicate value.
1793 if (autofill_labels_[j].empty() && 1796 if (autofill_labels_[j].empty() &&
1794 autofill_values_[j] == suggestions[i]) { 1797 autofill_values_[j] == suggestions[i]) {
1795 unique = false; 1798 unique = false;
1796 break; 1799 break;
1797 } 1800 }
1798 } 1801 }
1799 1802
1800 if (unique) { 1803 if (unique) {
1801 autofill_values_.push_back(suggestions[i]); 1804 autofill_values_.push_back(suggestions[i]);
1802 autofill_labels_.push_back(string16()); 1805 autofill_labels_.push_back(string16());
1803 autofill_icons_.push_back(string16()); 1806 autofill_icons_.push_back(string16());
1804 autofill_unique_ids_.push_back(0); // 0 means no profile. 1807 autofill_unique_ids_.push_back(0); // 0 means no profile.
1805 } 1808 }
1806 } 1809 }
1807 1810
1808 Send(new ViewMsg_AutoFillSuggestionsReturned(routing_id(), 1811 Send(new ViewMsg_AutoFillSuggestionsReturned(routing_id(),
1809 query_id, 1812 autofill_query_id_,
1810 autofill_values_, 1813 autofill_values_,
1811 autofill_labels_, 1814 autofill_labels_,
1812 autofill_icons_, 1815 autofill_icons_,
1813 autofill_unique_ids_)); 1816 autofill_unique_ids_));
1814 } 1817 }
1815 1818
1816 void RenderViewHost::AutoFillFormDataFilled(int query_id, 1819 void RenderViewHost::AutoFillFormDataFilled(int query_id,
1817 const FormData& form) { 1820 const FormData& form) {
1818 Send(new ViewMsg_AutoFillFormDataFilled(routing_id(), query_id, form)); 1821 Send(new ViewMsg_AutoFillFormDataFilled(routing_id(), query_id, form));
1819 } 1822 }
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
2224 } 2227 }
2225 #else 2228 #else
2226 void RenderViewHost::OnPagesReadyForPreview(int fd_in_browser) { 2229 void RenderViewHost::OnPagesReadyForPreview(int fd_in_browser) {
2227 // TODO(kmadhusu): Function definition needs to be changed. 2230 // TODO(kmadhusu): Function definition needs to be changed.
2228 // fd_in_browser should be the file descriptor of the metafile. 2231 // fd_in_browser should be the file descriptor of the metafile.
2229 2232
2230 // Send the printingDone msg for now. 2233 // Send the printingDone msg for now.
2231 Send(new ViewMsg_PrintingDone(routing_id(), -1, true)); 2234 Send(new ViewMsg_PrintingDone(routing_id(), -1, true));
2232 } 2235 }
2233 #endif 2236 #endif
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_view_host.h ('k') | chrome/browser/renderer_host/render_view_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698