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/ui/media_stream_infobar_delegate.h" | 5 #include "chrome/browser/ui/media_stream_infobar_delegate.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/api/infobars/infobar_service.h" | 9 #include "chrome/browser/api/infobars/infobar_service.h" |
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | |
10 #include "chrome/browser/google/google_util.h" | 11 #include "chrome/browser/google/google_util.h" |
11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
13 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
14 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
15 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
16 #include "grit/theme_resources.h" | 17 #include "grit/theme_resources.h" |
17 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
18 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
19 | 20 |
20 MediaStreamInfoBarDelegate::~MediaStreamInfoBarDelegate() {} | 21 MediaStreamInfoBarDelegate::~MediaStreamInfoBarDelegate() {} |
21 | 22 |
22 // static | 23 // static |
23 bool MediaStreamInfoBarDelegate::Create( | 24 bool MediaStreamInfoBarDelegate::Create( |
24 content::WebContents* web_contents, | 25 content::WebContents* web_contents, |
25 const content::MediaStreamRequest& request, | 26 const content::MediaStreamRequest& request, |
26 const content::MediaResponseCallback& callback) { | 27 const content::MediaResponseCallback& callback) { |
27 Profile* profile = | 28 Profile* profile = |
28 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 29 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
30 TabSpecificContentSettings* content_settings = | |
31 TabSpecificContentSettings::FromWebContents(web_contents); | |
32 scoped_ptr<MediaStreamDevicesController> controller( | |
33 new MediaStreamDevicesController(profile, content_settings, | |
34 request, callback)); | |
35 if (controller->DismissInfoBarAndTakeActionOnSettings()) | |
36 return false; | |
29 | 37 |
30 scoped_ptr<MediaStreamDevicesController> controller( | 38 InfoBarService* infobar_service = |
31 new MediaStreamDevicesController(profile, request, callback)); | 39 InfoBarService::FromWebContents(web_contents); |
32 if (!controller->DismissInfoBarAndTakeActionOnSettings()) { | 40 InfoBarDelegate* old_infobar = NULL; |
33 InfoBarService* infobar_service = | 41 for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) { |
34 InfoBarService::FromWebContents(web_contents); | 42 old_infobar = infobar_service->GetInfoBarDelegateAt(i)-> |
35 InfoBarDelegate* old_infobar = NULL; | 43 AsMediaStreamInfoBarDelegate(); |
36 for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) { | |
37 old_infobar = infobar_service->GetInfoBarDelegateAt(i)-> | |
38 AsMediaStreamInfoBarDelegate(); | |
39 if (old_infobar) | |
40 break; | |
41 } | |
42 | |
43 scoped_ptr<InfoBarDelegate> infobar( | |
44 new MediaStreamInfoBarDelegate(infobar_service, controller.release())); | |
45 if (old_infobar) | 44 if (old_infobar) |
46 infobar_service->ReplaceInfoBar(old_infobar, infobar.Pass()); | 45 break; |
47 else | |
48 infobar_service->AddInfoBar(infobar.Pass()); | |
49 return true; | |
50 } | 46 } |
51 return false; | 47 scoped_ptr<InfoBarDelegate> infobar( |
48 new MediaStreamInfoBarDelegate(infobar_service, controller.release())); | |
49 if (old_infobar) | |
50 infobar_service->ReplaceInfoBar(old_infobar, infobar.Pass()); | |
51 else | |
52 infobar_service->AddInfoBar(infobar.Pass()); | |
53 return true; | |
no longer working on chromium
2013/01/23 11:48:06
nit, add an empty line.
markusheintz_
2013/01/23 12:18:33
Done.
| |
52 } | 54 } |
53 | 55 |
54 void MediaStreamInfoBarDelegate::InfoBarDismissed() { | 56 void MediaStreamInfoBarDelegate::InfoBarDismissed() { |
55 // Deny the request if the infobar was closed with the 'x' button, since | 57 // Deny the request if the infobar was closed with the 'x' button, since |
56 // we don't want WebRTC to be waiting for an answer that will never come. | 58 // we don't want WebRTC to be waiting for an answer that will never come. |
57 controller_->Deny(false); | 59 controller_->Deny(false); |
58 } | 60 } |
59 | 61 |
60 gfx::Image* MediaStreamInfoBarDelegate::GetIcon() const { | 62 gfx::Image* MediaStreamInfoBarDelegate::GetIcon() const { |
61 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 63 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 } | 119 } |
118 | 120 |
119 MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate( | 121 MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate( |
120 InfoBarService* infobar_service, | 122 InfoBarService* infobar_service, |
121 MediaStreamDevicesController* controller) | 123 MediaStreamDevicesController* controller) |
122 : ConfirmInfoBarDelegate(infobar_service), | 124 : ConfirmInfoBarDelegate(infobar_service), |
123 controller_(controller) { | 125 controller_(controller) { |
124 DCHECK(controller_.get()); | 126 DCHECK(controller_.get()); |
125 DCHECK(controller_->has_audio() || controller_->has_video()); | 127 DCHECK(controller_->has_audio() || controller_->has_video()); |
126 } | 128 } |
OLD | NEW |