| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "content/browser/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| (...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 | 1501 |
| 1502 void ContentViewCoreImpl::ResumeResponseDeferredAtStart(JNIEnv* env, | 1502 void ContentViewCoreImpl::ResumeResponseDeferredAtStart(JNIEnv* env, |
| 1503 jobject obj) { | 1503 jobject obj) { |
| 1504 static_cast<WebContentsImpl*>(GetWebContents())-> | 1504 static_cast<WebContentsImpl*>(GetWebContents())-> |
| 1505 ResumeResponseDeferredAtStart(); | 1505 ResumeResponseDeferredAtStart(); |
| 1506 } | 1506 } |
| 1507 | 1507 |
| 1508 void ContentViewCoreImpl::SetHasPendingNavigationTransitionForTesting( | 1508 void ContentViewCoreImpl::SetHasPendingNavigationTransitionForTesting( |
| 1509 JNIEnv* env, | 1509 JNIEnv* env, |
| 1510 jobject obj) { | 1510 jobject obj) { |
| 1511 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1512 switches::kEnableExperimentalWebPlatformFeatures); |
| 1511 RenderFrameHost* frame = static_cast<WebContentsImpl*>(GetWebContents())-> | 1513 RenderFrameHost* frame = static_cast<WebContentsImpl*>(GetWebContents())-> |
| 1512 GetMainFrame(); | 1514 GetMainFrame(); |
| 1513 BrowserThread::PostTask( | 1515 BrowserThread::PostTask( |
| 1514 BrowserThread::IO, | 1516 BrowserThread::IO, |
| 1515 FROM_HERE, | 1517 FROM_HERE, |
| 1516 base::Bind( | 1518 base::Bind( |
| 1517 &TransitionRequestManager::SetHasPendingTransitionRequest, | 1519 &TransitionRequestManager::AddPendingTransitionRequestData, |
| 1518 base::Unretained(TransitionRequestManager::GetInstance()), | 1520 base::Unretained(TransitionRequestManager::GetInstance()), |
| 1519 frame->GetProcess()->GetID(), | 1521 frame->GetProcess()->GetID(), |
| 1520 frame->GetRoutingID(), | 1522 frame->GetRoutingID(), |
| 1521 true)); | 1523 "*", "", "")); |
| 1522 } | 1524 } |
| 1523 | 1525 |
| 1524 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) { | 1526 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) { |
| 1525 return GetRenderProcessIdFromRenderViewHost( | 1527 return GetRenderProcessIdFromRenderViewHost( |
| 1526 web_contents_->GetRenderViewHost()); | 1528 web_contents_->GetRenderViewHost()); |
| 1527 } | 1529 } |
| 1528 | 1530 |
| 1529 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj, | 1531 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj, |
| 1530 jboolean opaque) { | 1532 jboolean opaque) { |
| 1531 if (GetRenderWidgetHostViewAndroid()) | 1533 if (GetRenderWidgetHostViewAndroid()) |
| 1532 GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque); | 1534 GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque); |
| 1533 } | 1535 } |
| 1534 | 1536 |
| 1537 void ContentViewCoreImpl::SetupTransitionView( |
| 1538 JNIEnv* env, jobject jobj, jstring markup) { |
| 1539 if (!GetWebContents()) return; |
| 1540 GetWebContents()->GetMainFrame()->Send(new FrameMsg_SetupTransitionView( |
| 1541 GetWebContents()->GetMainFrame()->GetRoutingID(), |
| 1542 ConvertJavaStringToUTF8(env, markup))); |
| 1543 } |
| 1544 |
| 1545 void ContentViewCoreImpl::BeginExitTransition( |
| 1546 JNIEnv* env, jobject jobj, jstring css_selector) { |
| 1547 if (!GetWebContents()) return; |
| 1548 GetWebContents()->GetMainFrame()->Send(new FrameMsg_BeginExitTransition( |
| 1549 GetWebContents()->GetMainFrame()->GetRoutingID(), |
| 1550 ConvertJavaStringToUTF8(env, css_selector))); |
| 1551 } |
| 1552 |
| 1535 void ContentViewCoreImpl::RequestTextSurroundingSelection( | 1553 void ContentViewCoreImpl::RequestTextSurroundingSelection( |
| 1536 int max_length, | 1554 int max_length, |
| 1537 const base::Callback< | 1555 const base::Callback< |
| 1538 void(const base::string16& content, int start_offset, int end_offset)>& | 1556 void(const base::string16& content, int start_offset, int end_offset)>& |
| 1539 callback) { | 1557 callback) { |
| 1540 DCHECK(!callback.is_null()); | 1558 DCHECK(!callback.is_null()); |
| 1541 RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame(); | 1559 RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame(); |
| 1542 if (!focused_frame) | 1560 if (!focused_frame) |
| 1543 return; | 1561 return; |
| 1544 if (GetRenderWidgetHostViewAndroid()) { | 1562 if (GetRenderWidgetHostViewAndroid()) { |
| 1545 GetRenderWidgetHostViewAndroid()->SetTextSurroundingSelectionCallback( | 1563 GetRenderWidgetHostViewAndroid()->SetTextSurroundingSelectionCallback( |
| 1546 callback); | 1564 callback); |
| 1547 focused_frame->Send(new FrameMsg_TextSurroundingSelectionRequest( | 1565 focused_frame->Send(new FrameMsg_TextSurroundingSelectionRequest( |
| 1548 focused_frame->GetRoutingID(), max_length)); | 1566 focused_frame->GetRoutingID(), max_length)); |
| 1549 } | 1567 } |
| 1550 } | 1568 } |
| 1551 | 1569 |
| 1552 void ContentViewCoreImpl::DidDeferAfterResponseStarted( | 1570 void ContentViewCoreImpl::DidDeferAfterResponseStarted( |
| 1553 const scoped_refptr<net::HttpResponseHeaders>& headers, | 1571 const TransitionLayerData& transition_data) { |
| 1554 const GURL& url) { | |
| 1555 JNIEnv* env = AttachCurrentThread(); | 1572 JNIEnv* env = AttachCurrentThread(); |
| 1556 ScopedJavaLocalRef<jobject> obj(java_ref_.get(env)); | 1573 ScopedJavaLocalRef<jobject> obj(java_ref_.get(env)); |
| 1557 if (obj.is_null()) | 1574 if (obj.is_null()) |
| 1558 return; | 1575 return; |
| 1559 | 1576 |
| 1560 std::vector<GURL> entering_stylesheets; | 1577 std::vector<GURL> entering_stylesheets; |
| 1561 std::string transition_color; | 1578 std::string transition_color; |
| 1562 if (headers) { | 1579 if (transition_data.response_headers) { |
| 1563 TransitionRequestManager::ParseTransitionStylesheetsFromHeaders( | 1580 TransitionRequestManager::ParseTransitionStylesheetsFromHeaders( |
| 1564 headers, entering_stylesheets, url); | 1581 transition_data.response_headers, entering_stylesheets, |
| 1582 transition_data.request_url); |
| 1565 | 1583 |
| 1566 headers->EnumerateHeader( | 1584 transition_data.response_headers->EnumerateHeader( |
| 1567 NULL, "X-Transition-Entering-Color", &transition_color); | 1585 NULL, "X-Transition-Entering-Color", &transition_color); |
| 1568 } | 1586 } |
| 1569 | 1587 |
| 1588 ScopedJavaLocalRef<jstring> jstring_markup(ConvertUTF8ToJavaString( |
| 1589 env, transition_data.markup)); |
| 1590 |
| 1591 ScopedJavaLocalRef<jstring> jstring_css_selector(ConvertUTF8ToJavaString( |
| 1592 env, transition_data.css_selector)); |
| 1593 |
| 1570 ScopedJavaLocalRef<jstring> jstring_transition_color(ConvertUTF8ToJavaString( | 1594 ScopedJavaLocalRef<jstring> jstring_transition_color(ConvertUTF8ToJavaString( |
| 1571 env, transition_color)); | 1595 env, transition_color)); |
| 1572 | 1596 |
| 1573 Java_ContentViewCore_didDeferAfterResponseStarted( | 1597 Java_ContentViewCore_didDeferAfterResponseStarted( |
| 1574 env, obj.obj(), jstring_transition_color.obj()); | 1598 env, obj.obj(), jstring_markup.obj(), jstring_css_selector.obj(), |
| 1599 jstring_transition_color.obj()); |
| 1575 | 1600 |
| 1576 std::vector<GURL>::const_iterator iter = entering_stylesheets.begin(); | 1601 std::vector<GURL>::const_iterator iter = entering_stylesheets.begin(); |
| 1577 for (; iter != entering_stylesheets.end(); ++iter) { | 1602 for (; iter != entering_stylesheets.end(); ++iter) { |
| 1578 ScopedJavaLocalRef<jstring> jstring_url(ConvertUTF8ToJavaString( | 1603 ScopedJavaLocalRef<jstring> jstring_url(ConvertUTF8ToJavaString( |
| 1579 env, iter->spec())); | 1604 env, iter->spec())); |
| 1580 Java_ContentViewCore_addEnteringStylesheetToTransition( | 1605 Java_ContentViewCore_addEnteringStylesheetToTransition( |
| 1581 env, obj.obj(), jstring_url.obj()); | 1606 env, obj.obj(), jstring_url.obj()); |
| 1582 } | 1607 } |
| 1583 } | 1608 } |
| 1584 | 1609 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1637 reinterpret_cast<ui::WindowAndroid*>(window_android), | 1662 reinterpret_cast<ui::WindowAndroid*>(window_android), |
| 1638 retained_objects_set); | 1663 retained_objects_set); |
| 1639 return reinterpret_cast<intptr_t>(view); | 1664 return reinterpret_cast<intptr_t>(view); |
| 1640 } | 1665 } |
| 1641 | 1666 |
| 1642 bool RegisterContentViewCore(JNIEnv* env) { | 1667 bool RegisterContentViewCore(JNIEnv* env) { |
| 1643 return RegisterNativesImpl(env); | 1668 return RegisterNativesImpl(env); |
| 1644 } | 1669 } |
| 1645 | 1670 |
| 1646 } // namespace content | 1671 } // namespace content |
| OLD | NEW |