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

Side by Side Diff: extensions/shell/browser/shell_speech_recognition_manager_delegate.cc

Issue 1032553009: favor DCHECK_CURRENTLY_ON for better logs in extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « extensions/browser/guest_view/guest_view_message_filter.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/shell/browser/shell_speech_recognition_manager_delegate.h" 5 #include "extensions/shell/browser/shell_speech_recognition_manager_delegate.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/render_view_host.h" 9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/speech_recognition_manager.h" 10 #include "content/public/browser/speech_recognition_manager.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 void ShellSpeechRecognitionManagerDelegate::GetDiagnosticInformation( 67 void ShellSpeechRecognitionManagerDelegate::GetDiagnosticInformation(
68 bool* can_report_metrics, 68 bool* can_report_metrics,
69 std::string* hardware_info) { 69 std::string* hardware_info) {
70 } 70 }
71 71
72 void ShellSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed( 72 void ShellSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed(
73 int session_id, 73 int session_id,
74 base::Callback<void(bool ask_user, bool is_allowed)> callback) { 74 base::Callback<void(bool ask_user, bool is_allowed)> callback) {
75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 75 DCHECK_CURRENTLY_ON(BrowserThread::IO);
76 76
77 const content::SpeechRecognitionSessionContext& context = 77 const content::SpeechRecognitionSessionContext& context =
78 SpeechRecognitionManager::GetInstance()->GetSessionContext(session_id); 78 SpeechRecognitionManager::GetInstance()->GetSessionContext(session_id);
79 79
80 // Make sure that initiators (extensions/web pages) properly set the 80 // Make sure that initiators (extensions/web pages) properly set the
81 // |render_process_id| field, which is needed later to retrieve the profile. 81 // |render_process_id| field, which is needed later to retrieve the profile.
82 DCHECK_NE(context.render_process_id, 0); 82 DCHECK_NE(context.render_process_id, 0);
83 83
84 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 84 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
85 base::Bind(&CheckRenderViewType, 85 base::Bind(&CheckRenderViewType,
(...skipping 11 matching lines...) Expand all
97 int render_process_id) { 97 int render_process_id) {
98 // TODO(zork): Determine where this preference should come from. 98 // TODO(zork): Determine where this preference should come from.
99 return true; 99 return true;
100 } 100 }
101 101
102 // static 102 // static
103 void ShellSpeechRecognitionManagerDelegate::CheckRenderViewType( 103 void ShellSpeechRecognitionManagerDelegate::CheckRenderViewType(
104 base::Callback<void(bool ask_user, bool is_allowed)> callback, 104 base::Callback<void(bool ask_user, bool is_allowed)> callback,
105 int render_process_id, 105 int render_process_id,
106 int render_view_id) { 106 int render_view_id) {
107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 107 DCHECK_CURRENTLY_ON(BrowserThread::UI);
108 const content::RenderViewHost* render_view_host = 108 const content::RenderViewHost* render_view_host =
109 content::RenderViewHost::FromID(render_process_id, render_view_id); 109 content::RenderViewHost::FromID(render_process_id, render_view_id);
110 bool allowed = false; 110 bool allowed = false;
111 bool check_permission = false; 111 bool check_permission = false;
112 112
113 if (render_view_host) { 113 if (render_view_host) {
114 WebContents* web_contents = 114 WebContents* web_contents =
115 WebContents::FromRenderViewHost(render_view_host); 115 WebContents::FromRenderViewHost(render_view_host);
116 extensions::ViewType view_type = extensions::GetViewType(web_contents); 116 extensions::ViewType view_type = extensions::GetViewType(web_contents);
117 117
118 if (view_type == extensions::VIEW_TYPE_APP_WINDOW || 118 if (view_type == extensions::VIEW_TYPE_APP_WINDOW ||
119 view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { 119 view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
120 allowed = true; 120 allowed = true;
121 check_permission = true; 121 check_permission = true;
122 } else { 122 } else {
123 LOG(WARNING) << "Speech recognition only supported in Apps."; 123 LOG(WARNING) << "Speech recognition only supported in Apps.";
124 } 124 }
125 } 125 }
126 126
127 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 127 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
128 base::Bind(callback, check_permission, allowed)); 128 base::Bind(callback, check_permission, allowed));
129 } 129 }
130 130
131 } // namespace speech 131 } // namespace speech
132 } // namespace extensions 132 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/guest_view/guest_view_message_filter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698