| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/webdata/web_data_service.h" | 5 #include "chrome/browser/webdata/web_data_service.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/task.h" | 9 #include "base/task.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 11 #include "chrome/browser/autofill/autofill_profile.h" | 11 #include "chrome/browser/autofill/autofill_profile.h" |
| 12 #include "chrome/browser/autofill/credit_card.h" | 12 #include "chrome/browser/autofill/credit_card.h" |
| 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/search_engines/template_url.h" | 14 #include "chrome/browser/search_engines/template_url.h" |
| 14 #include "chrome/browser/ui/profile_error_dialog.h" | 15 #include "chrome/browser/ui/profile_error_dialog.h" |
| 15 #include "chrome/browser/webdata/autofill_change.h" | 16 #include "chrome/browser/webdata/autofill_change.h" |
| 16 #include "chrome/browser/webdata/autofill_entry.h" | 17 #include "chrome/browser/webdata/autofill_entry.h" |
| 17 #include "chrome/browser/webdata/autofill_table.h" | 18 #include "chrome/browser/webdata/autofill_table.h" |
| 18 #include "chrome/browser/webdata/keyword_table.h" | 19 #include "chrome/browser/webdata/keyword_table.h" |
| 19 #include "chrome/browser/webdata/logins_table.h" | 20 #include "chrome/browser/webdata/logins_table.h" |
| 20 #include "chrome/browser/webdata/token_service_table.h" | 21 #include "chrome/browser/webdata/token_service_table.h" |
| 21 #include "chrome/browser/webdata/web_apps_table.h" | 22 #include "chrome/browser/webdata/web_apps_table.h" |
| 22 #include "chrome/browser/webdata/web_intents_table.h" | 23 #include "chrome/browser/webdata/web_intents_table.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 35 //////////////////////////////////////////////////////////////////////////////// | 36 //////////////////////////////////////////////////////////////////////////////// |
| 36 // | 37 // |
| 37 // WebDataService implementation. | 38 // WebDataService implementation. |
| 38 // | 39 // |
| 39 //////////////////////////////////////////////////////////////////////////////// | 40 //////////////////////////////////////////////////////////////////////////////// |
| 40 | 41 |
| 41 using base::Time; | 42 using base::Time; |
| 42 using webkit_glue::FormField; | 43 using webkit_glue::FormField; |
| 43 using webkit_glue::PasswordForm; | 44 using webkit_glue::PasswordForm; |
| 44 | 45 |
| 46 namespace { |
| 47 // A task used by WebDataService (for Sync mainly) to inform the |
| 48 // PersonalDataManager living on the UI thread that it needs to refresh. |
| 49 class NotifyOfMultipleAutofillChangesTask : public Task { |
| 50 public: |
| 51 explicit NotifyOfMultipleAutofillChangesTask( |
| 52 WebDataService* web_data_service); |
| 53 virtual ~NotifyOfMultipleAutofillChangesTask(); |
| 54 virtual void Run(); |
| 55 private: |
| 56 WebDataService* web_data_service_; |
| 57 }; |
| 58 |
| 59 NotifyOfMultipleAutofillChangesTask::NotifyOfMultipleAutofillChangesTask( |
| 60 WebDataService* web_data_service) : web_data_service_(web_data_service) { |
| 61 } |
| 62 |
| 63 NotifyOfMultipleAutofillChangesTask::~NotifyOfMultipleAutofillChangesTask() {} |
| 64 |
| 65 void NotifyOfMultipleAutofillChangesTask::Run() { |
| 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 67 |
| 68 NotificationService::current()->Notify( |
| 69 chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED, |
| 70 Source<WebDataService>(web_data_service_), |
| 71 NotificationService::NoDetails()); |
| 72 } |
| 73 |
| 74 } // namespace |
| 75 |
| 45 WDAppImagesResult::WDAppImagesResult() : has_all_images(false) {} | 76 WDAppImagesResult::WDAppImagesResult() : has_all_images(false) {} |
| 46 | 77 |
| 47 WDAppImagesResult::~WDAppImagesResult() {} | 78 WDAppImagesResult::~WDAppImagesResult() {} |
| 48 | 79 |
| 49 WDKeywordsResult::WDKeywordsResult() | 80 WDKeywordsResult::WDKeywordsResult() |
| 50 : default_search_provider_id(0), | 81 : default_search_provider_id(0), |
| 51 builtin_keyword_version(0) { | 82 builtin_keyword_version(0) { |
| 52 } | 83 } |
| 53 | 84 |
| 54 WDKeywordsResult::~WDKeywordsResult() {} | 85 WDKeywordsResult::~WDKeywordsResult() {} |
| 55 | 86 |
| 56 WebDataService::WebDataService() | 87 WebDataService::WebDataService() |
| 57 : is_running_(false), | 88 : is_running_(false), |
| 58 db_(NULL), | 89 db_(NULL), |
| 59 failed_init_(false), | 90 failed_init_(false), |
| 60 should_commit_(false), | 91 should_commit_(false), |
| 61 next_request_handle_(1), | 92 next_request_handle_(1), |
| 62 main_loop_(MessageLoop::current()) { | 93 main_loop_(MessageLoop::current()) { |
| 63 } | 94 } |
| 64 | 95 |
| 96 // static |
| 97 void WebDataService::NotifyOfMultipleAutofillChanges(Profile* profile) { |
| 98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 99 |
| 100 if (!profile) |
| 101 return; |
| 102 |
| 103 WebDataService* web_data_service = |
| 104 profile->GetWebDataService(Profile::EXPLICIT_ACCESS); |
| 105 if (!web_data_service) |
| 106 return; |
| 107 |
| 108 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 109 new NotifyOfMultipleAutofillChangesTask(web_data_service)); |
| 110 } |
| 111 |
| 65 bool WebDataService::Init(const FilePath& profile_path) { | 112 bool WebDataService::Init(const FilePath& profile_path) { |
| 66 FilePath path = profile_path; | 113 FilePath path = profile_path; |
| 67 path = path.Append(chrome::kWebDataFilename); | 114 path = path.Append(chrome::kWebDataFilename); |
| 68 return InitWithPath(path); | 115 return InitWithPath(path); |
| 69 } | 116 } |
| 70 | 117 |
| 71 void WebDataService::Shutdown() { | 118 void WebDataService::Shutdown() { |
| 72 UnloadDatabase(); | 119 UnloadDatabase(); |
| 73 } | 120 } |
| 74 | 121 |
| (...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1439 return result_; | 1486 return result_; |
| 1440 } | 1487 } |
| 1441 | 1488 |
| 1442 void WebDataService::WebDataRequest::RequestComplete() { | 1489 void WebDataService::WebDataRequest::RequestComplete() { |
| 1443 WebDataService* s = service_; | 1490 WebDataService* s = service_; |
| 1444 Task* t = NewRunnableMethod(s, | 1491 Task* t = NewRunnableMethod(s, |
| 1445 &WebDataService::RequestCompleted, | 1492 &WebDataService::RequestCompleted, |
| 1446 handle_); | 1493 handle_); |
| 1447 message_loop_->PostTask(FROM_HERE, t); | 1494 message_loop_->PostTask(FROM_HERE, t); |
| 1448 } | 1495 } |
| OLD | NEW |