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

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: 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"
9 #include "chrome/browser/extensions/app_notify_channel_ui_android.h"
10 #include "chrome/browser/extensions/app_notify_channel_ui_impl.h"
8 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/page_action_controller.h" 12 #include "chrome/browser/extensions/page_action_controller.h"
10 #include "chrome/browser/extensions/script_badge_controller.h" 13 #include "chrome/browser/extensions/script_badge_controller.h"
11 #include "chrome/browser/extensions/script_executor.h" 14 #include "chrome/browser/extensions/script_executor.h"
12 #include "chrome/browser/extensions/webstore_inline_installer.h" 15 #include "chrome/browser/extensions/webstore_inline_installer.h"
13 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/sessions/restore_tab_helper.h" 17 #include "chrome/browser/sessions/restore_tab_helper.h"
15 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_dialogs.h" 19 #include "chrome/browser/ui/browser_dialogs.h"
17 #include "chrome/browser/ui/tab_contents/tab_contents.h" 20 #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, 196 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppInstallState,
194 OnGetAppInstallState); 197 OnGetAppInstallState);
195 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) 198 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
196 IPC_MESSAGE_UNHANDLED(handled = false) 199 IPC_MESSAGE_UNHANDLED(handled = false)
197 IPC_END_MESSAGE_MAP() 200 IPC_END_MESSAGE_MAP()
198 return handled; 201 return handled;
199 } 202 }
200 203
201 void ExtensionTabHelper::OnDidGetApplicationInfo( 204 void ExtensionTabHelper::OnDidGetApplicationInfo(
202 int32 page_id, const WebApplicationInfo& info) { 205 int32 page_id, const WebApplicationInfo& info) {
203 #if !defined(OS_MACOSX) 206 // Android does not implement BrowserWindow.
207 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
204 web_app_info_ = info; 208 web_app_info_ = info;
205 209
206 NavigationEntry* entry = 210 NavigationEntry* entry =
207 tab_contents_->web_contents()->GetController().GetLastCommittedEntry(); 211 tab_contents_->web_contents()->GetController().GetLastCommittedEntry();
208 if (!entry || (entry->GetPageID() != page_id)) 212 if (!entry || (entry->GetPageID() != page_id))
209 return; 213 return;
210 214
211 switch (pending_web_app_action_) { 215 switch (pending_web_app_action_) {
212 case CREATE_SHORTCUT: { 216 case CREATE_SHORTCUT: {
213 chrome::ShowCreateWebAppShortcutsDialog( 217 chrome::ShowCreateWebAppShortcutsDialog(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 requestor_url, 266 requestor_url,
263 this)); 267 this));
264 installer->BeginInstall(); 268 installer->BeginInstall();
265 } 269 }
266 270
267 void ExtensionTabHelper::OnGetAppNotifyChannel( 271 void ExtensionTabHelper::OnGetAppNotifyChannel(
268 const GURL& requestor_url, 272 const GURL& requestor_url,
269 const std::string& client_id, 273 const std::string& client_id,
270 int return_route_id, 274 int return_route_id,
271 int callback_id) { 275 int callback_id) {
272
273 // Check for permission first. 276 // Check for permission first.
274 Profile* profile = 277 Profile* profile =
275 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 278 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
276 ExtensionService* extension_service = profile->GetExtensionService(); 279 ExtensionService* extension_service = profile->GetExtensionService();
277 extensions::ProcessMap* process_map = extension_service->process_map(); 280 extensions::ProcessMap* process_map = extension_service->process_map();
278 content::RenderProcessHost* process = 281 content::RenderProcessHost* process =
279 tab_contents()->web_contents()->GetRenderProcessHost(); 282 tab_contents()->web_contents()->GetRenderProcessHost();
280 const Extension* extension = 283 const Extension* extension =
281 extension_service->GetInstalledApp(requestor_url); 284 extension_service->GetInstalledApp(requestor_url);
282 285
283 std::string error; 286 std::string error;
284 if (!extension || 287 if (!extension ||
285 !extension->HasAPIPermission( 288 !extension->HasAPIPermission(
286 extensions::APIPermission::kAppNotifications) || 289 extensions::APIPermission::kAppNotifications) ||
287 !process_map->Contains(extension->id(), process->GetID())) 290 !process_map->Contains(extension->id(), process->GetID()))
288 error = kPermissionError; 291 error = kPermissionError;
289 292
290 // Make sure the extension can cross to the main profile, if called from an 293 // Make sure the extension can cross to the main profile, if called from an
291 // an incognito window. 294 // an incognito window.
292 if (profile->IsOffTheRecord() && 295 if (profile->IsOffTheRecord() &&
293 !extension_service->CanCrossIncognito(extension)) 296 !extension_service->CanCrossIncognito(extension))
294 error = extension_misc::kAppNotificationsIncognitoError; 297 error = extension_misc::kAppNotificationsIncognitoError;
295 298
296 if (!error.empty()) { 299 if (!error.empty()) {
297 Send(new ExtensionMsg_GetAppNotifyChannelResponse( 300 Send(new ExtensionMsg_GetAppNotifyChannelResponse(
298 return_route_id, "", error, callback_id)); 301 return_route_id, "", error, callback_id));
299 return; 302 return;
300 } 303 }
301 304
305 #if defined(OS_ANDROID)
306 AppNotifyChannelUI* ui = new AppNotifyChannelUIAndroid();
Jay Civelli 2012/07/13 20:04:14 If you added a static Create() method in AppNotify
nilesh 2012/07/13 21:25:30 Done.
307 #else
302 AppNotifyChannelUI* ui = new AppNotifyChannelUIImpl( 308 AppNotifyChannelUI* ui = new AppNotifyChannelUIImpl(
303 profile, tab_contents(), extension->name(), 309 profile, tab_contents(), extension->name(),
304 AppNotifyChannelUI::NOTIFICATION_INFOBAR); 310 AppNotifyChannelUI::NOTIFICATION_INFOBAR);
311 #endif
305 312
306 scoped_refptr<AppNotifyChannelSetup> channel_setup( 313 scoped_refptr<AppNotifyChannelSetup> channel_setup(
307 new AppNotifyChannelSetup(profile, 314 new AppNotifyChannelSetup(profile,
308 extension->id(), 315 extension->id(),
309 client_id, 316 client_id,
310 requestor_url, 317 requestor_url,
311 return_route_id, 318 return_route_id,
312 callback_id, 319 callback_id,
313 ui, 320 ui,
314 this->AsWeakPtr())); 321 this->AsWeakPtr()));
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 // last committed entry is not NULL. Last committed entry could be NULL 464 // last committed entry is not NULL. Last committed entry could be NULL
458 // when an interstitial page is injected (e.g. bad https certificate, 465 // when an interstitial page is injected (e.g. bad https certificate,
459 // malware site etc). When this happens, we abort the shortcut update. 466 // malware site etc). When this happens, we abort the shortcut update.
460 NavigationEntry* entry = controller.GetLastCommittedEntry(); 467 NavigationEntry* entry = controller.GetLastCommittedEntry();
461 if (entry) 468 if (entry)
462 GetApplicationInfo(entry->GetPageID()); 469 GetApplicationInfo(entry->GetPageID());
463 else 470 else
464 pending_web_app_action_ = NONE; 471 pending_web_app_action_ = NONE;
465 } 472 }
466 } 473 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698