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

Side by Side Diff: chrome/renderer/extensions/dispatcher.cc

Issue 22299009: Move channel-related (Chrome-specific) global state out of Feature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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/renderer/extensions/dispatcher.h" 5 #include "chrome/renderer/extensions/dispatcher.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/sha1.h" 12 #include "base/sha1.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "chrome/common/child_process_logging.h" 17 #include "chrome/common/child_process_logging.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/chrome_version_info.h" 19 #include "chrome/common/chrome_version_info.h"
20 #include "chrome/common/extensions/api/extension_api.h" 20 #include "chrome/common/extensions/api/extension_api.h"
21 #include "chrome/common/extensions/background_info.h" 21 #include "chrome/common/extensions/background_info.h"
22 #include "chrome/common/extensions/extension.h" 22 #include "chrome/common/extensions/extension.h"
23 #include "chrome/common/extensions/extension_constants.h" 23 #include "chrome/common/extensions/extension_constants.h"
24 #include "chrome/common/extensions/extension_manifest_constants.h" 24 #include "chrome/common/extensions/extension_manifest_constants.h"
25 #include "chrome/common/extensions/extension_messages.h" 25 #include "chrome/common/extensions/extension_messages.h"
26 #include "chrome/common/extensions/features/base_feature_provider.h" 26 #include "chrome/common/extensions/features/base_feature_provider.h"
27 #include "chrome/common/extensions/features/feature.h" 27 #include "chrome/common/extensions/features/feature.h"
28 #include "chrome/common/extensions/features/feature_channel.h"
28 #include "chrome/common/extensions/manifest.h" 29 #include "chrome/common/extensions/manifest.h"
29 #include "chrome/common/extensions/manifest_handlers/externally_connectable.h" 30 #include "chrome/common/extensions/manifest_handlers/externally_connectable.h"
30 #include "chrome/common/extensions/manifest_handlers/sandboxed_page_info.h" 31 #include "chrome/common/extensions/manifest_handlers/sandboxed_page_info.h"
31 #include "chrome/common/extensions/message_bundle.h" 32 #include "chrome/common/extensions/message_bundle.h"
32 #include "chrome/common/extensions/permissions/permission_set.h" 33 #include "chrome/common/extensions/permissions/permission_set.h"
33 #include "chrome/common/extensions/permissions/permissions_data.h" 34 #include "chrome/common/extensions/permissions/permissions_data.h"
34 #include "chrome/common/url_constants.h" 35 #include "chrome/common/url_constants.h"
35 #include "chrome/renderer/chrome_render_process_observer.h" 36 #include "chrome/renderer/chrome_render_process_observer.h"
36 #include "chrome/renderer/extensions/api_activity_logger.h" 37 #include "chrome/renderer/extensions/api_activity_logger.h"
37 #include "chrome/renderer/extensions/api_definitions_natives.h" 38 #include "chrome/renderer/extensions/api_definitions_natives.h"
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 function_names_.insert(names[i]); 501 function_names_.insert(names[i]);
501 } 502 }
502 503
503 void Dispatcher::OnSetSystemFont(const std::string& font_family, 504 void Dispatcher::OnSetSystemFont(const std::string& font_family,
504 const std::string& font_size) { 505 const std::string& font_size) {
505 system_font_family_ = font_family; 506 system_font_family_ = font_family;
506 system_font_size_ = font_size; 507 system_font_size_ = font_size;
507 } 508 }
508 509
509 void Dispatcher::OnSetChannel(int channel) { 510 void Dispatcher::OnSetChannel(int channel) {
510 Feature::SetCurrentChannel( 511 extensions::SetCurrentChannel(
511 static_cast<chrome::VersionInfo::Channel>(channel)); 512 static_cast<chrome::VersionInfo::Channel>(channel));
512 } 513 }
513 514
514 void Dispatcher::OnMessageInvoke(const std::string& extension_id, 515 void Dispatcher::OnMessageInvoke(const std::string& extension_id,
515 const std::string& module_name, 516 const std::string& module_name,
516 const std::string& function_name, 517 const std::string& function_name,
517 const base::ListValue& args, 518 const base::ListValue& args,
518 bool user_gesture) { 519 bool user_gesture) {
519 InvokeModuleSystemMethod( 520 InvokeModuleSystemMethod(
520 NULL, extension_id, module_name, function_name, args, user_gesture); 521 NULL, extension_id, module_name, function_name, args, user_gesture);
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 AddOrRemoveBindingsForContext(context); 1078 AddOrRemoveBindingsForContext(context);
1078 1079
1079 bool is_within_platform_app = IsWithinPlatformApp(frame); 1080 bool is_within_platform_app = IsWithinPlatformApp(frame);
1080 // Inject custom JS into the platform app context. 1081 // Inject custom JS into the platform app context.
1081 if (is_within_platform_app) { 1082 if (is_within_platform_app) {
1082 module_system->Require("platformApp"); 1083 module_system->Require("platformApp");
1083 } 1084 }
1084 1085
1085 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && 1086 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT &&
1086 is_within_platform_app && 1087 is_within_platform_app &&
1087 Feature::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV && 1088 GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV &&
1088 CommandLine::ForCurrentProcess()->HasSwitch( 1089 CommandLine::ForCurrentProcess()->HasSwitch(
1089 switches::kEnableAppWindowControls)) { 1090 switches::kEnableAppWindowControls)) {
1090 module_system->Require("windowControls"); 1091 module_system->Require("windowControls");
1091 } 1092 }
1092 1093
1093 // Only platform apps support the <webview> tag, because the "webView" and 1094 // Only platform apps support the <webview> tag, because the "webView" and
1094 // "denyWebView" modules will affect the performance of DOM modifications 1095 // "denyWebView" modules will affect the performance of DOM modifications
1095 // (http://crbug.com/196453). 1096 // (http://crbug.com/196453).
1096 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && 1097 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT &&
1097 is_within_platform_app) { 1098 is_within_platform_app) {
1098 // Note: setting up the WebView class here, not the chrome.webview API. 1099 // Note: setting up the WebView class here, not the chrome.webview API.
1099 // The API will be automatically set up when first used. 1100 // The API will be automatically set up when first used.
1100 if (extension->HasAPIPermission(APIPermission::kWebView)) { 1101 if (extension->HasAPIPermission(APIPermission::kWebView)) {
1101 module_system->Require("webView"); 1102 module_system->Require("webView");
1102 bool includeExperimental = 1103 bool includeExperimental =
1103 Feature::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV || 1104 GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV ||
1104 extension->id() == extension_misc::kIdentityApiUiAppId; 1105 extension->id() == extension_misc::kIdentityApiUiAppId;
1105 if (!includeExperimental) { 1106 if (!includeExperimental) {
1106 // TODO(asargent) We need a whitelist for webview experimental. 1107 // TODO(asargent) We need a whitelist for webview experimental.
1107 // crbug.com/264852 1108 // crbug.com/264852
1108 std::string id_hash = base::SHA1HashString(extension->id()); 1109 std::string id_hash = base::SHA1HashString(extension->id());
1109 std::string hexencoded_id_hash = base::HexEncode(id_hash.c_str(), 1110 std::string hexencoded_id_hash = base::HexEncode(id_hash.c_str(),
1110 id_hash.length()); 1111 id_hash.length());
1111 if (hexencoded_id_hash == "8C3741E3AF0B93B6E8E0DDD499BB0B74839EA578" || 1112 if (hexencoded_id_hash == "8C3741E3AF0B93B6E8E0DDD499BB0B74839EA578" ||
1112 hexencoded_id_hash == "E703483CEF33DEC18B4B6DD84B5C776FB9182BDB") 1113 hexencoded_id_hash == "E703483CEF33DEC18B4B6DD84B5C776FB9182BDB")
1113 includeExperimental = true; 1114 includeExperimental = true;
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 RenderView* background_view = 1531 RenderView* background_view =
1531 ExtensionHelper::GetBackgroundPage(extension_id); 1532 ExtensionHelper::GetBackgroundPage(extension_id);
1532 if (background_view) { 1533 if (background_view) {
1533 background_view->Send(new ExtensionHostMsg_EventAck( 1534 background_view->Send(new ExtensionHostMsg_EventAck(
1534 background_view->GetRoutingID())); 1535 background_view->GetRoutingID()));
1535 } 1536 }
1536 } 1537 }
1537 } 1538 }
1538 1539
1539 } // namespace extensions 1540 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/permissions/permissions_data_unittest.cc ('k') | chrome/renderer/extensions/module_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698