OLD | NEW |
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/extension_dispatcher.h" | 5 #include "chrome/renderer/extensions/extension_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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #include "content/public/renderer/render_view.h" | 49 #include "content/public/renderer/render_view.h" |
50 #include "grit/renderer_resources.h" | 50 #include "grit/renderer_resources.h" |
51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" | 51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedUserGesture.
h" | 54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedUserGesture.
h" |
55 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" | 55 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
57 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 57 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
58 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques
t.h" | 58 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques
t.h" |
| 59 #include "ui/base/layout.h" |
59 #include "ui/base/resource/resource_bundle.h" | 60 #include "ui/base/resource/resource_bundle.h" |
60 #include "v8/include/v8.h" | 61 #include "v8/include/v8.h" |
61 | 62 |
62 using WebKit::WebDataSource; | 63 using WebKit::WebDataSource; |
63 using WebKit::WebDocument; | 64 using WebKit::WebDocument; |
64 using WebKit::WebFrame; | 65 using WebKit::WebFrame; |
65 using WebKit::WebScopedUserGesture; | 66 using WebKit::WebScopedUserGesture; |
66 using WebKit::WebSecurityPolicy; | 67 using WebKit::WebSecurityPolicy; |
67 using WebKit::WebString; | 68 using WebKit::WebString; |
68 using WebKit::WebVector; | 69 using WebKit::WebVector; |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 // We have collected a set of platform-app extensions, so let's tell WebKit | 384 // We have collected a set of platform-app extensions, so let's tell WebKit |
384 // about them so that it can provide a default stylesheet for them. | 385 // about them so that it can provide a default stylesheet for them. |
385 // | 386 // |
386 // TODO(miket): consider enhancing WebView to allow removing | 387 // TODO(miket): consider enhancing WebView to allow removing |
387 // single stylesheets, or else to edit the pattern set associated | 388 // single stylesheets, or else to edit the pattern set associated |
388 // with one. | 389 // with one. |
389 WebVector<WebString> patterns; | 390 WebVector<WebString> patterns; |
390 patterns.assign(platform_app_patterns); | 391 patterns.assign(platform_app_patterns); |
391 WebView::addUserStyleSheet( | 392 WebView::addUserStyleSheet( |
392 WebString::fromUTF8(ResourceBundle::GetSharedInstance(). | 393 WebString::fromUTF8(ResourceBundle::GetSharedInstance(). |
393 GetRawDataResource(IDR_PLATFORM_APP_CSS)), | 394 GetRawDataResource(IDR_PLATFORM_APP_CSS, |
| 395 ui::kScaleFactorNone)), |
394 patterns, | 396 patterns, |
395 WebView::UserContentInjectInAllFrames, | 397 WebView::UserContentInjectInAllFrames, |
396 WebView::UserStyleInjectInExistingDocuments); | 398 WebView::UserStyleInjectInExistingDocuments); |
397 } | 399 } |
398 } | 400 } |
399 | 401 |
400 void ExtensionDispatcher::OnUnloaded(const std::string& id) { | 402 void ExtensionDispatcher::OnUnloaded(const std::string& id) { |
401 extensions_.Remove(id); | 403 extensions_.Remove(id); |
402 // If the extension is later reloaded with a different set of permissions, | 404 // If the extension is later reloaded with a different set of permissions, |
403 // we'd like it to get a new isolated world ID, so that it can pick up the | 405 // we'd like it to get a new isolated world ID, so that it can pick up the |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 static const char kMessage[] = | 901 static const char kMessage[] = |
900 "%s can only be used in an extension process."; | 902 "%s can only be used in an extension process."; |
901 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); | 903 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); |
902 v8::ThrowException( | 904 v8::ThrowException( |
903 v8::Exception::Error(v8::String::New(error_msg.c_str()))); | 905 v8::Exception::Error(v8::String::New(error_msg.c_str()))); |
904 return false; | 906 return false; |
905 } | 907 } |
906 | 908 |
907 return true; | 909 return true; |
908 } | 910 } |
OLD | NEW |