| 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/speech_recognition_bubble_controller.h" | 5 #include "chrome/browser/speech/speech_recognition_bubble_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/tab_contents/tab_util.h" | 8 #include "chrome/browser/tab_contents/tab_util.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/public/browser/notification_registrar.h" | 10 #include "content/public/browser/notification_registrar.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 void SpeechRecognitionBubbleController::SetBubbleMessage(int caller_id, | 93 void SpeechRecognitionBubbleController::SetBubbleMessage(int caller_id, |
| 94 const string16& text) { | 94 const string16& text) { |
| 95 ProcessRequestInUiThread(caller_id, REQUEST_SET_MESSAGE, text, 0, 0); | 95 ProcessRequestInUiThread(caller_id, REQUEST_SET_MESSAGE, text, 0, 0); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void SpeechRecognitionBubbleController::UpdateTabContentsSubscription( | 98 void SpeechRecognitionBubbleController::UpdateTabContentsSubscription( |
| 99 int caller_id, ManageSubscriptionAction action) { | 99 int caller_id, ManageSubscriptionAction action) { |
| 100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 101 | 101 |
| 102 // If there are any other bubbles existing for the same TabContents, we would | 102 // If there are any other bubbles existing for the same WebContents, we would |
| 103 // have subscribed to tab close notifications on their behalf and we need to | 103 // have subscribed to tab close notifications on their behalf and we need to |
| 104 // stay registered. So we don't change the subscription in such cases. | 104 // stay registered. So we don't change the subscription in such cases. |
| 105 WebContents* web_contents = bubbles_[caller_id]->GetWebContents(); | 105 WebContents* web_contents = bubbles_[caller_id]->GetWebContents(); |
| 106 for (BubbleCallerIdMap::iterator iter = bubbles_.begin(); | 106 for (BubbleCallerIdMap::iterator iter = bubbles_.begin(); |
| 107 iter != bubbles_.end(); ++iter) { | 107 iter != bubbles_.end(); ++iter) { |
| 108 if (iter->second->GetWebContents() == web_contents && | 108 if (iter->second->GetWebContents() == web_contents && |
| 109 iter->first != caller_id) { | 109 iter->first != caller_id) { |
| 110 // At least one other bubble exists for the same TabContents. So don't | 110 // At least one other bubble exists for the same WebContents. So don't |
| 111 // make any change to the subscription. | 111 // make any change to the subscription. |
| 112 return; | 112 return; |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 if (action == BUBBLE_ADDED) { | 116 if (action == BUBBLE_ADDED) { |
| 117 registrar_->Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 117 registrar_->Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 118 content::Source<WebContents>(web_contents)); | 118 content::Source<WebContents>(web_contents)); |
| 119 } else { | 119 } else { |
| 120 registrar_->Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 120 registrar_->Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 int caller_id, SpeechRecognitionBubble::Button button) { | 235 int caller_id, SpeechRecognitionBubble::Button button) { |
| 236 delegate_->InfoBubbleButtonClicked(caller_id, button); | 236 delegate_->InfoBubbleButtonClicked(caller_id, button); |
| 237 } | 237 } |
| 238 | 238 |
| 239 void SpeechRecognitionBubbleController::InvokeDelegateFocusChanged( | 239 void SpeechRecognitionBubbleController::InvokeDelegateFocusChanged( |
| 240 int caller_id) { | 240 int caller_id) { |
| 241 delegate_->InfoBubbleFocusChanged(caller_id); | 241 delegate_->InfoBubbleFocusChanged(caller_id); |
| 242 } | 242 } |
| 243 | 243 |
| 244 } // namespace speech | 244 } // namespace speech |
| OLD | NEW |