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

Side by Side Diff: chrome/browser/extensions/api/messaging/message_service.cc

Issue 1351223003: Allow extensions to specify that they are not allowed in incognito mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add expectations for IncognitoInfo to test Created 5 years, 3 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
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/api/messaging/message_service.h" 5 #include "chrome/browser/extensions/api/messaging/message_service.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 19 matching lines...) Expand all
30 #include "content/public/browser/render_view_host.h" 30 #include "content/public/browser/render_view_host.h"
31 #include "content/public/browser/render_widget_host.h" 31 #include "content/public/browser/render_widget_host.h"
32 #include "content/public/browser/render_widget_host_view.h" 32 #include "content/public/browser/render_widget_host_view.h"
33 #include "content/public/browser/site_instance.h" 33 #include "content/public/browser/site_instance.h"
34 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
35 #include "content/public/common/child_process_host.h" 35 #include "content/public/common/child_process_host.h"
36 #include "extensions/browser/event_router.h" 36 #include "extensions/browser/event_router.h"
37 #include "extensions/browser/extension_host.h" 37 #include "extensions/browser/extension_host.h"
38 #include "extensions/browser/extension_registry.h" 38 #include "extensions/browser/extension_registry.h"
39 #include "extensions/browser/extension_system.h" 39 #include "extensions/browser/extension_system.h"
40 #include "extensions/browser/extension_util.h"
40 #include "extensions/browser/extensions_browser_client.h" 41 #include "extensions/browser/extensions_browser_client.h"
41 #include "extensions/browser/guest_view/web_view/web_view_guest.h" 42 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
42 #include "extensions/browser/lazy_background_task_queue.h" 43 #include "extensions/browser/lazy_background_task_queue.h"
43 #include "extensions/browser/pref_names.h" 44 #include "extensions/browser/pref_names.h"
44 #include "extensions/browser/process_manager.h" 45 #include "extensions/browser/process_manager.h"
45 #include "extensions/common/extension.h" 46 #include "extensions/common/extension.h"
46 #include "extensions/common/manifest_constants.h" 47 #include "extensions/common/manifest_constants.h"
47 #include "extensions/common/manifest_handlers/background_info.h" 48 #include "extensions/common/manifest_handlers/background_info.h"
48 #include "extensions/common/manifest_handlers/externally_connectable.h" 49 #include "extensions/common/manifest_handlers/externally_connectable.h"
49 #include "extensions/common/manifest_handlers/incognito_info.h" 50 #include "extensions/common/manifest_handlers/incognito_info.h"
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 !util::IsIncognitoEnabled(target_extension_id, context)) { 365 !util::IsIncognitoEnabled(target_extension_id, context)) {
365 // Give the user a chance to accept an incognito connection from the web if 366 // Give the user a chance to accept an incognito connection from the web if
366 // they haven't already, with the conditions: 367 // they haven't already, with the conditions:
367 // - Only for spanning-mode incognito. We don't want the complication of 368 // - Only for spanning-mode incognito. We don't want the complication of
368 // spinning up an additional process here which might need to do some 369 // spinning up an additional process here which might need to do some
369 // setup that we're not expecting. 370 // setup that we're not expecting.
370 // - Only for extensions that can't normally be enabled in incognito, since 371 // - Only for extensions that can't normally be enabled in incognito, since
371 // that surface (e.g. chrome://extensions) should be the only one for 372 // that surface (e.g. chrome://extensions) should be the only one for
372 // enabling in incognito. In practice this means platform apps only. 373 // enabling in incognito. In practice this means platform apps only.
373 if (!is_web_connection || IncognitoInfo::IsSplitMode(target_extension) || 374 if (!is_web_connection || IncognitoInfo::IsSplitMode(target_extension) ||
374 target_extension->can_be_incognito_enabled()) { 375 util::CanBeIncognitoEnabled(target_extension)) {
375 OnOpenChannelAllowed(params.Pass(), false); 376 OnOpenChannelAllowed(params.Pass(), false);
376 return; 377 return;
377 } 378 }
378 379
379 // If the target extension isn't even listening for connect/message events, 380 // If the target extension isn't even listening for connect/message events,
380 // there is no need to go any further and the connection should be 381 // there is no need to go any further and the connection should be
381 // rejected without showing a prompt. See http://crbug.com/442497 382 // rejected without showing a prompt. See http://crbug.com/442497
382 EventRouter* event_router = EventRouter::Get(context); 383 EventRouter* event_router = EventRouter::Get(context);
383 const char* const events[] = {"runtime.onConnectExternal", 384 const char* const events[] = {"runtime.onConnectExternal",
384 "runtime.onMessageExternal", 385 "runtime.onMessageExternal",
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 1002
1002 MessageChannelMap::iterator channel_iter = channels_.find(channel_id); 1003 MessageChannelMap::iterator channel_iter = channels_.find(channel_id);
1003 if (channel_iter != channels_.end()) { 1004 if (channel_iter != channels_.end()) {
1004 for (const PendingMessage& message : queue) { 1005 for (const PendingMessage& message : queue) {
1005 DispatchMessage(message.first, channel_iter->second, message.second); 1006 DispatchMessage(message.first, channel_iter->second, message.second);
1006 } 1007 }
1007 } 1008 }
1008 } 1009 }
1009 1010
1010 } // namespace extensions 1011 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698