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

Side by Side Diff: chrome/browser/extensions/extension_tab_helper.cc

Issue 8727024: Save the oauth client id used in App Notification setup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed nits Created 9 years 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/extensions/extension_tab_helper.h ('k') | chrome/chrome_tests.gypi » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extensions/extension_tab_helper.h" 5 #include "chrome/browser/extensions/extension_tab_helper.h"
6 6
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/webstore_inline_installer.h" 8 #include "chrome/browser/extensions/webstore_inline_installer.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sessions/restore_tab_helper.h" 10 #include "chrome/browser/sessions/restore_tab_helper.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 content::RenderProcessHost* process = 172 content::RenderProcessHost* process =
173 tab_contents_wrapper()->render_view_host()->process(); 173 tab_contents_wrapper()->render_view_host()->process();
174 const Extension* extension = 174 const Extension* extension =
175 extension_service->GetInstalledApp(requestor_url); 175 extension_service->GetInstalledApp(requestor_url);
176 bool allowed = 176 bool allowed =
177 extension && 177 extension &&
178 extension->HasAPIPermission( 178 extension->HasAPIPermission(
179 ExtensionAPIPermission::kExperimental) && 179 ExtensionAPIPermission::kExperimental) &&
180 process_map->Contains(extension->id(), process->GetID()); 180 process_map->Contains(extension->id(), process->GetID());
181 if (!allowed) { 181 if (!allowed) {
182 AppNotifyChannelSetupComplete("", "permission_error", return_route_id, 182 Send(new ExtensionMsg_GetAppNotifyChannelResponse(
183 callback_id); 183 return_route_id, "", "permission_error", callback_id));
184 return; 184 return;
185 } 185 }
186 186
187 AppNotifyChannelUI* ui = new AppNotifyChannelUIImpl( 187 AppNotifyChannelUI* ui = new AppNotifyChannelUIImpl(
188 GetBrowser(), tab_contents_wrapper(), extension->name()); 188 GetBrowser(), tab_contents_wrapper(), extension->name());
189 189
190 scoped_refptr<AppNotifyChannelSetup> channel_setup( 190 scoped_refptr<AppNotifyChannelSetup> channel_setup(
191 new AppNotifyChannelSetup(profile, 191 new AppNotifyChannelSetup(profile,
192 extension->id(), 192 extension->id(),
193 client_id, 193 client_id,
194 requestor_url, 194 requestor_url,
195 return_route_id, 195 return_route_id,
196 callback_id, 196 callback_id,
197 ui, 197 ui,
198 this->AsWeakPtr())); 198 this->AsWeakPtr()));
199 channel_setup->Start(); 199 channel_setup->Start();
200 // We'll get called back in AppNotifyChannelSetupComplete. 200 // We'll get called back in AppNotifyChannelSetupComplete.
201 } 201 }
202 202
203 void ExtensionTabHelper::AppNotifyChannelSetupComplete( 203 void ExtensionTabHelper::AppNotifyChannelSetupComplete(
204 const std::string& client_id, const std::string& error, int return_route_id, 204 const std::string& channel_id,
205 int callback_id) { 205 const std::string& error,
206 const AppNotifyChannelSetup* setup) {
207 CHECK(setup);
208
209 // If the setup was successful, record that fact in ExtensionService.
210 if (!channel_id.empty() && error.empty()) {
211 Profile* profile =
212 Profile::FromBrowserContext(tab_contents()->browser_context());
213 ExtensionService* service = profile->GetExtensionService();
214 if (service->GetExtensionById(setup->extension_id(), true))
215 service->SetAppNotificationSetupDone(setup->extension_id(),
216 setup->client_id());
217 }
218
206 Send(new ExtensionMsg_GetAppNotifyChannelResponse( 219 Send(new ExtensionMsg_GetAppNotifyChannelResponse(
207 return_route_id, client_id, error, callback_id)); 220 setup->return_route_id(), channel_id, error, setup->callback_id()));
208 } 221 }
209 222
210 void ExtensionTabHelper::OnRequest( 223 void ExtensionTabHelper::OnRequest(
211 const ExtensionHostMsg_Request_Params& request) { 224 const ExtensionHostMsg_Request_Params& request) {
212 extension_function_dispatcher_.Dispatch(request, 225 extension_function_dispatcher_.Dispatch(request,
213 tab_contents()->render_view_host()); 226 tab_contents()->render_view_host());
214 } 227 }
215 228
216 void ExtensionTabHelper::UpdateExtensionAppIcon(const Extension* extension) { 229 void ExtensionTabHelper::UpdateExtensionAppIcon(const Extension* extension) {
217 extension_app_icon_.reset(); 230 extension_app_icon_.reset();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 280 }
268 281
269 TabContents* ExtensionTabHelper::GetAssociatedTabContents() const { 282 TabContents* ExtensionTabHelper::GetAssociatedTabContents() const {
270 return tab_contents(); 283 return tab_contents();
271 } 284 }
272 285
273 gfx::NativeView ExtensionTabHelper::GetNativeViewOfHost() { 286 gfx::NativeView ExtensionTabHelper::GetNativeViewOfHost() {
274 RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView(); 287 RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView();
275 return rwhv ? rwhv->GetNativeView() : NULL; 288 return rwhv ? rwhv->GetNativeView() : NULL;
276 } 289 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_tab_helper.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698