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

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

Issue 12092045: Revert 179093 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1397/src/
Patch Set: Created 7 years, 10 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
« no previous file with comments | « chrome/browser/ui/content_settings/content_setting_image_model.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "chrome/browser/google/google_util.h" 10 #include "chrome/browser/google/google_util.h"
12 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/url_constants.h" 12 #include "chrome/common/url_constants.h"
14 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
15 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.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 "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
20 19
21 MediaStreamInfoBarDelegate::~MediaStreamInfoBarDelegate() {} 20 MediaStreamInfoBarDelegate::~MediaStreamInfoBarDelegate() {}
22 21
23 // static 22 // static
24 bool MediaStreamInfoBarDelegate::Create( 23 bool MediaStreamInfoBarDelegate::Create(
25 content::WebContents* web_contents, 24 content::WebContents* web_contents,
26 const content::MediaStreamRequest& request, 25 const content::MediaStreamRequest& request,
27 const content::MediaResponseCallback& callback) { 26 const content::MediaResponseCallback& callback) {
28 Profile* profile = 27 Profile* profile =
29 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 28 Profile::FromBrowserContext(web_contents->GetBrowserContext());
30 TabSpecificContentSettings* content_settings = 29
31 TabSpecificContentSettings::FromWebContents(web_contents);
32 scoped_ptr<MediaStreamDevicesController> controller( 30 scoped_ptr<MediaStreamDevicesController> controller(
33 new MediaStreamDevicesController(profile, content_settings, 31 new MediaStreamDevicesController(profile, request, callback));
34 request, callback)); 32 if (!controller->DismissInfoBarAndTakeActionOnSettings()) {
35 if (controller->DismissInfoBarAndTakeActionOnSettings()) 33 InfoBarService* infobar_service =
36 return false; 34 InfoBarService::FromWebContents(web_contents);
35 InfoBarDelegate* old_infobar = NULL;
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 }
37 42
38 InfoBarService* infobar_service = 43 scoped_ptr<InfoBarDelegate> infobar(
39 InfoBarService::FromWebContents(web_contents); 44 new MediaStreamInfoBarDelegate(infobar_service, controller.release()));
40 InfoBarDelegate* old_infobar = NULL;
41 for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) {
42 old_infobar = infobar_service->GetInfoBarDelegateAt(i)->
43 AsMediaStreamInfoBarDelegate();
44 if (old_infobar) 45 if (old_infobar)
45 break; 46 infobar_service->ReplaceInfoBar(old_infobar, infobar.Pass());
47 else
48 infobar_service->AddInfoBar(infobar.Pass());
49 return true;
46 } 50 }
47 scoped_ptr<InfoBarDelegate> infobar( 51 return false;
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
54 return true;
55 } 52 }
56 53
57 void MediaStreamInfoBarDelegate::InfoBarDismissed() { 54 void MediaStreamInfoBarDelegate::InfoBarDismissed() {
58 // Deny the request if the infobar was closed with the 'x' button, since 55 // Deny the request if the infobar was closed with the 'x' button, since
59 // we don't want WebRTC to be waiting for an answer that will never come. 56 // we don't want WebRTC to be waiting for an answer that will never come.
60 controller_->Deny(false); 57 controller_->Deny(false);
61 } 58 }
62 59
63 gfx::Image* MediaStreamInfoBarDelegate::GetIcon() const { 60 gfx::Image* MediaStreamInfoBarDelegate::GetIcon() const {
64 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( 61 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 117 }
121 118
122 MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate( 119 MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate(
123 InfoBarService* infobar_service, 120 InfoBarService* infobar_service,
124 MediaStreamDevicesController* controller) 121 MediaStreamDevicesController* controller)
125 : ConfirmInfoBarDelegate(infobar_service), 122 : ConfirmInfoBarDelegate(infobar_service),
126 controller_(controller) { 123 controller_(controller) {
127 DCHECK(controller_.get()); 124 DCHECK(controller_.get());
128 DCHECK(controller_->has_audio() || controller_->has_video()); 125 DCHECK(controller_->has_audio() || controller_->has_video());
129 } 126 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/content_settings/content_setting_image_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698