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

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

Issue 10700202: Add Android stub implementation for AppNotifyChannelUI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a Create method to the interface Created 8 years, 5 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/extensions/extension_tab_helper.h" 5 #include "chrome/browser/extensions/extension_tab_helper.h"
6 6
7 #include "chrome/browser/extensions/crx_installer.h" 7 #include "chrome/browser/extensions/crx_installer.h"
8 #include "chrome/browser/extensions/app_notify_channel_ui.h"
8 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/page_action_controller.h" 10 #include "chrome/browser/extensions/page_action_controller.h"
10 #include "chrome/browser/extensions/script_badge_controller.h" 11 #include "chrome/browser/extensions/script_badge_controller.h"
11 #include "chrome/browser/extensions/script_executor.h" 12 #include "chrome/browser/extensions/script_executor.h"
12 #include "chrome/browser/extensions/webstore_inline_installer.h" 13 #include "chrome/browser/extensions/webstore_inline_installer.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/sessions/restore_tab_helper.h" 15 #include "chrome/browser/sessions/restore_tab_helper.h"
15 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_dialogs.h" 17 #include "chrome/browser/ui/browser_dialogs.h"
17 #include "chrome/browser/ui/tab_contents/tab_contents.h" 18 #include "chrome/browser/ui/tab_contents/tab_contents.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppInstallState, 194 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppInstallState,
194 OnGetAppInstallState); 195 OnGetAppInstallState);
195 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) 196 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
196 IPC_MESSAGE_UNHANDLED(handled = false) 197 IPC_MESSAGE_UNHANDLED(handled = false)
197 IPC_END_MESSAGE_MAP() 198 IPC_END_MESSAGE_MAP()
198 return handled; 199 return handled;
199 } 200 }
200 201
201 void ExtensionTabHelper::OnDidGetApplicationInfo( 202 void ExtensionTabHelper::OnDidGetApplicationInfo(
202 int32 page_id, const WebApplicationInfo& info) { 203 int32 page_id, const WebApplicationInfo& info) {
203 #if !defined(OS_MACOSX) 204 // Android does not implement BrowserWindow.
205 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
204 web_app_info_ = info; 206 web_app_info_ = info;
205 207
206 NavigationEntry* entry = 208 NavigationEntry* entry =
207 tab_contents_->web_contents()->GetController().GetLastCommittedEntry(); 209 tab_contents_->web_contents()->GetController().GetLastCommittedEntry();
208 if (!entry || (entry->GetPageID() != page_id)) 210 if (!entry || (entry->GetPageID() != page_id))
209 return; 211 return;
210 212
211 switch (pending_web_app_action_) { 213 switch (pending_web_app_action_) {
212 case CREATE_SHORTCUT: { 214 case CREATE_SHORTCUT: {
213 chrome::ShowCreateWebAppShortcutsDialog( 215 chrome::ShowCreateWebAppShortcutsDialog(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 requestor_url, 264 requestor_url,
263 this)); 265 this));
264 installer->BeginInstall(); 266 installer->BeginInstall();
265 } 267 }
266 268
267 void ExtensionTabHelper::OnGetAppNotifyChannel( 269 void ExtensionTabHelper::OnGetAppNotifyChannel(
268 const GURL& requestor_url, 270 const GURL& requestor_url,
269 const std::string& client_id, 271 const std::string& client_id,
270 int return_route_id, 272 int return_route_id,
271 int callback_id) { 273 int callback_id) {
272
273 // Check for permission first. 274 // Check for permission first.
274 Profile* profile = 275 Profile* profile =
275 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 276 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
276 ExtensionService* extension_service = profile->GetExtensionService(); 277 ExtensionService* extension_service = profile->GetExtensionService();
277 extensions::ProcessMap* process_map = extension_service->process_map(); 278 extensions::ProcessMap* process_map = extension_service->process_map();
278 content::RenderProcessHost* process = 279 content::RenderProcessHost* process =
279 tab_contents()->web_contents()->GetRenderProcessHost(); 280 tab_contents()->web_contents()->GetRenderProcessHost();
280 const Extension* extension = 281 const Extension* extension =
281 extension_service->GetInstalledApp(requestor_url); 282 extension_service->GetInstalledApp(requestor_url);
282 283
283 std::string error; 284 std::string error;
284 if (!extension || 285 if (!extension ||
285 !extension->HasAPIPermission( 286 !extension->HasAPIPermission(
286 extensions::APIPermission::kAppNotifications) || 287 extensions::APIPermission::kAppNotifications) ||
287 !process_map->Contains(extension->id(), process->GetID())) 288 !process_map->Contains(extension->id(), process->GetID()))
288 error = kPermissionError; 289 error = kPermissionError;
289 290
290 // Make sure the extension can cross to the main profile, if called from an 291 // Make sure the extension can cross to the main profile, if called from an
291 // an incognito window. 292 // an incognito window.
292 if (profile->IsOffTheRecord() && 293 if (profile->IsOffTheRecord() &&
293 !extension_service->CanCrossIncognito(extension)) 294 !extension_service->CanCrossIncognito(extension))
294 error = extension_misc::kAppNotificationsIncognitoError; 295 error = extension_misc::kAppNotificationsIncognitoError;
295 296
296 if (!error.empty()) { 297 if (!error.empty()) {
297 Send(new ExtensionMsg_GetAppNotifyChannelResponse( 298 Send(new ExtensionMsg_GetAppNotifyChannelResponse(
298 return_route_id, "", error, callback_id)); 299 return_route_id, "", error, callback_id));
299 return; 300 return;
300 } 301 }
301 302
302 AppNotifyChannelUI* ui = new AppNotifyChannelUIImpl( 303 AppNotifyChannelUI* ui = AppNotifyChannelUI::Create(
303 profile, tab_contents(), extension->name(), 304 profile, tab_contents(), extension->name(),
304 AppNotifyChannelUI::NOTIFICATION_INFOBAR); 305 AppNotifyChannelUI::NOTIFICATION_INFOBAR);
305 306
306 scoped_refptr<AppNotifyChannelSetup> channel_setup( 307 scoped_refptr<AppNotifyChannelSetup> channel_setup(
307 new AppNotifyChannelSetup(profile, 308 new AppNotifyChannelSetup(profile,
308 extension->id(), 309 extension->id(),
309 client_id, 310 client_id,
310 requestor_url, 311 requestor_url,
311 return_route_id, 312 return_route_id,
312 callback_id, 313 callback_id,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 // last committed entry is not NULL. Last committed entry could be NULL 458 // last committed entry is not NULL. Last committed entry could be NULL
458 // when an interstitial page is injected (e.g. bad https certificate, 459 // when an interstitial page is injected (e.g. bad https certificate,
459 // malware site etc). When this happens, we abort the shortcut update. 460 // malware site etc). When this happens, we abort the shortcut update.
460 NavigationEntry* entry = controller.GetLastCommittedEntry(); 461 NavigationEntry* entry = controller.GetLastCommittedEntry();
461 if (entry) 462 if (entry)
462 GetApplicationInfo(entry->GetPageID()); 463 GetApplicationInfo(entry->GetPageID());
463 else 464 else
464 pending_web_app_action_ = NONE; 465 pending_web_app_action_ = NONE;
465 } 466 }
466 } 467 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_notify_channel_ui_impl.cc ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698