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/app_list/start_page_service.h" | 5 #include "chrome/browser/ui/app_list/start_page_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 state == SPEECH_RECOGNITION_IN_SPEECH; | 79 state == SPEECH_RECOGNITION_IN_SPEECH; |
80 } | 80 } |
81 | 81 |
82 } // namespace | 82 } // namespace |
83 | 83 |
84 class StartPageService::ProfileDestroyObserver | 84 class StartPageService::ProfileDestroyObserver |
85 : public content::NotificationObserver { | 85 : public content::NotificationObserver { |
86 public: | 86 public: |
87 explicit ProfileDestroyObserver(StartPageService* service) | 87 explicit ProfileDestroyObserver(StartPageService* service) |
88 : service_(service) { | 88 : service_(service) { |
| 89 if (service_->profile()->IsOffTheRecord()) { |
| 90 // We need to be notified when the original profile gets destroyed as well |
| 91 // as the OTR profile, because the original profile will be destroyed |
| 92 // first, and a DCHECK at that time ensures that the OTR profile has 0 |
| 93 // hosts. See http://crbug.com/463419. |
| 94 registrar_.Add( |
| 95 this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
| 96 content::Source<Profile>(service_->profile()->GetOriginalProfile())); |
| 97 } |
89 registrar_.Add(this, | 98 registrar_.Add(this, |
90 chrome::NOTIFICATION_PROFILE_DESTROYED, | 99 chrome::NOTIFICATION_PROFILE_DESTROYED, |
91 content::Source<Profile>(service_->profile())); | 100 content::Source<Profile>(service_->profile())); |
92 } | 101 } |
93 ~ProfileDestroyObserver() override {} | 102 ~ProfileDestroyObserver() override {} |
94 | 103 |
95 private: | 104 private: |
96 // content::NotificationObserver | 105 // content::NotificationObserver |
97 void Observe(int type, | 106 void Observe(int type, |
98 const content::NotificationSource& source, | 107 const content::NotificationSource& source, |
99 const content::NotificationDetails& details) override { | 108 const content::NotificationDetails& details) override { |
100 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 109 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
101 DCHECK_EQ(service_->profile(), content::Source<Profile>(source).ptr()); | 110 DCHECK(service_->profile()->IsSameProfile( |
| 111 content::Source<Profile>(source).ptr())); |
| 112 registrar_.RemoveAll(); |
102 service_->Shutdown(); | 113 service_->Shutdown(); |
103 } | 114 } |
104 | 115 |
105 StartPageService* service_; // Owner of this class. | 116 StartPageService* service_; // Owner of this class. |
106 content::NotificationRegistrar registrar_; | 117 content::NotificationRegistrar registrar_; |
107 | 118 |
108 DISALLOW_COPY_AND_ASSIGN(ProfileDestroyObserver); | 119 DISALLOW_COPY_AND_ASSIGN(ProfileDestroyObserver); |
109 }; | 120 }; |
110 | 121 |
111 class StartPageService::StartPageWebContentsDelegate | 122 class StartPageService::StartPageWebContentsDelegate |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 | 676 |
666 // Check for a new doodle. | 677 // Check for a new doodle. |
667 content::BrowserThread::PostDelayedTask( | 678 content::BrowserThread::PostDelayedTask( |
668 content::BrowserThread::UI, FROM_HERE, | 679 content::BrowserThread::UI, FROM_HERE, |
669 base::Bind(&StartPageService::FetchDoodleJson, | 680 base::Bind(&StartPageService::FetchDoodleJson, |
670 weak_factory_.GetWeakPtr()), | 681 weak_factory_.GetWeakPtr()), |
671 recheck_delay); | 682 recheck_delay); |
672 } | 683 } |
673 | 684 |
674 } // namespace app_list | 685 } // namespace app_list |
OLD | NEW |