Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(671)

Side by Side Diff: chrome/browser/ui/media_stream_infobar_delegate.cc

Issue 11896028: Add an location bar icon and a content settings bubble for media settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix browser test Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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) { 44 if (old_infobar)
37 old_infobar = infobar_service->GetInfoBarDelegateAt(i)-> 45 break;
38 AsMediaStreamInfoBarDelegate(); 46 }
39 if (old_infobar) 47 scoped_ptr<InfoBarDelegate> infobar(
40 break; 48 new MediaStreamInfoBarDelegate(infobar_service, controller.release()));
41 } 49 if (old_infobar)
50 infobar_service->ReplaceInfoBar(old_infobar, infobar.Pass());
51 else
52 infobar_service->AddInfoBar(infobar.Pass());
42 53
43 scoped_ptr<InfoBarDelegate> infobar( 54 return true;
44 new MediaStreamInfoBarDelegate(infobar_service, controller.release()));
45 if (old_infobar)
46 infobar_service->ReplaceInfoBar(old_infobar, infobar.Pass());
47 else
48 infobar_service->AddInfoBar(infobar.Pass());
49 return true;
50 }
51 return false;
52 } 55 }
53 56
54 void MediaStreamInfoBarDelegate::InfoBarDismissed() { 57 void MediaStreamInfoBarDelegate::InfoBarDismissed() {
55 // Deny the request if the infobar was closed with the 'x' button, since 58 // 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. 59 // we don't want WebRTC to be waiting for an answer that will never come.
57 controller_->Deny(false); 60 controller_->Deny(false);
58 } 61 }
59 62
60 gfx::Image* MediaStreamInfoBarDelegate::GetIcon() const { 63 gfx::Image* MediaStreamInfoBarDelegate::GetIcon() const {
61 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( 64 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 120 }
118 121
119 MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate( 122 MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate(
120 InfoBarService* infobar_service, 123 InfoBarService* infobar_service,
121 MediaStreamDevicesController* controller) 124 MediaStreamDevicesController* controller)
122 : ConfirmInfoBarDelegate(infobar_service), 125 : ConfirmInfoBarDelegate(infobar_service),
123 controller_(controller) { 126 controller_(controller) {
124 DCHECK(controller_.get()); 127 DCHECK(controller_.get());
125 DCHECK(controller_->has_audio() || controller_->has_video()); 128 DCHECK(controller_->has_audio() || controller_->has_video());
126 } 129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698