OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 2935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2946 external_host_bindings_.set_routing_id(routing_id_); | 2946 external_host_bindings_.set_routing_id(routing_id_); |
2947 external_host_bindings_.BindToJavascript(frame, L"externalHost"); | 2947 external_host_bindings_.BindToJavascript(frame, L"externalHost"); |
2948 } | 2948 } |
2949 } | 2949 } |
2950 | 2950 |
2951 void RenderView::didCreateDocumentElement(WebFrame* frame) { | 2951 void RenderView::didCreateDocumentElement(WebFrame* frame) { |
2952 if (RenderThread::current()) { // Will be NULL during unit tests. | 2952 if (RenderThread::current()) { // Will be NULL during unit tests. |
2953 RenderThread::current()->user_script_slave()->InjectScripts( | 2953 RenderThread::current()->user_script_slave()->InjectScripts( |
2954 frame, UserScript::DOCUMENT_START); | 2954 frame, UserScript::DOCUMENT_START); |
2955 } | 2955 } |
2956 if (view_type_ == ViewType::EXTENSION_TOOLSTRIP || | |
2957 view_type_ == ViewType::EXTENSION_MOLE) { | |
2958 InjectToolstripCSS(); | |
2959 ExtensionProcessBindings::SetViewType(webview(), view_type_); | |
2960 } | |
2961 | 2956 |
2962 // Notify the browser about non-blank documents loading in the top frame. | 2957 // Notify the browser about non-blank documents loading in the top frame. |
2963 GURL url = frame->url(); | 2958 GURL url = frame->url(); |
2964 if (url.is_valid() && url.spec() != chrome::kAboutBlankURL) { | 2959 if (url.is_valid() && url.spec() != chrome::kAboutBlankURL) { |
2965 if (frame == webview()->mainFrame()) | 2960 if (frame == webview()->mainFrame()) |
2966 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); | 2961 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); |
2967 } | 2962 } |
2968 } | 2963 } |
2969 | 2964 |
2970 void RenderView::didReceiveTitle(WebFrame* frame, const WebString& title) { | 2965 void RenderView::didReceiveTitle(WebFrame* frame, const WebString& title) { |
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4183 #endif | 4178 #endif |
4184 } | 4179 } |
4185 | 4180 |
4186 void RenderView::OnMediaPlayerActionAt(const gfx::Point& location, | 4181 void RenderView::OnMediaPlayerActionAt(const gfx::Point& location, |
4187 const WebMediaPlayerAction& action) { | 4182 const WebMediaPlayerAction& action) { |
4188 if (webview()) | 4183 if (webview()) |
4189 webview()->performMediaPlayerAction(action, location); | 4184 webview()->performMediaPlayerAction(action, location); |
4190 } | 4185 } |
4191 | 4186 |
4192 void RenderView::OnNotifyRendererViewType(ViewType::Type type) { | 4187 void RenderView::OnNotifyRendererViewType(ViewType::Type type) { |
4193 // When this is first set, the bindings aren't fully loaded. We only need | |
4194 // to call through this API after the page has already been loaded. It's | |
4195 // also called in didCreateDocumentElement to bootstrap. | |
4196 if (view_type_ != ViewType::INVALID) { | |
4197 if (type == ViewType::EXTENSION_MOLE || | |
4198 type == ViewType::EXTENSION_TOOLSTRIP) { | |
4199 ExtensionProcessBindings::SetViewType(webview(), type); | |
4200 } | |
4201 } | |
4202 view_type_ = type; | 4188 view_type_ = type; |
4203 } | 4189 } |
4204 | 4190 |
4205 void RenderView::OnUpdateBrowserWindowId(int window_id) { | 4191 void RenderView::OnUpdateBrowserWindowId(int window_id) { |
4206 browser_window_id_ = window_id; | 4192 browser_window_id_ = window_id; |
4207 } | 4193 } |
4208 | 4194 |
4209 void RenderView::OnGetAccessibilityTree() { | 4195 void RenderView::OnGetAccessibilityTree() { |
4210 if (accessibility_.get()) | 4196 if (accessibility_.get()) |
4211 accessibility_->clear(); | 4197 accessibility_->clear(); |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4576 } | 4562 } |
4577 | 4563 |
4578 void RenderView::OnExtensionResponse(int request_id, | 4564 void RenderView::OnExtensionResponse(int request_id, |
4579 bool success, | 4565 bool success, |
4580 const std::string& response, | 4566 const std::string& response, |
4581 const std::string& error) { | 4567 const std::string& error) { |
4582 ExtensionProcessBindings::HandleResponse( | 4568 ExtensionProcessBindings::HandleResponse( |
4583 request_id, success, response, error); | 4569 request_id, success, response, error); |
4584 } | 4570 } |
4585 | 4571 |
4586 void RenderView::InjectToolstripCSS() { | |
4587 if (view_type_ != ViewType::EXTENSION_TOOLSTRIP) | |
4588 return; | |
4589 | |
4590 static const base::StringPiece toolstrip_css( | |
4591 ResourceBundle::GetSharedInstance().GetRawDataResource( | |
4592 IDR_EXTENSION_TOOLSTRIP_CSS)); | |
4593 std::string css = toolstrip_css.as_string(); | |
4594 InsertCSS(L"", css, "ToolstripDefaultCSS"); | |
4595 } | |
4596 | |
4597 void RenderView::OnExtensionMessageInvoke(const std::string& function_name, | 4572 void RenderView::OnExtensionMessageInvoke(const std::string& function_name, |
4598 const ListValue& args, | 4573 const ListValue& args, |
4599 bool requires_incognito_access, | 4574 bool requires_incognito_access, |
4600 const GURL& event_url) { | 4575 const GURL& event_url) { |
4601 RendererExtensionBindings::Invoke( | 4576 RendererExtensionBindings::Invoke( |
4602 function_name, args, this, requires_incognito_access, event_url); | 4577 function_name, args, this, requires_incognito_access, event_url); |
4603 } | 4578 } |
4604 | 4579 |
4605 // Dump all load time histograms. | 4580 // Dump all load time histograms. |
4606 // | 4581 // |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5482 // the origins of the two domains are different. This can be treated as a | 5457 // the origins of the two domains are different. This can be treated as a |
5483 // top level navigation and routed back to the host. | 5458 // top level navigation and routed back to the host. |
5484 WebKit::WebFrame* opener = frame->opener(); | 5459 WebKit::WebFrame* opener = frame->opener(); |
5485 if (opener) { | 5460 if (opener) { |
5486 if (url.GetOrigin() != GURL(opener->url()).GetOrigin()) | 5461 if (url.GetOrigin() != GURL(opener->url()).GetOrigin()) |
5487 return true; | 5462 return true; |
5488 } | 5463 } |
5489 } | 5464 } |
5490 return false; | 5465 return false; |
5491 } | 5466 } |
OLD | NEW |