OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/speech/chrome_speech_recognition_manager_delegate.h" | 5 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 181 |
182 registrar_->Add(this, | 182 registrar_->Add(this, |
183 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 183 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
184 content::Source<WebContents>(web_contents)); | 184 content::Source<WebContents>(web_contents)); |
185 registrar_->Add(this, | 185 registrar_->Add(this, |
186 content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, | 186 content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, |
187 content::Source<WebContents>(web_contents)); | 187 content::Source<WebContents>(web_contents)); |
188 } | 188 } |
189 | 189 |
190 // content::NotificationObserver implementation. | 190 // content::NotificationObserver implementation. |
191 virtual void Observe(int type, | 191 void Observe(int type, |
192 const content::NotificationSource& source, | 192 const content::NotificationSource& source, |
193 const content::NotificationDetails& details) override { | 193 const content::NotificationDetails& details) override { |
194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
195 DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED || | 195 DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED || |
196 type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED); | 196 type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED); |
197 | 197 |
198 WebContents* web_contents = content::Source<WebContents>(source).ptr(); | 198 WebContents* web_contents = content::Source<WebContents>(source).ptr(); |
199 std::vector<WebContentsInfo>::iterator iter = FindWebContents(web_contents); | 199 std::vector<WebContentsInfo>::iterator iter = FindWebContents(web_contents); |
200 DCHECK(iter != registered_web_contents_.end()); | 200 DCHECK(iter != registered_web_contents_.end()); |
201 int render_process_id = iter->render_process_id; | 201 int render_process_id = iter->render_process_id; |
202 int render_view_id = iter->render_view_id; | 202 int render_view_id = iter->render_view_id; |
203 registered_web_contents_.erase(iter); | 203 registered_web_contents_.erase(iter); |
(...skipping 19 matching lines...) Expand all Loading... |
223 | 223 |
224 ~WebContentsInfo() {} | 224 ~WebContentsInfo() {} |
225 | 225 |
226 content::WebContents* web_contents; | 226 content::WebContents* web_contents; |
227 int render_process_id; | 227 int render_process_id; |
228 int render_view_id; | 228 int render_view_id; |
229 }; | 229 }; |
230 | 230 |
231 friend class base::RefCountedThreadSafe<TabWatcher>; | 231 friend class base::RefCountedThreadSafe<TabWatcher>; |
232 | 232 |
233 virtual ~TabWatcher() { | 233 ~TabWatcher() override { |
234 // Must be destroyed on the UI thread due to |registrar_| non thread-safety. | 234 // Must be destroyed on the UI thread due to |registrar_| non thread-safety. |
235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
236 } | 236 } |
237 | 237 |
238 // Helper function to find the iterator in |registered_web_contents_| which | 238 // Helper function to find the iterator in |registered_web_contents_| which |
239 // contains |web_contents|. | 239 // contains |web_contents|. |
240 std::vector<WebContentsInfo>::iterator FindWebContents( | 240 std::vector<WebContentsInfo>::iterator FindWebContents( |
241 content::WebContents* web_contents) { | 241 content::WebContents* web_contents) { |
242 for (std::vector<WebContentsInfo>::iterator i( | 242 for (std::vector<WebContentsInfo>::iterator i( |
243 registered_web_contents_.begin()); | 243 registered_web_contents_.begin()); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 // Otherwise this should be a regular tab contents. | 443 // Otherwise this should be a regular tab contents. |
444 allowed = true; | 444 allowed = true; |
445 check_permission = true; | 445 check_permission = true; |
446 #endif | 446 #endif |
447 | 447 |
448 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 448 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
449 base::Bind(callback, check_permission, allowed)); | 449 base::Bind(callback, check_permission, allowed)); |
450 } | 450 } |
451 | 451 |
452 } // namespace speech | 452 } // namespace speech |
OLD | NEW |