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

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

Issue 12680004: Remove chrome/ code to handle App Notifications (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflicts. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/tab_helper.h ('k') | chrome/browser/resources/ntp4/apps_page.css » ('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) 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/tab_helper.h" 5 #include "chrome/browser/extensions/tab_helper.h"
6 6
7 #include "chrome/browser/extensions/activity_log.h" 7 #include "chrome/browser/extensions/activity_log.h"
8 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" 8 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h"
9 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist ry.h" 9 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist ry.h"
10 #include "chrome/browser/extensions/app_notify_channel_ui.h"
11 #include "chrome/browser/extensions/crx_installer.h" 10 #include "chrome/browser/extensions/crx_installer.h"
12 #include "chrome/browser/extensions/extension_action.h" 11 #include "chrome/browser/extensions/extension_action.h"
13 #include "chrome/browser/extensions/extension_action_manager.h" 12 #include "chrome/browser/extensions/extension_action_manager.h"
14 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/extensions/extension_system.h" 14 #include "chrome/browser/extensions/extension_system.h"
16 #include "chrome/browser/extensions/extension_tab_util.h" 15 #include "chrome/browser/extensions/extension_tab_util.h"
17 #include "chrome/browser/extensions/image_loader.h" 16 #include "chrome/browser/extensions/image_loader.h"
18 #include "chrome/browser/extensions/page_action_controller.h" 17 #include "chrome/browser/extensions/page_action_controller.h"
19 #include "chrome/browser/extensions/script_badge_controller.h" 18 #include "chrome/browser/extensions/script_badge_controller.h"
20 #include "chrome/browser/extensions/script_bubble_controller.h" 19 #include "chrome/browser/extensions/script_bubble_controller.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 229
231 bool TabHelper::OnMessageReceived(const IPC::Message& message) { 230 bool TabHelper::OnMessageReceived(const IPC::Message& message) {
232 bool handled = true; 231 bool handled = true;
233 IPC_BEGIN_MESSAGE_MAP(TabHelper, message) 232 IPC_BEGIN_MESSAGE_MAP(TabHelper, message)
234 IPC_MESSAGE_HANDLER(ExtensionHostMsg_DidGetApplicationInfo, 233 IPC_MESSAGE_HANDLER(ExtensionHostMsg_DidGetApplicationInfo,
235 OnDidGetApplicationInfo) 234 OnDidGetApplicationInfo)
236 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InstallApplication, 235 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InstallApplication,
237 OnInstallApplication) 236 OnInstallApplication)
238 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InlineWebstoreInstall, 237 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InlineWebstoreInstall,
239 OnInlineWebstoreInstall) 238 OnInlineWebstoreInstall)
240 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppNotifyChannel,
241 OnGetAppNotifyChannel)
242 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppInstallState, 239 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppInstallState,
243 OnGetAppInstallState); 240 OnGetAppInstallState);
244 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) 241 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
245 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ContentScriptsExecuting, 242 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ContentScriptsExecuting,
246 OnContentScriptsExecuting) 243 OnContentScriptsExecuting)
247 IPC_MESSAGE_HANDLER(ExtensionHostMsg_OnWatchedPageChange, 244 IPC_MESSAGE_HANDLER(ExtensionHostMsg_OnWatchedPageChange,
248 OnWatchedPageChange) 245 OnWatchedPageChange)
249 IPC_MESSAGE_UNHANDLED(handled = false) 246 IPC_MESSAGE_UNHANDLED(handled = false)
250 IPC_END_MESSAGE_MAP() 247 IPC_END_MESSAGE_MAP()
251 return handled; 248 return handled;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 webstore_item_id, 319 webstore_item_id,
323 WebstoreStandaloneInstaller::REQUIRE_VERIFIED_SITE, 320 WebstoreStandaloneInstaller::REQUIRE_VERIFIED_SITE,
324 WebstoreStandaloneInstaller::INLINE_PROMPT, 321 WebstoreStandaloneInstaller::INLINE_PROMPT,
325 requestor_url, 322 requestor_url,
326 Profile::FromBrowserContext(web_contents()->GetBrowserContext()), 323 Profile::FromBrowserContext(web_contents()->GetBrowserContext()),
327 web_contents(), 324 web_contents(),
328 callback)); 325 callback));
329 installer->BeginInstall(); 326 installer->BeginInstall();
330 } 327 }
331 328
332 void TabHelper::OnGetAppNotifyChannel(const GURL& requestor_url,
333 const std::string& client_id,
334 int return_route_id,
335 int callback_id) {
336 // Check for permission first.
337 Profile* profile =
338 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
339 ExtensionService* extension_service = profile->GetExtensionService();
340 ProcessMap* process_map = extension_service->process_map();
341 content::RenderProcessHost* process = web_contents()->GetRenderProcessHost();
342 const Extension* extension =
343 extension_service->GetInstalledApp(requestor_url);
344
345 std::string error;
346 if (!extension ||
347 !extension->HasAPIPermission(APIPermission::kAppNotifications) ||
348 !process_map->Contains(extension->id(), process->GetID()))
349 error = kPermissionError;
350
351 // Make sure the extension can cross to the main profile, if called from an
352 // an incognito window.
353 if (profile->IsOffTheRecord() &&
354 !extension_service->CanCrossIncognito(extension))
355 error = extension_misc::kAppNotificationsIncognitoError;
356
357 if (!error.empty()) {
358 Send(new ExtensionMsg_GetAppNotifyChannelResponse(
359 return_route_id, "", error, callback_id));
360 return;
361 }
362
363 AppNotifyChannelUI* ui = AppNotifyChannelUI::Create(
364 profile, web_contents(), extension->name(),
365 AppNotifyChannelUI::NOTIFICATION_INFOBAR);
366
367 scoped_refptr<AppNotifyChannelSetup> channel_setup(
368 new AppNotifyChannelSetup(profile,
369 extension->id(),
370 client_id,
371 requestor_url,
372 return_route_id,
373 callback_id,
374 ui,
375 this->AsWeakPtr()));
376 channel_setup->Start();
377 // We'll get called back in AppNotifyChannelSetupComplete.
378 }
379
380 void TabHelper::OnGetAppInstallState(const GURL& requestor_url, 329 void TabHelper::OnGetAppInstallState(const GURL& requestor_url,
381 int return_route_id, 330 int return_route_id,
382 int callback_id) { 331 int callback_id) {
383 Profile* profile = 332 Profile* profile =
384 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 333 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
385 ExtensionService* extension_service = profile->GetExtensionService(); 334 ExtensionService* extension_service = profile->GetExtensionService();
386 const ExtensionSet* extensions = extension_service->extensions(); 335 const ExtensionSet* extensions = extension_service->extensions();
387 const ExtensionSet* disabled = extension_service->disabled_extensions(); 336 const ExtensionSet* disabled = extension_service->disabled_extensions();
388 337
389 ExtensionURLInfo url(requestor_url); 338 ExtensionURLInfo url(requestor_url);
390 std::string state; 339 std::string state;
391 if (extensions->GetHostedAppByURL(url)) 340 if (extensions->GetHostedAppByURL(url))
392 state = extension_misc::kAppStateInstalled; 341 state = extension_misc::kAppStateInstalled;
393 else if (disabled->GetHostedAppByURL(url)) 342 else if (disabled->GetHostedAppByURL(url))
394 state = extension_misc::kAppStateDisabled; 343 state = extension_misc::kAppStateDisabled;
395 else 344 else
396 state = extension_misc::kAppStateNotInstalled; 345 state = extension_misc::kAppStateNotInstalled;
397 346
398 Send(new ExtensionMsg_GetAppInstallStateResponse( 347 Send(new ExtensionMsg_GetAppInstallStateResponse(
399 return_route_id, state, callback_id)); 348 return_route_id, state, callback_id));
400 } 349 }
401 350
402 void TabHelper::AppNotifyChannelSetupComplete(
403 const std::string& channel_id,
404 const std::string& error,
405 const AppNotifyChannelSetup* setup) {
406 CHECK(setup);
407
408 // If the setup was successful, record that fact in ExtensionService.
409 if (!channel_id.empty() && error.empty()) {
410 Profile* profile =
411 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
412 ExtensionService* service = profile->GetExtensionService();
413 if (service->GetExtensionById(setup->extension_id(), true))
414 service->SetAppNotificationSetupDone(setup->extension_id(),
415 setup->client_id());
416 }
417
418 Send(new ExtensionMsg_GetAppNotifyChannelResponse(
419 setup->return_route_id(), channel_id, error, setup->callback_id()));
420 }
421
422 void TabHelper::OnRequest(const ExtensionHostMsg_Request_Params& request) { 351 void TabHelper::OnRequest(const ExtensionHostMsg_Request_Params& request) {
423 extension_function_dispatcher_.Dispatch(request, 352 extension_function_dispatcher_.Dispatch(request,
424 web_contents()->GetRenderViewHost()); 353 web_contents()->GetRenderViewHost());
425 } 354 }
426 355
427 void TabHelper::OnContentScriptsExecuting( 356 void TabHelper::OnContentScriptsExecuting(
428 const ScriptExecutionObserver::ExecutingScriptsMap& executing_scripts_map, 357 const ScriptExecutionObserver::ExecutingScriptsMap& executing_scripts_map,
429 int32 on_page_id, 358 int32 on_page_id,
430 const GURL& on_url) { 359 const GURL& on_url) {
431 FOR_EACH_OBSERVER(ScriptExecutionObserver, script_execution_observers_, 360 FOR_EACH_OBSERVER(ScriptExecutionObserver, script_execution_observers_,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 script_bubble_controller_->OnExtensionUnloaded( 476 script_bubble_controller_->OnExtensionUnloaded(
548 content::Details<extensions::UnloadedExtensionInfo>( 477 content::Details<extensions::UnloadedExtensionInfo>(
549 details)->extension->id()); 478 details)->extension->id());
550 break; 479 break;
551 } 480 }
552 } 481 }
553 } 482 }
554 } 483 }
555 484
556 } // namespace extensions 485 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/tab_helper.h ('k') | chrome/browser/resources/ntp4/apps_page.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698