| 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/media/media_stream_infobar_delegate.h" | 5 #include "chrome/browser/media/media_stream_infobar_delegate.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/google/google_util.h" | 10 #include "chrome/browser/google/google_util.h" |
| 11 #include "chrome/browser/infobars/infobar.h" | 11 #include "chrome/browser/infobars/infobar.h" |
| 12 #include "chrome/browser/infobars/infobar_manager.h" | |
| 13 #include "chrome/browser/infobars/infobar_service.h" | 12 #include "chrome/browser/infobars/infobar_service.h" |
| 14 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
| 15 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 16 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 17 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 20 | 19 |
| 21 namespace { | 20 namespace { |
| 22 | 21 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 48 if (!infobar_service) { | 47 if (!infobar_service) { |
| 49 // Deny the request if there is no place to show the infobar, e.g. when | 48 // Deny the request if there is no place to show the infobar, e.g. when |
| 50 // the request comes from a background extension page. | 49 // the request comes from a background extension page. |
| 51 controller->Deny(false, content::MEDIA_DEVICE_INVALID_STATE); | 50 controller->Deny(false, content::MEDIA_DEVICE_INVALID_STATE); |
| 52 return false; | 51 return false; |
| 53 } | 52 } |
| 54 | 53 |
| 55 scoped_ptr<InfoBar> infobar(ConfirmInfoBarDelegate::CreateInfoBar( | 54 scoped_ptr<InfoBar> infobar(ConfirmInfoBarDelegate::CreateInfoBar( |
| 56 scoped_ptr<ConfirmInfoBarDelegate>( | 55 scoped_ptr<ConfirmInfoBarDelegate>( |
| 57 new MediaStreamInfoBarDelegate(controller.Pass())))); | 56 new MediaStreamInfoBarDelegate(controller.Pass())))); |
| 58 InfoBarManager* infobar_manager = infobar_service->infobar_manager(); | 57 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { |
| 59 for (size_t i = 0; i < infobar_manager->infobar_count(); ++i) { | 58 InfoBar* old_infobar = infobar_service->infobar_at(i); |
| 60 InfoBar* old_infobar = infobar_manager->infobar_at(i); | |
| 61 if (old_infobar->delegate()->AsMediaStreamInfoBarDelegate()) { | 59 if (old_infobar->delegate()->AsMediaStreamInfoBarDelegate()) { |
| 62 infobar_service->ReplaceInfoBar(old_infobar, infobar.Pass()); | 60 infobar_service->ReplaceInfoBar(old_infobar, infobar.Pass()); |
| 63 return true; | 61 return true; |
| 64 } | 62 } |
| 65 } | 63 } |
| 66 infobar_service->AddInfoBar(infobar.Pass()); | 64 infobar_service->AddInfoBar(infobar.Pass()); |
| 67 return true; | 65 return true; |
| 68 } | 66 } |
| 69 | 67 |
| 70 MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate( | 68 MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 web_contents()->OpenURL(content::OpenURLParams( | 140 web_contents()->OpenURL(content::OpenURLParams( |
| 143 google_util::AppendGoogleLocaleParam( | 141 google_util::AppendGoogleLocaleParam( |
| 144 GURL(chrome::kMediaAccessLearnMoreUrl)), | 142 GURL(chrome::kMediaAccessLearnMoreUrl)), |
| 145 content::Referrer(), | 143 content::Referrer(), |
| 146 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 144 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 147 content::PAGE_TRANSITION_LINK, | 145 content::PAGE_TRANSITION_LINK, |
| 148 false)); | 146 false)); |
| 149 | 147 |
| 150 return false; // Do not dismiss the info bar. | 148 return false; // Do not dismiss the info bar. |
| 151 } | 149 } |
| OLD | NEW |