| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 return; | 153 return; |
| 154 } | 154 } |
| 155 registered_web_contents_.push_back( | 155 registered_web_contents_.push_back( |
| 156 WebContentsInfo(web_contents, render_process_id, render_view_id)); | 156 WebContentsInfo(web_contents, render_process_id, render_view_id)); |
| 157 | 157 |
| 158 // Lazy initialize the registrar. | 158 // Lazy initialize the registrar. |
| 159 if (!registrar_.get()) | 159 if (!registrar_.get()) |
| 160 registrar_.reset(new content::NotificationRegistrar()); | 160 registrar_.reset(new content::NotificationRegistrar()); |
| 161 | 161 |
| 162 registrar_->Add(this, | 162 registrar_->Add(this, |
| 163 content::NOTIFICATION_WEB_CONTENTS_SWAPPED, | 163 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 164 content::Source<WebContents>(web_contents)); | 164 content::Source<WebContents>(web_contents)); |
| 165 registrar_->Add(this, | 165 registrar_->Add(this, |
| 166 content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, | 166 content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, |
| 167 content::Source<WebContents>(web_contents)); | 167 content::Source<WebContents>(web_contents)); |
| 168 } | 168 } |
| 169 | 169 |
| 170 // content::NotificationObserver implementation. | 170 // content::NotificationObserver implementation. |
| 171 virtual void Observe(int type, | 171 virtual void Observe(int type, |
| 172 const content::NotificationSource& source, | 172 const content::NotificationSource& source, |
| 173 const content::NotificationDetails& details) OVERRIDE { | 173 const content::NotificationDetails& details) OVERRIDE { |
| 174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 175 DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED || | 175 DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED || |
| 176 type == content::NOTIFICATION_WEB_CONTENTS_SWAPPED); | 176 type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED); |
| 177 | 177 |
| 178 WebContents* web_contents = content::Source<WebContents>(source).ptr(); | 178 WebContents* web_contents = content::Source<WebContents>(source).ptr(); |
| 179 std::vector<WebContentsInfo>::iterator iter = FindWebContents(web_contents); | 179 std::vector<WebContentsInfo>::iterator iter = FindWebContents(web_contents); |
| 180 DCHECK(iter != registered_web_contents_.end()); | 180 DCHECK(iter != registered_web_contents_.end()); |
| 181 int render_process_id = iter->render_process_id; | 181 int render_process_id = iter->render_process_id; |
| 182 int render_view_id = iter->render_view_id; | 182 int render_view_id = iter->render_view_id; |
| 183 registered_web_contents_.erase(iter); | 183 registered_web_contents_.erase(iter); |
| 184 | 184 |
| 185 registrar_->Remove(this, | 185 registrar_->Remove(this, |
| 186 content::NOTIFICATION_WEB_CONTENTS_SWAPPED, | 186 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 187 content::Source<WebContents>(web_contents)); | 187 content::Source<WebContents>(web_contents)); |
| 188 registrar_->Remove(this, | 188 registrar_->Remove(this, |
| 189 content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, | 189 content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, |
| 190 content::Source<WebContents>(web_contents)); | 190 content::Source<WebContents>(web_contents)); |
| 191 | 191 |
| 192 BrowserThread::PostTask(callback_thread_, FROM_HERE, base::Bind( | 192 BrowserThread::PostTask(callback_thread_, FROM_HERE, base::Bind( |
| 193 tab_closed_callback_, render_process_id, render_view_id)); | 193 tab_closed_callback_, render_process_id, render_view_id)); |
| 194 } | 194 } |
| 195 | 195 |
| 196 private: | 196 private: |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 allowed = true; | 427 allowed = true; |
| 428 if (js_api) | 428 if (js_api) |
| 429 check_permission = true; | 429 check_permission = true; |
| 430 } | 430 } |
| 431 | 431 |
| 432 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 432 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 433 base::Bind(callback, check_permission, allowed)); | 433 base::Bind(callback, check_permission, allowed)); |
| 434 } | 434 } |
| 435 | 435 |
| 436 } // namespace speech | 436 } // namespace speech |
| OLD | NEW |