diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc index e087d93..a9bf16da 100644 --- a/base/test/launcher/test_launcher.cc +++ b/base/test/launcher/test_launcher.cc
@@ -1204,6 +1204,7 @@ LOG(ERROR) << "Invalid value for " << switches::kTestLauncherJobs; return 0U; } + return jobs; } else if (command_line->HasSwitch(kGTestFilterFlag) && !BotModeEnabled()) { // Do not run jobs in parallel by default if we are running a subset of // the tests and if bot mode is off.
diff --git a/base/trace_event/heap_profiler_stack_frame_deduplicator.cc b/base/trace_event/heap_profiler_stack_frame_deduplicator.cc index a7dac9c5..12110b1 100644 --- a/base/trace_event/heap_profiler_stack_frame_deduplicator.cc +++ b/base/trace_event/heap_profiler_stack_frame_deduplicator.cc
@@ -7,9 +7,11 @@ #include <inttypes.h> #include <stddef.h> +#include <algorithm> #include <string> #include <utility> +#include "base/hash.h" #include "base/strings/stringprintf.h" #include "base/trace_event/heap_profiler_string_deduplicator.h" #include "base/trace_event/memory_usage_estimator.h" @@ -20,6 +22,20 @@ namespace base { namespace trace_event { +namespace { + +// Dumb hash function that nevertheless works surprisingly well and +// produces ~0 collisions on real backtraces. +size_t HashBacktrace(const StackFrame* begin, const StackFrame* end) { + size_t hash = 0; + for (; begin != end; begin++) { + hash += reinterpret_cast<uintptr_t>(begin->value); + } + return hash; +} + +} // namespace + StackFrameDeduplicator::FrameNode::FrameNode(StackFrame frame, int parent_frame_index) : frame(frame), parent_frame_index(parent_frame_index) {} @@ -39,18 +55,55 @@ } StackFrameDeduplicator::~StackFrameDeduplicator() {} -int StackFrameDeduplicator::Insert(const StackFrame* beginFrame, - const StackFrame* endFrame) { - if (beginFrame == endFrame) { +bool StackFrameDeduplicator::Match(int frame_index, + const StackFrame* begin_frame, + const StackFrame* end_frame) const { + // |frame_index| identifies the bottom frame, i.e. we need to walk + // backtrace backwards. + const StackFrame* current_frame = end_frame - 1; + for (; current_frame >= begin_frame; --current_frame) { + const FrameNode& node = frames_[frame_index]; + if (node.frame != *current_frame) { + break; + } + + frame_index = node.parent_frame_index; + if (frame_index == FrameNode::kInvalidFrameIndex) { + if (current_frame == begin_frame) { + // We're at the top node and we matched all backtrace frames, + // i.e. we successfully matched the backtrace. + return true; + } + break; + } + } + + return false; +} + +int StackFrameDeduplicator::Insert(const StackFrame* begin_frame, + const StackFrame* end_frame) { + if (begin_frame == end_frame) { // Empty backtraces are mapped to id 0. return 0; } + size_t backtrace_hash = HashBacktrace(begin_frame, end_frame); + + // Check if we know about this backtrace. + auto backtrace_it = backtrace_lookup_table_.find(backtrace_hash); + if (backtrace_it != backtrace_lookup_table_.end()) { + int backtrace_index = backtrace_it->second; + if (Match(backtrace_index, begin_frame, end_frame)) { + return backtrace_index; + } + } + int frame_index = FrameNode::kInvalidFrameIndex; - std::map<StackFrame, int>* nodes = &roots_; + base::flat_map<StackFrame, int>* nodes = &roots_; // Loop through the frames, early out when a frame is null. - for (const StackFrame* it = beginFrame; it != endFrame; it++) { + for (const StackFrame* it = begin_frame; it != end_frame; it++) { StackFrame frame = *it; auto node = nodes->find(frame); @@ -77,6 +130,9 @@ nodes = &frames_[frame_index].children; } + // Remember the backtrace. + backtrace_lookup_table_[backtrace_hash] = frame_index; + return frame_index; } @@ -123,8 +179,9 @@ void StackFrameDeduplicator::EstimateTraceMemoryOverhead( TraceEventMemoryOverhead* overhead) { - size_t memory_usage = - EstimateMemoryUsage(frames_) + EstimateMemoryUsage(roots_); + size_t memory_usage = EstimateMemoryUsage(frames_) + + EstimateMemoryUsage(roots_) + + EstimateMemoryUsage(backtrace_lookup_table_); overhead->Add(TraceEventMemoryOverhead::kHeapProfilerStackFrameDeduplicator, sizeof(StackFrameDeduplicator) + memory_usage); }
diff --git a/base/trace_event/heap_profiler_stack_frame_deduplicator.h b/base/trace_event/heap_profiler_stack_frame_deduplicator.h index 04b3567..7b6c662 100644 --- a/base/trace_event/heap_profiler_stack_frame_deduplicator.h +++ b/base/trace_event/heap_profiler_stack_frame_deduplicator.h
@@ -5,11 +5,12 @@ #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_STACK_FRAME_DEDUPLICATOR_H_ #define BASE_TRACE_EVENT_HEAP_PROFILER_STACK_FRAME_DEDUPLICATOR_H_ -#include <map> +#include <deque> #include <string> -#include <vector> +#include <unordered_map> #include "base/base_export.h" +#include "base/containers/flat_map.h" #include "base/macros.h" #include "base/trace_event/heap_profiler_allocation_context.h" @@ -45,10 +46,10 @@ constexpr static int kInvalidFrameIndex = -1; // Indices into |frames_| of frames called from the current frame. - std::map<StackFrame, int> children; + base::flat_map<StackFrame, int> children; }; - using ConstIterator = std::vector<FrameNode>::const_iterator; + using ConstIterator = std::deque<FrameNode>::const_iterator; // |string_deduplication| is used during serialization, and is expected // to outlive instances of this class. @@ -73,12 +74,23 @@ void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead); private: + // Checks that existing backtrace identified by |frame_index| equals + // to the one identified by |begin_frame|, |end_frame|. + bool Match(int frame_index, + const StackFrame* begin_frame, + const StackFrame* end_frame) const; + StringDeduplicator* string_deduplicator_; - std::map<StackFrame, int> roots_; - std::vector<FrameNode> frames_; + base::flat_map<StackFrame, int> roots_; + std::deque<FrameNode> frames_; size_t last_exported_index_; + // {backtrace_hash -> frame_index} map for finding backtraces that are + // already added. Backtraces themselves are not stored in the map, instead + // Match() is used on the found frame_index to detect collisions. + std::unordered_map<size_t, int> backtrace_lookup_table_; + DISALLOW_COPY_AND_ASSIGN(StackFrameDeduplicator); };
diff --git a/base/trace_event/heap_profiler_stack_frame_deduplicator_unittest.cc b/base/trace_event/heap_profiler_stack_frame_deduplicator_unittest.cc index 291f99ba..c5b94ad9 100644 --- a/base/trace_event/heap_profiler_stack_frame_deduplicator_unittest.cc +++ b/base/trace_event/heap_profiler_stack_frame_deduplicator_unittest.cc
@@ -106,7 +106,7 @@ StackFrameDeduplicator dedup(&string_dedup); // Node #0 is added implicitly and corresponds to an empty backtrace. - ASSERT_EQ(dedup.begin() + 1, dedup.end()); + ASSERT_TRUE(dedup.begin() + 1 == dedup.end()); ASSERT_EQ(0, dedup.Insert(std::begin(null_bt), std::begin(null_bt))); // Placeholder entry for ID 0 is a frame with NULL name and no parent. @@ -138,7 +138,7 @@ ASSERT_EQ(kMalloc, (iter + 2)->frame); ASSERT_EQ(2, (iter + 2)->parent_frame_index); - ASSERT_EQ(iter + 3, dedup.end()); + ASSERT_TRUE(iter + 3 == dedup.end()); } TEST(StackFrameDeduplicatorTest, SingleBacktraceWithNull) { @@ -168,7 +168,7 @@ ASSERT_EQ(kMalloc, (iter + 2)->frame); ASSERT_EQ(2, (iter + 2)->parent_frame_index); - ASSERT_EQ(iter + 3, dedup.end()); + ASSERT_TRUE(iter + 3 == dedup.end()); } // Test that there can be different call trees (there can be multiple bottom @@ -206,7 +206,7 @@ ASSERT_EQ(kCreateWidget, (iter + 3)->frame); ASSERT_EQ(3, (iter + 3)->parent_frame_index); - ASSERT_EQ(iter + 4, dedup.end()); + ASSERT_TRUE(iter + 4 == dedup.end()); } TEST(StackFrameDeduplicatorTest, Deduplication) { @@ -236,7 +236,7 @@ ASSERT_EQ(kInitialize, (iter + 2)->frame); ASSERT_EQ(1, (iter + 2)->parent_frame_index); - ASSERT_EQ(iter + 3, dedup.end()); + ASSERT_TRUE(iter + 3 == dedup.end()); // Inserting the same backtrace again should return the index of the existing // node.
diff --git a/base/trace_event/memory_usage_estimator.h b/base/trace_event/memory_usage_estimator.h index 174429f..90c94aba 100644 --- a/base/trace_event/memory_usage_estimator.h +++ b/base/trace_event/memory_usage_estimator.h
@@ -22,6 +22,8 @@ #include <vector> #include "base/base_export.h" +#include "base/containers/flat_map.h" +#include "base/containers/flat_set.h" #include "base/containers/linked_list.h" #include "base/strings/string16.h" @@ -150,6 +152,12 @@ template <class T, class C> size_t EstimateMemoryUsage(const std::stack<T, C>& stack); +template <class T, class C> +size_t EstimateMemoryUsage(const base::flat_set<T, C>& set); + +template <class K, class V, class C> +size_t EstimateMemoryUsage(const base::flat_map<K, V, C>& map); + // TODO(dskiba): // std::forward_list @@ -542,6 +550,20 @@ return EstimateMemoryUsage(internal::GetUnderlyingContainer(stack)); } +// Flat containers + +template <class T, class C> +size_t EstimateMemoryUsage(const base::flat_set<T, C>& set) { + using value_type = typename base::flat_set<T, C>::value_type; + return sizeof(value_type) * set.capacity() + EstimateIterableMemoryUsage(set); +} + +template <class K, class V, class C> +size_t EstimateMemoryUsage(const base::flat_map<K, V, C>& map) { + using value_type = typename base::flat_map<K, V, C>::value_type; + return sizeof(value_type) * map.capacity() + EstimateIterableMemoryUsage(map); +} + } // namespace trace_event } // namespace base
diff --git a/chrome/browser/android/signin/signin_promo_util_android.cc b/chrome/browser/android/signin/signin_promo_util_android.cc index 509cd55..3e357f5 100644 --- a/chrome/browser/android/signin/signin_promo_util_android.cc +++ b/chrome/browser/android/signin/signin_promo_util_android.cc
@@ -13,12 +13,11 @@ // static void SigninPromoUtilAndroid::StartAccountSigninActivityForPromo( - content::ContentViewCore* content_view_core, + ui::WindowAndroid* window, signin_metrics::AccessPoint access_point) { - if (content_view_core && content_view_core->GetWindowAndroid()) { + if (window) { Java_SigninPromoUtil_openAccountSigninActivityForPromo( - base::android::AttachCurrentThread(), - content_view_core->GetWindowAndroid()->GetJavaObject(), + base::android::AttachCurrentThread(), window->GetJavaObject(), jint(access_point)); } }
diff --git a/chrome/browser/android/signin/signin_promo_util_android.h b/chrome/browser/android/signin/signin_promo_util_android.h index aa646fb..4f11d1af 100644 --- a/chrome/browser/android/signin/signin_promo_util_android.h +++ b/chrome/browser/android/signin/signin_promo_util_android.h
@@ -7,17 +7,19 @@ #include "base/android/jni_android.h" #include "components/signin/core/browser/signin_metrics.h" -#include "content/public/browser/android/content_view_core.h" + +namespace ui { +class WindowAndroid; +} namespace chrome { namespace android { class SigninPromoUtilAndroid { public: - // Opens a signin flow with the specified |access_point| for metrics within - // the context of |content_view_core|, which could be null. + // Opens a signin flow with the specified |access_point| for metrics. static void StartAccountSigninActivityForPromo( - content::ContentViewCore* content_view_core, + ui::WindowAndroid* window, signin_metrics::AccessPoint access_point); };
diff --git a/chrome/browser/chromeos/arc/arc_service_launcher.cc b/chrome/browser/chromeos/arc/arc_service_launcher.cc index bbf149a9..decc9ea 100644 --- a/chrome/browser/chromeos/arc/arc_service_launcher.cc +++ b/chrome/browser/chromeos/arc/arc_service_launcher.cc
@@ -105,10 +105,6 @@ arc_service_manager_->AddService( base::MakeUnique<ArcPolicyBridge>(arc_bridge_service)); arc_service_manager_->AddService( - base::MakeUnique<ArcPowerBridge>(arc_bridge_service)); - arc_service_manager_->AddService( - base::MakeUnique<ArcPrintService>(arc_bridge_service)); - arc_service_manager_->AddService( base::MakeUnique<ArcProcessService>(arc_bridge_service)); arc_service_manager_->AddService( base::MakeUnique<ArcProvisionNotificationService>(arc_bridge_service)); @@ -193,6 +189,8 @@ ArcFileSystemMounter::GetForBrowserContext(profile); ArcMetricsService::GetForBrowserContext(profile); ArcObbMounterBridge::GetForBrowserContext(profile); + ArcPowerBridge::GetForBrowserContext(profile); + ArcPrintService::GetForBrowserContext(profile); arc_service_manager_->AddService(base::MakeUnique<ArcBootPhaseMonitorBridge>( arc_service_manager_->arc_bridge_service(),
diff --git a/chrome/browser/chromeos/arc/print/arc_print_service.cc b/chrome/browser/chromeos/arc/print/arc_print_service.cc index 185629a..4a38649 100644 --- a/chrome/browser/chromeos/arc/print/arc_print_service.cc +++ b/chrome/browser/chromeos/arc/print/arc_print_service.cc
@@ -11,10 +11,12 @@ #include "base/bind.h" #include "base/files/file_util.h" #include "base/logging.h" +#include "base/memory/singleton.h" #include "base/task_scheduler/post_task.h" #include "base/task_scheduler/task_traits.h" #include "base/threading/thread_restrictions.h" #include "components/arc/arc_bridge_service.h" +#include "components/arc/arc_browser_context_keyed_service_factory_base.h" #include "mojo/edk/embedder/embedder.h" #include "net/base/filename_util.h" #include "url/gurl.h" @@ -45,19 +47,55 @@ } // namespace namespace arc { +namespace { -ArcPrintService::ArcPrintService(ArcBridgeService* bridge_service) - : ArcService(bridge_service), binding_(this), weak_ptr_factory_(this) { - arc_bridge_service()->print()->AddObserver(this); +// Singleton factory for ArcPrintService. +class ArcPrintServiceFactory + : public internal::ArcBrowserContextKeyedServiceFactoryBase< + ArcPrintService, + ArcPrintServiceFactory> { + public: + // Factory name used by ArcBrowserContextKeyedServiceFactoryBase. + static constexpr const char* kName = "ArcPrintServiceFactory"; + + static ArcPrintServiceFactory* GetInstance() { + return base::Singleton<ArcPrintServiceFactory>::get(); + } + + private: + friend base::DefaultSingletonTraits<ArcPrintServiceFactory>; + ArcPrintServiceFactory() = default; + ~ArcPrintServiceFactory() override = default; +}; + +} // namespace + +// static +ArcPrintService* ArcPrintService::GetForBrowserContext( + content::BrowserContext* context) { + return ArcPrintServiceFactory::GetForBrowserContext(context); +} + +ArcPrintService::ArcPrintService(content::BrowserContext* context, + ArcBridgeService* bridge_service) + : arc_bridge_service_(bridge_service), + binding_(this), + weak_ptr_factory_(this) { + arc_bridge_service_->print()->AddObserver(this); } ArcPrintService::~ArcPrintService() { - arc_bridge_service()->print()->RemoveObserver(this); + // TODO(hidehiko): Currently, the lifetime of ArcBridgeService and + // BrowserContextKeyedService is not nested. + // If ArcServiceManager::Get() returns nullptr, it is already destructed, + // so do not touch it. + if (ArcServiceManager::Get()) + arc_bridge_service_->print()->RemoveObserver(this); } void ArcPrintService::OnInstanceReady() { mojom::PrintInstance* print_instance = - ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->print(), Init); + ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service_->print(), Init); DCHECK(print_instance); mojom::PrintHostPtr host_proxy; binding_.Bind(mojo::MakeRequest(&host_proxy));
diff --git a/chrome/browser/chromeos/arc/print/arc_print_service.h b/chrome/browser/chromeos/arc/print/arc_print_service.h index 17205fe1..eb468380 100644 --- a/chrome/browser/chromeos/arc/print/arc_print_service.h +++ b/chrome/browser/chromeos/arc/print/arc_print_service.h
@@ -10,20 +10,30 @@ #include "base/memory/weak_ptr.h" #include "base/optional.h" #include "base/threading/thread_checker.h" -#include "components/arc/arc_service.h" #include "components/arc/common/print.mojom.h" #include "components/arc/instance_holder.h" +#include "components/keyed_service/core/keyed_service.h" #include "mojo/public/cpp/bindings/binding.h" +namespace content { +class BrowserContext; +} // namespace content + namespace arc { class ArcBridgeService; -class ArcPrintService : public ArcService, +class ArcPrintService : public KeyedService, public InstanceHolder<mojom::PrintInstance>::Observer, public mojom::PrintHost { public: - explicit ArcPrintService(ArcBridgeService* bridge_service); + // Returns singleton instance for the given BrowserContext, + // or nullptr if the browser |context| is not allowed to use ARC. + static ArcPrintService* GetForBrowserContext( + content::BrowserContext* context); + + ArcPrintService(content::BrowserContext* context, + ArcBridgeService* bridge_service); ~ArcPrintService() override; // InstanceHolder<mojom::PrintInstance>::Observer override: @@ -38,6 +48,8 @@ void OpenPdf(base::Optional<base::FilePath> file_path) const; THREAD_CHECKER(thread_checker_); + + ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager. mojo::Binding<mojom::PrintHost> binding_; base::WeakPtrFactory<ArcPrintService> weak_ptr_factory_;
diff --git a/chrome/browser/ui/autofill/chrome_autofill_client.cc b/chrome/browser/ui/autofill/chrome_autofill_client.cc index 9768baf3..286ef02ec 100644 --- a/chrome/browser/ui/autofill/chrome_autofill_client.cc +++ b/chrome/browser/ui/autofill/chrome_autofill_client.cc
@@ -57,7 +57,7 @@ #include "components/autofill/core/browser/autofill_save_card_infobar_delegate_mobile.h" #include "components/autofill/core/browser/autofill_save_card_infobar_mobile.h" #include "components/infobars/core/infobar.h" -#include "content/public/browser/android/content_view_core.h" +#include "ui/android/window_android.h" #else // !OS_ANDROID #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" #include "chrome/browser/ui/browser.h" @@ -378,9 +378,11 @@ void ChromeAutofillClient::StartSigninFlow() { #if defined(OS_ANDROID) - chrome::android::SigninPromoUtilAndroid::StartAccountSigninActivityForPromo( - content::ContentViewCore::FromWebContents(web_contents()), - signin_metrics::AccessPoint::ACCESS_POINT_AUTOFILL_DROPDOWN); + auto* window = web_contents()->GetNativeView()->GetWindowAndroid(); + if (window) { + chrome::android::SigninPromoUtilAndroid::StartAccountSigninActivityForPromo( + window, signin_metrics::AccessPoint::ACCESS_POINT_AUTOFILL_DROPDOWN); + } #endif }
diff --git a/components/arc/power/arc_power_bridge.cc b/components/arc/power/arc_power_bridge.cc index 98d1384..72e99db 100644 --- a/components/arc/power/arc_power_bridge.cc +++ b/components/arc/power/arc_power_bridge.cc
@@ -9,31 +9,70 @@ #include "ash/shell.h" #include "base/logging.h" +#include "base/memory/singleton.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/power_policy_controller.h" #include "components/arc/arc_bridge_service.h" +#include "components/arc/arc_browser_context_keyed_service_factory_base.h" #include "components/arc/arc_service_manager.h" namespace arc { +namespace { // Delay for notifying Android about screen brightness changes, added in // order to prevent spammy brightness updates. constexpr base::TimeDelta kNotifyBrightnessDelay = base::TimeDelta::FromMilliseconds(200); -ArcPowerBridge::ArcPowerBridge(ArcBridgeService* bridge_service) - : ArcService(bridge_service), binding_(this), weak_ptr_factory_(this) { - arc_bridge_service()->power()->AddObserver(this); +// Singleton factory for ArcPowerBridge. +class ArcPowerBridgeFactory + : public internal::ArcBrowserContextKeyedServiceFactoryBase< + ArcPowerBridge, + ArcPowerBridgeFactory> { + public: + // Factory name used by ArcBrowserContextKeyedServiceFactoryBase. + static constexpr const char* kName = "ArcPowerBridgeFactory"; + + static ArcPowerBridgeFactory* GetInstance() { + return base::Singleton<ArcPowerBridgeFactory>::get(); + } + + private: + friend base::DefaultSingletonTraits<ArcPowerBridgeFactory>; + ArcPowerBridgeFactory() = default; + ~ArcPowerBridgeFactory() override = default; +}; + +} // namespace + +// static +ArcPowerBridge* ArcPowerBridge::GetForBrowserContext( + content::BrowserContext* context) { + return ArcPowerBridgeFactory::GetForBrowserContext(context); +} + +ArcPowerBridge::ArcPowerBridge(content::BrowserContext* context, + ArcBridgeService* bridge_service) + : arc_bridge_service_(bridge_service), + binding_(this), + weak_ptr_factory_(this) { + arc_bridge_service_->power()->AddObserver(this); } ArcPowerBridge::~ArcPowerBridge() { - arc_bridge_service()->power()->RemoveObserver(this); ReleaseAllDisplayWakeLocks(); + + // TODO(hidehiko): Currently, the lifetime of ArcBridgeService and + // BrowserContextKeyedService is not nested. + // If ArcServiceManager::Get() returns nullptr, it is already destructed, + // so do not touch it. + if (ArcServiceManager::Get()) + arc_bridge_service_->power()->RemoveObserver(this); } void ArcPowerBridge::OnInstanceReady() { mojom::PowerInstance* power_instance = - ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->power(), Init); + ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service_->power(), Init); DCHECK(power_instance); mojom::PowerHostPtr host_proxy; binding_.Bind(mojo::MakeRequest(&host_proxy)); @@ -56,8 +95,8 @@ } void ArcPowerBridge::SuspendImminent() { - mojom::PowerInstance* power_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->power(), Suspend); + mojom::PowerInstance* power_instance = + ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service_->power(), Suspend); if (!power_instance) return; @@ -67,8 +106,8 @@ } void ArcPowerBridge::SuspendDone(const base::TimeDelta& sleep_duration) { - mojom::PowerInstance* power_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->power(), Resume); + mojom::PowerInstance* power_instance = + ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service_->power(), Resume); if (!power_instance) return; @@ -93,8 +132,8 @@ void ArcPowerBridge::OnPowerStateChanged( chromeos::DisplayPowerState power_state) { - mojom::PowerInstance* power_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->power(), SetInteractive); + mojom::PowerInstance* power_instance = + ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service_->power(), SetInteractive); if (!power_instance) return; @@ -175,7 +214,7 @@ void ArcPowerBridge::UpdateAndroidScreenBrightness(double percent) { mojom::PowerInstance* power_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->power(), UpdateScreenBrightnessSettings); + arc_bridge_service_->power(), UpdateScreenBrightnessSettings); if (!power_instance) return; power_instance->UpdateScreenBrightnessSettings(percent);
diff --git a/components/arc/power/arc_power_bridge.h b/components/arc/power/arc_power_bridge.h index e6a5c7a..7d2c073 100644 --- a/components/arc/power/arc_power_bridge.h +++ b/components/arc/power/arc_power_bridge.h
@@ -9,25 +9,34 @@ #include "base/macros.h" #include "chromeos/dbus/power_manager_client.h" -#include "components/arc/arc_service.h" #include "components/arc/common/power.mojom.h" #include "components/arc/instance_holder.h" +#include "components/keyed_service/core/keyed_service.h" #include "mojo/public/cpp/bindings/binding.h" #include "ui/display/manager/chromeos/display_configurator.h" +namespace content { +class BrowserContext; +} // namespace content + namespace arc { class ArcBridgeService; // ARC Power Client sets power management policy based on requests from // ARC instances. -class ArcPowerBridge : public ArcService, +class ArcPowerBridge : public KeyedService, public InstanceHolder<mojom::PowerInstance>::Observer, public chromeos::PowerManagerClient::Observer, public display::DisplayConfigurator::Observer, public mojom::PowerHost { public: - explicit ArcPowerBridge(ArcBridgeService* bridge_service); + // Returns singleton instance for the given BrowserContext, + // or nullptr if the browser |context| is not allowed to use ARC. + static ArcPowerBridge* GetForBrowserContext(content::BrowserContext* context); + + ArcPowerBridge(content::BrowserContext* context, + ArcBridgeService* bridge_service); ~ArcPowerBridge() override; // InstanceHolder<mojom::PowerInstance>::Observer overrides. @@ -52,6 +61,7 @@ void ReleaseAllDisplayWakeLocks(); void UpdateAndroidScreenBrightness(double percent); + ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager. mojo::Binding<mojom::PowerHost> binding_; // Stores a mapping of type -> wake lock ID for all wake locks
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn index ec3b745..10d487d8 100644 --- a/content/browser/BUILD.gn +++ b/content/browser/BUILD.gn
@@ -1882,9 +1882,9 @@ "accessibility/web_contents_accessibility_android.h", "android/composited_touch_handle_drawable.cc", "android/composited_touch_handle_drawable.h", - "android/content_view_core_impl.cc", - "android/content_view_core_impl.h", - "android/content_view_core_impl_observer.h", + "android/content_view_core.cc", + "android/content_view_core.h", + "android/content_view_core_observer.h", "android/content_view_render_view.cc", "android/content_view_render_view.h", "android/content_view_statics.cc",
diff --git a/content/browser/android/content_video_view.h b/content/browser/android/content_video_view.h index cb9c0d3..3d9ca1d 100644 --- a/content/browser/android/content_video_view.h +++ b/content/browser/android/content_video_view.h
@@ -11,7 +11,7 @@ #include "base/android/scoped_java_ref.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "content/public/browser/android/content_view_core.h" +#include "content/browser/android/content_view_core.h" #include "ui/gl/android/scoped_java_surface.h" namespace content {
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core.cc similarity index 73% rename from content/browser/android/content_view_core_impl.cc rename to content/browser/android/content_view_core.cc index 23cadc69..042e028 100644 --- a/content/browser/android/content_view_core_impl.cc +++ b/content/browser/android/content_view_core.cc
@@ -1,8 +1,8 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. +// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/android/content_view_core_impl.h" +#include "content/browser/android/content_view_core.h" #include <stddef.h> @@ -102,15 +102,10 @@ return 0; } -ScopedJavaLocalRef<jobject> CreateJavaRect( - JNIEnv* env, - const gfx::Rect& rect) { - return ScopedJavaLocalRef<jobject>( - Java_ContentViewCore_createRect(env, - static_cast<int>(rect.x()), - static_cast<int>(rect.y()), - static_cast<int>(rect.right()), - static_cast<int>(rect.bottom()))); +ScopedJavaLocalRef<jobject> CreateJavaRect(JNIEnv* env, const gfx::Rect& rect) { + return ScopedJavaLocalRef<jobject>(Java_ContentViewCore_createRect( + env, static_cast<int>(rect.x()), static_cast<int>(rect.y()), + static_cast<int>(rect.right()), static_cast<int>(rect.bottom()))); } int ToGestureEventType(WebInputEvent::Type type) { @@ -159,12 +154,11 @@ // Enables a callback when the underlying WebContents is destroyed, to enable // nulling the back-pointer. -class ContentViewCoreImpl::ContentViewUserData +class ContentViewCore::ContentViewUserData : public base::SupportsUserData::Data { public: - explicit ContentViewUserData(ContentViewCoreImpl* content_view_core) - : content_view_core_(content_view_core) { - } + explicit ContentViewUserData(ContentViewCore* content_view_core) + : content_view_core_(content_view_core) {} ~ContentViewUserData() override { // TODO(joth): When chrome has finished removing the TabContents class (see @@ -174,31 +168,25 @@ delete content_view_core_; } - ContentViewCoreImpl* get() const { return content_view_core_; } + ContentViewCore* get() const { return content_view_core_; } private: - // Not using scoped_ptr as ContentViewCoreImpl destructor is private. - ContentViewCoreImpl* content_view_core_; + // Not using scoped_ptr as ContentViewCore destructor is private. + ContentViewCore* content_view_core_; DISALLOW_IMPLICIT_CONSTRUCTORS(ContentViewUserData); }; // static -ContentViewCoreImpl* ContentViewCoreImpl::FromWebContents( +ContentViewCore* ContentViewCore::FromWebContents( content::WebContents* web_contents) { - ContentViewCoreImpl::ContentViewUserData* data = - static_cast<ContentViewCoreImpl::ContentViewUserData*>( + ContentViewCore::ContentViewUserData* data = + static_cast<ContentViewCore::ContentViewUserData*>( web_contents->GetUserData(kContentViewUserDataKey)); return data ? data->get() : NULL; } -// static -ContentViewCore* ContentViewCore::FromWebContents( - content::WebContents* web_contents) { - return ContentViewCoreImpl::FromWebContents(web_contents); -} - -ContentViewCoreImpl::ContentViewCoreImpl( +ContentViewCore::ContentViewCore( JNIEnv* env, const JavaRef<jobject>& obj, WebContents* web_contents, @@ -221,24 +209,21 @@ BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product); web_contents->SetUserAgentOverride(spoofed_ua); - java_bridge_dispatcher_host_ = - new GinJavaBridgeDispatcherHost(web_contents, - java_bridge_retained_object_set); + java_bridge_dispatcher_host_ = new GinJavaBridgeDispatcherHost( + web_contents, java_bridge_retained_object_set); InitWebContents(); } -void ContentViewCoreImpl::AddObserver( - ContentViewCoreImplObserver* observer) { +void ContentViewCore::AddObserver(ContentViewCoreObserver* observer) { observer_list_.AddObserver(observer); } -void ContentViewCoreImpl::RemoveObserver( - ContentViewCoreImplObserver* observer) { +void ContentViewCore::RemoveObserver(ContentViewCoreObserver* observer) { observer_list_.RemoveObserver(observer); } -ContentViewCoreImpl::~ContentViewCoreImpl() { +ContentViewCore::~ContentViewCore() { for (auto& observer : observer_list_) observer.OnContentViewCoreDestroyed(); observer_list_.Clear(); @@ -252,7 +237,7 @@ } } -void ContentViewCoreImpl::UpdateWindowAndroid( +void ContentViewCore::UpdateWindowAndroid( JNIEnv* env, const base::android::JavaParamRef<jobject>& obj, jlong window_android) { @@ -274,20 +259,20 @@ } base::android::ScopedJavaLocalRef<jobject> -ContentViewCoreImpl::GetWebContentsAndroid(JNIEnv* env, - const JavaParamRef<jobject>& obj) { +ContentViewCore::GetWebContentsAndroid(JNIEnv* env, + const JavaParamRef<jobject>& obj) { return web_contents_->GetJavaWebContents(); } base::android::ScopedJavaLocalRef<jobject> -ContentViewCoreImpl::GetJavaWindowAndroid(JNIEnv* env, - const JavaParamRef<jobject>& obj) { +ContentViewCore::GetJavaWindowAndroid(JNIEnv* env, + const JavaParamRef<jobject>& obj) { if (!GetWindowAndroid()) return ScopedJavaLocalRef<jobject>(); return GetWindowAndroid()->GetJavaObject(); } -void ContentViewCoreImpl::OnJavaContentViewCoreDestroyed( +void ContentViewCore::OnJavaContentViewCoreDestroyed( JNIEnv* env, const JavaParamRef<jobject>& obj) { DCHECK(env->IsSameObject(java_ref_.get(env).obj(), obj)); @@ -299,21 +284,21 @@ // see http://crbug.com/383939 . DCHECK(web_contents_); static_cast<WebContentsViewAndroid*>( - static_cast<WebContentsImpl*>(web_contents_)->GetView())-> - SetContentViewCore(NULL); + static_cast<WebContentsImpl*>(web_contents_)->GetView()) + ->SetContentViewCore(NULL); } -void ContentViewCoreImpl::InitWebContents() { +void ContentViewCore::InitWebContents() { DCHECK(web_contents_); static_cast<WebContentsViewAndroid*>( - static_cast<WebContentsImpl*>(web_contents_)->GetView())-> - SetContentViewCore(this); + static_cast<WebContentsImpl*>(web_contents_)->GetView()) + ->SetContentViewCore(this); DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey)); web_contents_->SetUserData(kContentViewUserDataKey, base::MakeUnique<ContentViewUserData>(this)); } -void ContentViewCoreImpl::RenderViewReady() { +void ContentViewCore::RenderViewReady() { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); if (!obj.is_null()) @@ -323,8 +308,8 @@ SendOrientationChangeEventInternal(); } -void ContentViewCoreImpl::RenderViewHostChanged(RenderViewHost* old_host, - RenderViewHost* new_host) { +void ContentViewCore::RenderViewHostChanged(RenderViewHost* old_host, + RenderViewHost* new_host) { int old_pid = 0; if (old_host) { old_pid = GetRenderProcessIdFromRenderViewHost(old_host); @@ -340,8 +325,8 @@ if (view) view->SetContentViewCore(this); } - int new_pid = GetRenderProcessIdFromRenderViewHost( - web_contents_->GetRenderViewHost()); + int new_pid = + GetRenderProcessIdFromRenderViewHost(web_contents_->GetRenderViewHost()); if (new_pid != old_pid) { // Notify the Java side that the renderer process changed. JNIEnv* env = AttachCurrentThread(); @@ -354,8 +339,8 @@ SetFocusInternal(HasFocus()); } -RenderWidgetHostViewAndroid* - ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() const { +RenderWidgetHostViewAndroid* ContentViewCore::GetRenderWidgetHostViewAndroid() + const { RenderWidgetHostView* rwhv = NULL; if (web_contents_) { rwhv = web_contents_->GetRenderWidgetHostView(); @@ -370,12 +355,12 @@ return static_cast<RenderWidgetHostViewAndroid*>(rwhv); } -ScopedJavaLocalRef<jobject> ContentViewCoreImpl::GetJavaObject() { +ScopedJavaLocalRef<jobject> ContentViewCore::GetJavaObject() { JNIEnv* env = AttachCurrentThread(); return java_ref_.get(env); } -jint ContentViewCoreImpl::GetBackgroundColor(JNIEnv* env, jobject obj) { +jint ContentViewCore::GetBackgroundColor(JNIEnv* env, jobject obj) { RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); if (!rwhva) return SK_ColorWHITE; @@ -385,7 +370,7 @@ // All positions and sizes (except |top_shown_pix|) are in CSS pixels. // Note that viewport_width/height is a best effort based. // ContentViewCore has the actual information about the physical viewport size. -void ContentViewCoreImpl::UpdateFrameInfo( +void ContentViewCore::UpdateFrameInfo( const gfx::Vector2dF& scroll_offset, float page_scale_factor, const gfx::Vector2dF& page_scale_factor_limits, @@ -412,13 +397,12 @@ is_mobile_optimized_hint); } -void ContentViewCoreImpl::ShowSelectPopupMenu( - RenderFrameHost* frame, - const gfx::Rect& bounds, - const std::vector<MenuItem>& items, - int selected_item, - bool multiple, - bool right_aligned) { +void ContentViewCore::ShowSelectPopupMenu(RenderFrameHost* frame, + const gfx::Rect& bounds, + const std::vector<MenuItem>& items, + int selected_item, + bool multiple, + bool right_aligned) { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); if (j_obj.is_null()) @@ -436,8 +420,8 @@ native_selected_array[selected_count++] = i; } - selected_array = ScopedJavaLocalRef<jintArray>( - env, env->NewIntArray(selected_count)); + selected_array = + ScopedJavaLocalRef<jintArray>(env, env->NewIntArray(selected_count)); env->SetIntArrayRegion(selected_array.obj(), 0, selected_count, native_selected_array.get()); } else { @@ -452,10 +436,10 @@ labels.reserve(items.size()); for (size_t i = 0; i < items.size(); ++i) { labels.push_back(items[i].label); - jint enabled = - (items[i].type == MenuItem::GROUP ? POPUP_ITEM_TYPE_GROUP : - (items[i].enabled ? POPUP_ITEM_TYPE_ENABLED : - POPUP_ITEM_TYPE_DISABLED)); + jint enabled = (items[i].type == MenuItem::GROUP + ? POPUP_ITEM_TYPE_GROUP + : (items[i].enabled ? POPUP_ITEM_TYPE_ENABLED + : POPUP_ITEM_TYPE_DISABLED)); env->SetIntArrayRegion(enabled_array.obj(), i, 1, &enabled); } ScopedJavaLocalRef<jobjectArray> items_array( @@ -471,7 +455,7 @@ enabled_array, multiple, selected_array, right_aligned); } -void ContentViewCoreImpl::HideSelectPopupMenu() { +void ContentViewCore::HideSelectPopupMenu() { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); if (!j_obj.is_null()) @@ -479,8 +463,8 @@ select_popup_.Reset(); } -void ContentViewCoreImpl::OnGestureEventAck(const blink::WebGestureEvent& event, - InputEventAckState ack_result) { +void ContentViewCore::OnGestureEventAck(const blink::WebGestureEvent& event, + InputEventAckState ack_result) { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); if (j_obj.is_null()) @@ -530,7 +514,7 @@ } } -bool ContentViewCoreImpl::FilterInputEvent(const blink::WebInputEvent& event) { +bool ContentViewCore::FilterInputEvent(const blink::WebInputEvent& event) { if (event.GetType() != WebInputEvent::kGestureTap && event.GetType() != WebInputEvent::kGestureLongTap && event.GetType() != WebInputEvent::kGestureLongPress && @@ -555,7 +539,7 @@ gesture.y * dpi_scale()); } -bool ContentViewCoreImpl::HasFocus() { +bool ContentViewCore::HasFocus() { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); if (obj.is_null()) @@ -563,16 +547,15 @@ return Java_ContentViewCore_hasFocus(env, obj); } -void ContentViewCoreImpl::RequestDisallowInterceptTouchEvent() { +void ContentViewCore::RequestDisallowInterceptTouchEvent() { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); if (!obj.is_null()) Java_ContentViewCore_requestDisallowInterceptTouchEvent(env, obj); } -void ContentViewCoreImpl::ShowDisambiguationPopup( - const gfx::Rect& rect_pixels, - const SkBitmap& zoomed_bitmap) { +void ContentViewCore::ShowDisambiguationPopup(const gfx::Rect& rect_pixels, + const SkBitmap& zoomed_bitmap) { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); @@ -589,8 +572,7 @@ java_bitmap); } -ScopedJavaLocalRef<jobject> -ContentViewCoreImpl::CreateMotionEventSynthesizer() { +ScopedJavaLocalRef<jobject> ContentViewCore::CreateMotionEventSynthesizer() { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); @@ -599,7 +581,7 @@ return Java_ContentViewCore_createMotionEventSynthesizer(env, obj); } -void ContentViewCoreImpl::DidStopFlinging() { +void ContentViewCore::DidStopFlinging() { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); @@ -607,7 +589,7 @@ Java_ContentViewCore_onNativeFlingStopped(env, obj); } -ScopedJavaLocalRef<jobject> ContentViewCoreImpl::GetContext() const { +ScopedJavaLocalRef<jobject> ContentViewCore::GetContext() const { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); @@ -617,14 +599,14 @@ return Java_ContentViewCore_getContext(env, obj); } -gfx::Size ContentViewCoreImpl::GetViewSize() const { +gfx::Size ContentViewCore::GetViewSize() const { gfx::Size size = GetViewportSizeDip(); if (DoBrowserControlsShrinkBlinkSize()) size.Enlarge(0, -GetTopControlsHeightDip() - GetBottomControlsHeightDip()); return size; } -gfx::Size ContentViewCoreImpl::GetViewportSizePix() const { +gfx::Size ContentViewCore::GetViewportSizePix() const { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); if (j_obj.is_null()) @@ -633,7 +615,7 @@ Java_ContentViewCore_getViewportHeightPix(env, j_obj)); } -int ContentViewCoreImpl::GetTopControlsHeightPix() const { +int ContentViewCore::GetTopControlsHeightPix() const { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); if (j_obj.is_null()) @@ -641,7 +623,7 @@ return Java_ContentViewCore_getTopControlsHeightPix(env, j_obj); } -int ContentViewCoreImpl::GetBottomControlsHeightPix() const { +int ContentViewCore::GetBottomControlsHeightPix() const { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); if (j_obj.is_null()) @@ -649,11 +631,11 @@ return Java_ContentViewCore_getBottomControlsHeightPix(env, j_obj); } -gfx::Size ContentViewCoreImpl::GetViewportSizeDip() const { +gfx::Size ContentViewCore::GetViewportSizeDip() const { return gfx::ScaleToCeiledSize(GetViewportSizePix(), 1.0f / dpi_scale()); } -bool ContentViewCoreImpl::DoBrowserControlsShrinkBlinkSize() const { +bool ContentViewCore::DoBrowserControlsShrinkBlinkSize() const { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); if (j_obj.is_null()) @@ -661,15 +643,15 @@ return Java_ContentViewCore_doBrowserControlsShrinkBlinkSize(env, j_obj); } -float ContentViewCoreImpl::GetTopControlsHeightDip() const { +float ContentViewCore::GetTopControlsHeightDip() const { return GetTopControlsHeightPix() / dpi_scale(); } -float ContentViewCoreImpl::GetBottomControlsHeightDip() const { +float ContentViewCore::GetBottomControlsHeightDip() const { return GetBottomControlsHeightPix() / dpi_scale(); } -void ContentViewCoreImpl::SendScreenRectsAndResizeWidget() { +void ContentViewCore::SendScreenRectsAndResizeWidget() { RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); if (view) { // |SendScreenRects()| indirectly calls GetViewSize() that asks Java layer. @@ -678,15 +660,15 @@ } } -void ContentViewCoreImpl::MoveRangeSelectionExtent(const gfx::PointF& extent) { +void ContentViewCore::MoveRangeSelectionExtent(const gfx::PointF& extent) { if (!web_contents_) return; web_contents_->MoveRangeSelectionExtent(gfx::ToRoundedPoint(extent)); } -void ContentViewCoreImpl::SelectBetweenCoordinates(const gfx::PointF& base, - const gfx::PointF& extent) { +void ContentViewCore::SelectBetweenCoordinates(const gfx::PointF& base, + const gfx::PointF& extent) { if (!web_contents_) return; @@ -698,20 +680,19 @@ web_contents_->SelectRange(base_point, extent_point); } -ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { +ui::WindowAndroid* ContentViewCore::GetWindowAndroid() const { return GetViewAndroid()->GetWindowAndroid(); } -ui::ViewAndroid* ContentViewCoreImpl::GetViewAndroid() const { +ui::ViewAndroid* ContentViewCore::GetViewAndroid() const { return web_contents_->GetView()->GetNativeView(); } - // ---------------------------------------------------------------------------- // Methods called from Java via JNI // ---------------------------------------------------------------------------- -void ContentViewCoreImpl::SelectPopupMenuItems( +void ContentViewCore::SelectPopupMenuItems( JNIEnv* env, const JavaParamRef<jobject>& obj, jlong selectPopupSourceFrame, @@ -733,19 +714,19 @@ rfhi->DidSelectPopupMenuItems(selected_indices); } -WebContents* ContentViewCoreImpl::GetWebContents() const { +WebContents* ContentViewCore::GetWebContents() const { return web_contents_; } -void ContentViewCoreImpl::SetFocus(JNIEnv* env, - const JavaParamRef<jobject>& obj, - jboolean focused) { +void ContentViewCore::SetFocus(JNIEnv* env, + const JavaParamRef<jobject>& obj, + jboolean focused) { SetFocusInternal(focused); } -void ContentViewCoreImpl::SetDIPScale(JNIEnv* env, - const JavaParamRef<jobject>& obj, - jfloat dpi_scale) { +void ContentViewCore::SetDIPScale(JNIEnv* env, + const JavaParamRef<jobject>& obj, + jfloat dpi_scale) { if (dpi_scale_ == dpi_scale) return; @@ -753,7 +734,7 @@ SendScreenRectsAndResizeWidget(); } -void ContentViewCoreImpl::SetFocusInternal(bool focused) { +void ContentViewCore::SetFocusInternal(bool focused) { if (!GetRenderWidgetHostViewAndroid()) return; @@ -763,7 +744,7 @@ GetRenderWidgetHostViewAndroid()->Blur(); } -void ContentViewCoreImpl::SendOrientationChangeEvent( +void ContentViewCore::SendOrientationChangeEvent( JNIEnv* env, const JavaParamRef<jobject>& obj, jint orientation) { @@ -774,30 +755,29 @@ } } -WebGestureEvent ContentViewCoreImpl::MakeGestureEvent(WebInputEvent::Type type, - int64_t time_ms, - float x, - float y) const { - return WebGestureEventBuilder::Build( - type, time_ms / 1000.0, x / dpi_scale(), y / dpi_scale()); +WebGestureEvent ContentViewCore::MakeGestureEvent(WebInputEvent::Type type, + int64_t time_ms, + float x, + float y) const { + return WebGestureEventBuilder::Build(type, time_ms / 1000.0, x / dpi_scale(), + y / dpi_scale()); } -void ContentViewCoreImpl::SendGestureEvent( - const blink::WebGestureEvent& event) { +void ContentViewCore::SendGestureEvent(const blink::WebGestureEvent& event) { RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); if (rwhv) rwhv->SendGestureEvent(event); } -void ContentViewCoreImpl::ScrollBegin(JNIEnv* env, - const JavaParamRef<jobject>& obj, - jlong time_ms, - jfloat x, - jfloat y, - jfloat hintx, - jfloat hinty, - jboolean target_viewport, - jboolean from_gamepad) { +void ContentViewCore::ScrollBegin(JNIEnv* env, + const JavaParamRef<jobject>& obj, + jlong time_ms, + jfloat x, + jfloat y, + jfloat hintx, + jfloat hinty, + jboolean target_viewport, + jboolean from_gamepad) { WebGestureEvent event = MakeGestureEvent(WebInputEvent::kGestureScrollBegin, time_ms, x, y); event.data.scroll_begin.delta_x_hint = hintx / dpi_scale(); @@ -810,21 +790,21 @@ SendGestureEvent(event); } -void ContentViewCoreImpl::ScrollEnd(JNIEnv* env, - const JavaParamRef<jobject>& obj, - jlong time_ms) { +void ContentViewCore::ScrollEnd(JNIEnv* env, + const JavaParamRef<jobject>& obj, + jlong time_ms) { WebGestureEvent event = MakeGestureEvent(WebInputEvent::kGestureScrollEnd, time_ms, 0, 0); SendGestureEvent(event); } -void ContentViewCoreImpl::ScrollBy(JNIEnv* env, - const JavaParamRef<jobject>& obj, - jlong time_ms, - jfloat x, - jfloat y, - jfloat dx, - jfloat dy) { +void ContentViewCore::ScrollBy(JNIEnv* env, + const JavaParamRef<jobject>& obj, + jlong time_ms, + jfloat x, + jfloat y, + jfloat dx, + jfloat dy) { WebGestureEvent event = MakeGestureEvent(WebInputEvent::kGestureScrollUpdate, time_ms, x, y); event.data.scroll_update.delta_x = -dx / dpi_scale(); @@ -833,15 +813,15 @@ SendGestureEvent(event); } -void ContentViewCoreImpl::FlingStart(JNIEnv* env, - const JavaParamRef<jobject>& obj, - jlong time_ms, - jfloat x, - jfloat y, - jfloat vx, - jfloat vy, - jboolean target_viewport, - jboolean from_gamepad) { +void ContentViewCore::FlingStart(JNIEnv* env, + const JavaParamRef<jobject>& obj, + jlong time_ms, + jfloat x, + jfloat y, + jfloat vx, + jfloat vy, + jboolean target_viewport, + jboolean from_gamepad) { WebGestureEvent event = MakeGestureEvent(WebInputEvent::kGestureFlingStart, time_ms, x, y); event.data.fling_start.velocity_x = vx / dpi_scale(); @@ -854,10 +834,10 @@ SendGestureEvent(event); } -void ContentViewCoreImpl::FlingCancel(JNIEnv* env, - const JavaParamRef<jobject>& obj, - jlong time_ms, - jboolean from_gamepad) { +void ContentViewCore::FlingCancel(JNIEnv* env, + const JavaParamRef<jobject>& obj, + jlong time_ms, + jboolean from_gamepad) { WebGestureEvent event = MakeGestureEvent(WebInputEvent::kGestureFlingCancel, time_ms, 0, 0); event.data.fling_cancel.prevent_boosting = true; @@ -870,11 +850,11 @@ SendGestureEvent(event); } -void ContentViewCoreImpl::DoubleTap(JNIEnv* env, - const JavaParamRef<jobject>& obj, - jlong time_ms, - jfloat x, - jfloat y) { +void ContentViewCore::DoubleTap(JNIEnv* env, + const JavaParamRef<jobject>& obj, + jlong time_ms, + jfloat x, + jfloat y) { WebGestureEvent event = MakeGestureEvent(WebInputEvent::kGestureDoubleTap, time_ms, x, y); // Set the tap count to 1 even for DoubleTap, in order to be consistent with @@ -884,13 +864,12 @@ SendGestureEvent(event); } -void ContentViewCoreImpl::ResolveTapDisambiguation( - JNIEnv* env, - const JavaParamRef<jobject>& obj, - jlong time_ms, - jfloat x, - jfloat y, - jboolean is_long_press) { +void ContentViewCore::ResolveTapDisambiguation(JNIEnv* env, + const JavaParamRef<jobject>& obj, + jlong time_ms, + jfloat x, + jfloat y, + jboolean is_long_press) { RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); if (!rwhv) return; @@ -900,30 +879,30 @@ is_long_press); } -void ContentViewCoreImpl::PinchBegin(JNIEnv* env, - const JavaParamRef<jobject>& obj, - jlong time_ms, - jfloat x, - jfloat y) { +void ContentViewCore::PinchBegin(JNIEnv* env, + const JavaParamRef<jobject>& obj, + jlong time_ms, + jfloat x, + jfloat y) { WebGestureEvent event = MakeGestureEvent(WebInputEvent::kGesturePinchBegin, time_ms, x, y); SendGestureEvent(event); } -void ContentViewCoreImpl::PinchEnd(JNIEnv* env, - const JavaParamRef<jobject>& obj, - jlong time_ms) { +void ContentViewCore::PinchEnd(JNIEnv* env, + const JavaParamRef<jobject>& obj, + jlong time_ms) { WebGestureEvent event = MakeGestureEvent(WebInputEvent::kGesturePinchEnd, time_ms, 0, 0); SendGestureEvent(event); } -void ContentViewCoreImpl::PinchBy(JNIEnv* env, - const JavaParamRef<jobject>& obj, - jlong time_ms, - jfloat anchor_x, - jfloat anchor_y, - jfloat delta) { +void ContentViewCore::PinchBy(JNIEnv* env, + const JavaParamRef<jobject>& obj, + jlong time_ms, + jfloat anchor_x, + jfloat anchor_y, + jfloat delta) { WebGestureEvent event = MakeGestureEvent(WebInputEvent::kGesturePinchUpdate, time_ms, anchor_x, anchor_y); event.data.pinch_update.scale = delta; @@ -931,7 +910,7 @@ SendGestureEvent(event); } -void ContentViewCoreImpl::SetTextHandlesTemporarilyHidden( +void ContentViewCore::SetTextHandlesTemporarilyHidden( JNIEnv* env, const JavaParamRef<jobject>& obj, jboolean hidden) { @@ -940,15 +919,14 @@ rwhv->SetTextHandlesTemporarilyHidden(hidden); } -void ContentViewCoreImpl::ResetGestureDetection( - JNIEnv* env, - const JavaParamRef<jobject>& obj) { +void ContentViewCore::ResetGestureDetection(JNIEnv* env, + const JavaParamRef<jobject>& obj) { RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); if (rwhv) rwhv->ResetGestureDetection(); } -void ContentViewCoreImpl::SetDoubleTapSupportEnabled( +void ContentViewCore::SetDoubleTapSupportEnabled( JNIEnv* env, const JavaParamRef<jobject>& obj, jboolean enabled) { @@ -957,7 +935,7 @@ rwhv->SetDoubleTapSupportEnabled(enabled); } -void ContentViewCoreImpl::SetMultiTouchZoomSupportEnabled( +void ContentViewCore::SetMultiTouchZoomSupportEnabled( JNIEnv* env, const JavaParamRef<jobject>& obj, jboolean enabled) { @@ -966,7 +944,7 @@ rwhv->SetMultiTouchZoomSupportEnabled(enabled); } -void ContentViewCoreImpl::OnTouchDown( +void ContentViewCore::OnTouchDown( const base::android::ScopedJavaLocalRef<jobject>& event) { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); @@ -975,14 +953,14 @@ Java_ContentViewCore_onTouchDown(env, obj, event); } -void ContentViewCoreImpl::SetAllowJavascriptInterfacesInspection( +void ContentViewCore::SetAllowJavascriptInterfacesInspection( JNIEnv* env, const JavaParamRef<jobject>& obj, jboolean allow) { java_bridge_dispatcher_host_->SetAllowObjectContentsInspection(allow); } -void ContentViewCoreImpl::AddJavascriptInterface( +void ContentViewCore::AddJavascriptInterface( JNIEnv* env, const JavaParamRef<jobject>& /* obj */, const JavaParamRef<jobject>& object, @@ -992,7 +970,7 @@ ConvertJavaStringToUTF8(env, name), object, safe_annotation_clazz); } -void ContentViewCoreImpl::RemoveJavascriptInterface( +void ContentViewCore::RemoveJavascriptInterface( JNIEnv* env, const JavaParamRef<jobject>& /* obj */, const JavaParamRef<jstring>& name) { @@ -1000,12 +978,12 @@ ConvertJavaStringToUTF8(env, name)); } -void ContentViewCoreImpl::WasResized(JNIEnv* env, - const JavaParamRef<jobject>& obj) { +void ContentViewCore::WasResized(JNIEnv* env, + const JavaParamRef<jobject>& obj) { SendScreenRectsAndResizeWidget(); } -void ContentViewCoreImpl::SetTextTrackSettings( +void ContentViewCore::SetTextTrackSettings( JNIEnv* env, const JavaParamRef<jobject>& obj, jboolean textTracksEnabled, @@ -1018,24 +996,23 @@ const JavaParamRef<jstring>& textTrackTextSize) { FrameMsg_TextTrackSettings_Params params; params.text_tracks_enabled = textTracksEnabled; - params.text_track_background_color = ConvertJavaStringToUTF8( - env, textTrackBackgroundColor); - params.text_track_font_family = ConvertJavaStringToUTF8( - env, textTrackFontFamily); - params.text_track_font_style = ConvertJavaStringToUTF8( - env, textTrackFontStyle); - params.text_track_font_variant = ConvertJavaStringToUTF8( - env, textTrackFontVariant); - params.text_track_text_color = ConvertJavaStringToUTF8( - env, textTrackTextColor); - params.text_track_text_shadow = ConvertJavaStringToUTF8( - env, textTrackTextShadow); - params.text_track_text_size = ConvertJavaStringToUTF8( - env, textTrackTextSize); + params.text_track_background_color = + ConvertJavaStringToUTF8(env, textTrackBackgroundColor); + params.text_track_font_family = + ConvertJavaStringToUTF8(env, textTrackFontFamily); + params.text_track_font_style = + ConvertJavaStringToUTF8(env, textTrackFontStyle); + params.text_track_font_variant = + ConvertJavaStringToUTF8(env, textTrackFontVariant); + params.text_track_text_color = + ConvertJavaStringToUTF8(env, textTrackTextColor); + params.text_track_text_shadow = + ConvertJavaStringToUTF8(env, textTrackTextShadow); + params.text_track_text_size = ConvertJavaStringToUTF8(env, textTrackTextSize); web_contents_->GetMainFrame()->SetTextTrackSettings(params); } -bool ContentViewCoreImpl::IsFullscreenRequiredForOrientationLock() const { +bool ContentViewCore::IsFullscreenRequiredForOrientationLock() const { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); if (obj.is_null()) @@ -1043,7 +1020,7 @@ return Java_ContentViewCore_isFullscreenRequiredForOrientationLock(env, obj); } -void ContentViewCoreImpl::SendOrientationChangeEventInternal() { +void ContentViewCore::SendOrientationChangeEventInternal() { RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); if (rwhv) rwhv->UpdateScreenInfo(GetViewAndroid()); @@ -1051,16 +1028,16 @@ static_cast<WebContentsImpl*>(web_contents())->OnScreenOrientationChange(); } -jint ContentViewCoreImpl::GetCurrentRenderProcessId( +jint ContentViewCore::GetCurrentRenderProcessId( JNIEnv* env, const JavaParamRef<jobject>& obj) { return GetRenderProcessIdFromRenderViewHost( web_contents_->GetRenderViewHost()); } -void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, - const JavaParamRef<jobject>& jobj, - jboolean opaque) { +void ContentViewCore::SetBackgroundOpaque(JNIEnv* env, + const JavaParamRef<jobject>& jobj, + jboolean opaque) { if (GetRenderWidgetHostViewAndroid()) { if (opaque) GetRenderWidgetHostViewAndroid()->SetBackgroundColorToDefault(); @@ -1069,7 +1046,7 @@ } } -void ContentViewCoreImpl::HidePopupsAndPreserveSelection() { +void ContentViewCore::HidePopupsAndPreserveSelection() { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); if (obj.is_null()) @@ -1078,7 +1055,7 @@ Java_ContentViewCore_hidePopupsAndPreserveSelection(env, obj); } -void ContentViewCoreImpl::WebContentsDestroyed() { +void ContentViewCore::WebContentsDestroyed() { WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( static_cast<WebContentsImpl*>(web_contents())->GetView()); DCHECK(wcva); @@ -1095,19 +1072,19 @@ const JavaParamRef<jobject>& retained_objects_set) { WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( WebContents::FromJavaWebContents(jweb_contents)); - CHECK(web_contents) << - "A ContentViewCoreImpl should be created with a valid WebContents."; + CHECK(web_contents) + << "A ContentViewCore should be created with a valid WebContents."; ui::ViewAndroid* view_android = web_contents->GetView()->GetNativeView(); view_android->SetDelegate(jview_android_delegate); view_android->SetLayout(ui::ViewAndroid::LayoutParams::MatchParent()); ui::WindowAndroid* window_android = - reinterpret_cast<ui::WindowAndroid*>(jwindow_android); + reinterpret_cast<ui::WindowAndroid*>(jwindow_android); DCHECK(window_android); window_android->AddChild(view_android); - ContentViewCoreImpl* view = new ContentViewCoreImpl( - env, obj, web_contents, dip_scale, retained_objects_set); + ContentViewCore* view = new ContentViewCore(env, obj, web_contents, dip_scale, + retained_objects_set); return reinterpret_cast<intptr_t>(view); }
diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core.h similarity index 90% rename from content/browser/android/content_view_core_impl.h rename to content/browser/android/content_view_core.h index 48c93b1..43d7ea05 100644 --- a/content/browser/android/content_view_core_impl.h +++ b/content/browser/android/content_view_core.h
@@ -1,9 +1,9 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. +// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ -#define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ +#ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_ +#define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_ #include <stdint.h> @@ -17,10 +17,9 @@ #include "base/i18n/rtl.h" #include "base/macros.h" #include "base/process/process.h" -#include "content/browser/android/content_view_core_impl_observer.h" +#include "content/browser/android/content_view_core_observer.h" #include "content/browser/renderer_host/render_widget_host_view_android.h" #include "content/browser/web_contents/web_contents_impl.h" -#include "content/public/browser/android/content_view_core.h" #include "content/public/browser/web_contents_observer.h" #include "third_party/WebKit/public/platform/WebInputEvent.h" #include "ui/android/view_android.h" @@ -40,24 +39,22 @@ class RenderWidgetHostViewAndroid; struct MenuItem; -class ContentViewCoreImpl : public ContentViewCore, - public WebContentsObserver { +class ContentViewCore : public WebContentsObserver { public: - static ContentViewCoreImpl* FromWebContents(WebContents* web_contents); - ContentViewCoreImpl( + static ContentViewCore* FromWebContents(WebContents* web_contents); + ContentViewCore( JNIEnv* env, const base::android::JavaRef<jobject>& obj, WebContents* web_contents, float dpi_scale, const base::android::JavaRef<jobject>& java_bridge_retained_object_set); - // ContentViewCore implementation. - base::android::ScopedJavaLocalRef<jobject> GetJavaObject() override; - WebContents* GetWebContents() const override; - ui::WindowAndroid* GetWindowAndroid() const override; + base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); + WebContents* GetWebContents() const; + ui::WindowAndroid* GetWindowAndroid() const; - void AddObserver(ContentViewCoreImplObserver* observer); - void RemoveObserver(ContentViewCoreImplObserver* observer); + void AddObserver(ContentViewCoreObserver* observer); + void RemoveObserver(ContentViewCoreObserver* observer); // -------------------------------------------------------------------------- // Methods called from Java via JNI @@ -243,7 +240,7 @@ const gfx::Vector2dF& page_scale_factor_limits, const gfx::SizeF& content_size, const gfx::SizeF& viewport_size, - const float content_offset, + const float top_content_offset, const float top_shown_pix, bool top_changed, bool is_mobile_optimized_hint); @@ -257,8 +254,8 @@ // Shows the disambiguation popup // |rect_pixels| --> window coordinates which |zoomed_bitmap| represents // |zoomed_bitmap| --> magnified image of potential touch targets - void ShowDisambiguationPopup( - const gfx::Rect& rect_pixels, const SkBitmap& zoomed_bitmap); + void ShowDisambiguationPopup(const gfx::Rect& rect_pixels, + const SkBitmap& zoomed_bitmap); // Creates a java-side touch event, used for injecting motion events for // testing/benchmarking purposes. @@ -297,7 +294,7 @@ class ContentViewUserData; friend class ContentViewUserData; - ~ContentViewCoreImpl() override; + ~ContentViewCore() override; // WebContentsObserver implementation. void RenderViewReady() override; @@ -347,7 +344,7 @@ float dpi_scale_; // Observer to notify of lifecyle changes. - base::ObserverList<ContentViewCoreImplObserver> observer_list_; + base::ObserverList<ContentViewCoreObserver> observer_list_; // The cache of device's current orientation set from Java side, this value // will be sent to Renderer once it is ready. @@ -356,11 +353,11 @@ // Manages injecting Java objects. scoped_refptr<GinJavaBridgeDispatcherHost> java_bridge_dispatcher_host_; - DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl); + DISALLOW_COPY_AND_ASSIGN(ContentViewCore); }; bool RegisterContentViewCore(JNIEnv* env); } // namespace content -#endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ +#endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_
diff --git a/content/browser/android/content_view_core_impl_observer.h b/content/browser/android/content_view_core_impl_observer.h deleted file mode 100644 index d27735e..0000000 --- a/content/browser/android/content_view_core_impl_observer.h +++ /dev/null
@@ -1,22 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_OBSERVER_H -#define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_OBSERVER_H - -namespace content { - -class ContentViewCoreImplObserver { - public: - virtual void OnContentViewCoreDestroyed() = 0; - virtual void OnAttachedToWindow() = 0; - virtual void OnDetachedFromWindow() = 0; - - protected: - virtual ~ContentViewCoreImplObserver() {} -}; - -} // namespace content - -#endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_OBSERVER_H
diff --git a/content/browser/android/content_view_core_observer.h b/content/browser/android/content_view_core_observer.h new file mode 100644 index 0000000..396618a --- /dev/null +++ b/content/browser/android/content_view_core_observer.h
@@ -0,0 +1,22 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_OBSERVER_H +#define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_OBSERVER_H + +namespace content { + +class ContentViewCoreObserver { + public: + virtual void OnContentViewCoreDestroyed() = 0; + virtual void OnAttachedToWindow() = 0; + virtual void OnDetachedFromWindow() = 0; + + protected: + virtual ~ContentViewCoreObserver() {} +}; + +} // namespace content + +#endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_OBSERVER_H
diff --git a/content/browser/android/dialog_overlay_impl.cc b/content/browser/android/dialog_overlay_impl.cc index 5be3327..5e36140 100644 --- a/content/browser/android/dialog_overlay_impl.cc +++ b/content/browser/android/dialog_overlay_impl.cc
@@ -40,8 +40,7 @@ if (!rfhi->IsCurrent() || web_contents_impl->IsHidden()) return 0; - ContentViewCoreImpl* cvc = - content::ContentViewCoreImpl::FromWebContents(web_contents_impl); + ContentViewCore* cvc = ContentViewCore::FromWebContents(web_contents_impl); if (!cvc) return 0; @@ -53,7 +52,7 @@ DialogOverlayImpl::DialogOverlayImpl(const JavaParamRef<jobject>& obj, RenderFrameHostImpl* rfhi, WebContents* web_contents, - ContentViewCoreImpl* cvc) + ContentViewCore* cvc) : WebContentsObserver(web_contents), rfhi_(rfhi), cvc_(cvc) { DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(rfhi_);
diff --git a/content/browser/android/dialog_overlay_impl.h b/content/browser/android/dialog_overlay_impl.h index c5c328b2..c30707b 100644 --- a/content/browser/android/dialog_overlay_impl.h +++ b/content/browser/android/dialog_overlay_impl.h
@@ -9,8 +9,8 @@ #include "base/android/jni_weak_ref.h" #include "base/android/scoped_java_ref.h" #include "base/unguessable_token.h" -#include "content/browser/android/content_view_core_impl.h" -#include "content/browser/android/content_view_core_impl_observer.h" +#include "content/browser/android/content_view_core.h" +#include "content/browser/android/content_view_core_observer.h" #include "content/public/browser/web_contents_observer.h" namespace content { @@ -19,7 +19,7 @@ // java side. When the ContentViewCore for the provided token is attached or // detached from a WindowAndroid, we get the Android window token and notify the // java side. -class DialogOverlayImpl : public ContentViewCoreImplObserver, +class DialogOverlayImpl : public ContentViewCoreObserver, public WebContentsObserver { public: // Registers the JNI methods for DialogOverlayImpl. @@ -30,7 +30,7 @@ DialogOverlayImpl(const base::android::JavaParamRef<jobject>& obj, RenderFrameHostImpl* rfhi, WebContents* web_contents, - ContentViewCoreImpl* cvc); + ContentViewCore* cvc); ~DialogOverlayImpl() override; // Called when the java side is ready for token / dismissed callbacks. May @@ -48,7 +48,7 @@ const base::android::JavaParamRef<jobject>& obj, const base::android::JavaParamRef<jobject>& rect); - // ContentViewCoreImplObserver + // ContentViewCoreObserver void OnContentViewCoreDestroyed() override; void OnAttachedToWindow() override; void OnDetachedFromWindow() override; @@ -74,8 +74,8 @@ // RenderFrameHostImpl* associated with the given overlay routing token. RenderFrameHostImpl* rfhi_; - // ContentViewCoreImpl instance that we're registered with as an observer. - ContentViewCoreImpl* cvc_; + // ContentViewCore instance that we're registered with as an observer. + ContentViewCore* cvc_; }; } // namespace content
diff --git a/content/browser/media/android/browser_media_player_manager.cc b/content/browser/media/android/browser_media_player_manager.cc index d5128ec..f498c4c 100644 --- a/content/browser/media/android/browser_media_player_manager.cc +++ b/content/browser/media/android/browser_media_player_manager.cc
@@ -31,7 +31,7 @@ #include "media/base/media_content_type.h" #if !defined(USE_AURA) -#include "content/browser/android/content_view_core_impl.h" +#include "content/browser/android/content_view_core.h" #include "content/browser/renderer_host/render_widget_host_view_android.h" #endif @@ -79,7 +79,7 @@ #if !defined(USE_AURA) ContentViewCore* BrowserMediaPlayerManager::GetContentViewCore() const { - return ContentViewCoreImpl::FromWebContents(web_contents()); + return ContentViewCore::FromWebContents(web_contents()); } #endif
diff --git a/content/browser/media/android/browser_surface_view_manager.cc b/content/browser/media/android/browser_surface_view_manager.cc index dc854ee..2569903 100644 --- a/content/browser/media/android/browser_surface_view_manager.cc +++ b/content/browser/media/android/browser_surface_view_manager.cc
@@ -6,7 +6,7 @@ #include "base/android/build_info.h" #include "base/trace_event/trace_event.h" -#include "content/browser/android/content_view_core_impl.h" +#include "content/browser/android/content_view_core.h" #include "content/browser/gpu/gpu_process_host.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/common/media/surface_view_manager_messages_android.h"
diff --git a/content/browser/renderer_host/input/synthetic_gesture_target_android.cc b/content/browser/renderer_host/input/synthetic_gesture_target_android.cc index f9482534..c050922c 100644 --- a/content/browser/renderer_host/input/synthetic_gesture_target_android.cc +++ b/content/browser/renderer_host/input/synthetic_gesture_target_android.cc
@@ -4,7 +4,7 @@ #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h" -#include "content/browser/android/content_view_core_impl.h" +#include "content/browser/android/content_view_core.h" #include "content/browser/renderer_host/render_widget_host_impl.h" #include "jni/MotionEventSynthesizer_jni.h" #include "third_party/WebKit/public/platform/WebInputEvent.h"
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc index 0082320..1ee89dc 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.cc +++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -38,7 +38,7 @@ #include "content/browser/accessibility/browser_accessibility_manager_android.h" #include "content/browser/accessibility/web_contents_accessibility_android.h" #include "content/browser/android/composited_touch_handle_drawable.h" -#include "content/browser/android/content_view_core_impl.h" +#include "content/browser/android/content_view_core.h" #include "content/browser/android/ime_adapter_android.h" #include "content/browser/android/overscroll_controller_android.h" #include "content/browser/android/selection_popup_controller.h" @@ -443,7 +443,7 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( RenderWidgetHostImpl* widget_host, - ContentViewCoreImpl* content_view_core) + ContentViewCore* content_view_core) : host_(widget_host), begin_frame_source_(nullptr), outstanding_begin_frame_requests_(0), @@ -643,7 +643,7 @@ } bool RenderWidgetHostViewAndroid::IsShowing() { - // ContentViewCoreImpl represents the native side of the Java + // ContentViewCore represents the native side of the Java // ContentViewCore. It being NULL means that it is not attached // to the View system yet, so we treat this RWHVA as hidden. return is_showing_ && content_view_core_; @@ -2045,7 +2045,7 @@ } void RenderWidgetHostViewAndroid::SetContentViewCore( - ContentViewCoreImpl* content_view_core) { + ContentViewCore* content_view_core) { DCHECK(!content_view_core || !content_view_core_ || (content_view_core_ == content_view_core)); StopObservingRootWindow();
diff --git a/content/browser/renderer_host/render_widget_host_view_android.h b/content/browser/renderer_host/render_widget_host_view_android.h index 6df01af9..b0321f94 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.h +++ b/content/browser/renderer_host/render_widget_host_view_android.h
@@ -22,7 +22,7 @@ #include "cc/output/begin_frame_args.h" #include "cc/scheduler/begin_frame_source.h" #include "components/viz/service/frame_sinks/frame_evictor.h" -#include "content/browser/android/content_view_core_impl_observer.h" +#include "content/browser/android/content_view_core_observer.h" #include "content/browser/renderer_host/input/mouse_wheel_phase_handler.h" #include "content/browser/renderer_host/input/stylus_text_selector.h" #include "content/browser/renderer_host/render_widget_host_view_base.h" @@ -48,7 +48,7 @@ } namespace content { -class ContentViewCoreImpl; +class ContentViewCore; class ImeAdapterAndroid; class OverscrollControllerAndroid; class RenderWidgetHost; @@ -72,13 +72,13 @@ public viz::FrameEvictorClient, public StylusTextSelectorClient, public ui::TouchSelectionControllerClient, - public content::ContentViewCoreImplObserver, + public content::ContentViewCoreObserver, public content::TextInputManager::Observer, public ui::DelegatedFrameHostAndroid::Client, public cc::BeginFrameObserver { public: RenderWidgetHostViewAndroid(RenderWidgetHostImpl* widget, - ContentViewCoreImpl* content_view_core); + ContentViewCore* content_view_core); ~RenderWidgetHostViewAndroid() override; void Blur(); @@ -208,7 +208,7 @@ void OnActivityStopped() override; void OnActivityStarted() override; - // content::ContentViewCoreImplObserver implementation. + // content::ContentViewCoreObserver implementation. void OnContentViewCoreDestroyed() override; void OnAttachedToWindow() override; void OnDetachedFromWindow() override; @@ -244,7 +244,7 @@ void OnBeginFrameSourcePausedChanged(bool paused) override; // Non-virtual methods - void SetContentViewCore(ContentViewCoreImpl* content_view_core); + void SetContentViewCore(ContentViewCore* content_view_core); SkColor GetCachedBackgroundColor() const; void SendKeyEvent(const NativeWebKeyboardEvent& event); void SendMouseEvent(const ui::MotionEventAndroid&, int action_button); @@ -389,8 +389,8 @@ // appearance of overscroll glow and the keyboard. bool is_in_vr_; - // ContentViewCoreImpl is our interface to the view system. - ContentViewCoreImpl* content_view_core_; + // ContentViewCore is our interface to the view system. + ContentViewCore* content_view_core_; ImeAdapterAndroid* ime_adapter_android_; SelectionPopupController* selection_popup_controller_;
diff --git a/content/browser/screen_orientation/screen_orientation_delegate_android.cc b/content/browser/screen_orientation/screen_orientation_delegate_android.cc index 6a95d7db..ebd1f94 100644 --- a/content/browser/screen_orientation/screen_orientation_delegate_android.cc +++ b/content/browser/screen_orientation/screen_orientation_delegate_android.cc
@@ -4,7 +4,7 @@ #include "content/browser/screen_orientation/screen_orientation_delegate_android.h" -#include "content/browser/android/content_view_core_impl.h" +#include "content/browser/android/content_view_core.h" #include "content/browser/screen_orientation/screen_orientation_provider.h" #include "jni/ScreenOrientationProvider_jni.h" #include "ui/android/window_android.h" @@ -22,8 +22,7 @@ bool ScreenOrientationDelegateAndroid::FullScreenRequired( WebContents* web_contents) { - ContentViewCoreImpl* cvc = - ContentViewCoreImpl::FromWebContents(web_contents); + ContentViewCore* cvc = ContentViewCore::FromWebContents(web_contents); bool fullscreen_required = cvc ? cvc->IsFullscreenRequiredForOrientationLock() : true; return fullscreen_required;
diff --git a/content/browser/web_contents/web_contents_android.cc b/content/browser/web_contents/web_contents_android.cc index 52df13b..193df403 100644 --- a/content/browser/web_contents/web_contents_android.cc +++ b/content/browser/web_contents/web_contents_android.cc
@@ -17,7 +17,7 @@ #include "base/memory/ptr_util.h" #include "content/browser/accessibility/browser_accessibility_android.h" #include "content/browser/accessibility/browser_accessibility_manager_android.h" -#include "content/browser/android/content_view_core_impl.h" +#include "content/browser/android/content_view_core.h" #include "content/browser/android/interstitial_page_delegate_android.h" #include "content/browser/frame_host/interstitial_page_impl.h" #include "content/browser/media/android/browser_media_player_manager.h"
diff --git a/content/browser/web_contents/web_contents_view_android.cc b/content/browser/web_contents/web_contents_view_android.cc index a300da52..b0b1349 100644 --- a/content/browser/web_contents/web_contents_view_android.cc +++ b/content/browser/web_contents/web_contents_view_android.cc
@@ -9,7 +9,7 @@ #include "base/logging.h" #include "cc/layers/layer.h" #include "content/browser/accessibility/browser_accessibility_manager_android.h" -#include "content/browser/android/content_view_core_impl.h" +#include "content/browser/android/content_view_core.h" #include "content/browser/frame_host/interstitial_page_impl.h" #include "content/browser/renderer_host/render_view_host_factory.h" #include "content/browser/renderer_host/render_view_host_impl.h" @@ -98,7 +98,7 @@ } void WebContentsViewAndroid::SetContentViewCore( - ContentViewCoreImpl* content_view_core) { + ContentViewCore* content_view_core) { content_view_core_ = content_view_core; RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); if (rwhv)
diff --git a/content/browser/web_contents/web_contents_view_android.h b/content/browser/web_contents/web_contents_view_android.h index 205d2a54..d60ceaf 100644 --- a/content/browser/web_contents/web_contents_view_android.h +++ b/content/browser/web_contents/web_contents_view_android.h
@@ -19,7 +19,7 @@ #include "ui/gfx/geometry/rect_f.h" namespace content { -class ContentViewCoreImpl; +class ContentViewCore; class RenderWidgetHostViewAndroid; class SynchronousCompositorClient; class WebContentsImpl; @@ -33,10 +33,10 @@ WebContentsViewDelegate* delegate); ~WebContentsViewAndroid() override; - // Sets the interface to the view system. ContentViewCoreImpl is owned + // Sets the interface to the view system. ContentViewCore is owned // by its Java ContentViewCore counterpart, whose lifetime is managed // by the UI frontend. - void SetContentViewCore(ContentViewCoreImpl* content_view_core); + void SetContentViewCore(ContentViewCore* content_view_core); void set_synchronous_compositor_client(SynchronousCompositorClient* client) { synchronous_compositor_client_ = client; @@ -121,8 +121,8 @@ // The WebContents whose contents we display. WebContentsImpl* web_contents_; - // ContentViewCoreImpl is our interface to the view system. - ContentViewCoreImpl* content_view_core_; + // ContentViewCore is our interface to the view system. + ContentViewCore* content_view_core_; // Handles "overscroll to refresh" events std::unique_ptr<ui::OverscrollRefreshHandler> overscroll_refresh_handler_;
diff --git a/content/public/android/BUILD.gn b/content/public/android/BUILD.gn index 90520e2..105a27f 100644 --- a/content/public/android/BUILD.gn +++ b/content/public/android/BUILD.gn
@@ -293,7 +293,7 @@ java_cpp_enum("content_public_android_java_enums_srcjar") { sources = [ - "//content/browser/android/content_view_core_impl.cc", + "//content/browser/android/content_view_core.cc", "//content/browser/android/gesture_event_type.h", "//content/public/browser/download_item.h", "//content/public/browser/invalidate_type.h",
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java index 8b32c13..2b5d847 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -204,7 +204,7 @@ private WebContents mWebContents; private WebContentsObserver mWebContentsObserver; - // Native pointer to C++ ContentViewCoreImpl object which will be set by nativeInit(). + // Native pointer to C++ ContentViewCore object which will be set by nativeInit(). private long mNativeContentViewCore; private boolean mAttachedToWindow; @@ -274,7 +274,7 @@ /** * PID used to indicate an invalid render process. */ - // Keep in sync with the value returned from ContentViewCoreImpl::GetCurrentRendererProcessId() + // Keep in sync with the value returned from ContentViewCore::GetCurrentRendererProcessId() // if there is no render process. public static final int INVALID_RENDER_PROCESS_PID = 0; @@ -2225,79 +2225,75 @@ private static native ContentViewCore nativeFromWebContentsAndroid(WebContents webContents); private native void nativeUpdateWindowAndroid( - long nativeContentViewCoreImpl, long windowAndroidPtr); - private native WebContents nativeGetWebContentsAndroid(long nativeContentViewCoreImpl); - private native WindowAndroid nativeGetJavaWindowAndroid(long nativeContentViewCoreImpl); + long nativeContentViewCore, long windowAndroidPtr); + private native WebContents nativeGetWebContentsAndroid(long nativeContentViewCore); + private native WindowAndroid nativeGetJavaWindowAndroid(long nativeContentViewCore); - private native void nativeOnJavaContentViewCoreDestroyed(long nativeContentViewCoreImpl); + private native void nativeOnJavaContentViewCoreDestroyed(long nativeContentViewCore); - private native void nativeSetFocus(long nativeContentViewCoreImpl, boolean focused); + private native void nativeSetFocus(long nativeContentViewCore, boolean focused); - private native void nativeSetDIPScale(long nativeContentViewCoreImpl, float dipScale); + private native void nativeSetDIPScale(long nativeContentViewCore, float dipScale); private native void nativeSendOrientationChangeEvent( - long nativeContentViewCoreImpl, int orientation); + long nativeContentViewCore, int orientation); - private native void nativeScrollBegin(long nativeContentViewCoreImpl, long timeMs, float x, - float y, float hintX, float hintY, boolean targetViewport, boolean fromGamepad); + private native void nativeScrollBegin(long nativeContentViewCore, long timeMs, float x, float y, + float hintX, float hintY, boolean targetViewport, boolean fromGamepad); - private native void nativeScrollEnd(long nativeContentViewCoreImpl, long timeMs); + private native void nativeScrollEnd(long nativeContentViewCore, long timeMs); private native void nativeScrollBy( - long nativeContentViewCoreImpl, long timeMs, float x, float y, - float deltaX, float deltaY); + long nativeContentViewCore, long timeMs, float x, float y, float deltaX, float deltaY); - private native void nativeFlingStart(long nativeContentViewCoreImpl, long timeMs, float x, - float y, float vx, float vy, boolean targetViewport, boolean fromGamepad); + private native void nativeFlingStart(long nativeContentViewCore, long timeMs, float x, float y, + float vx, float vy, boolean targetViewport, boolean fromGamepad); private native void nativeFlingCancel( - long nativeContentViewCoreImpl, long timeMs, boolean fromGamepad); + long nativeContentViewCore, long timeMs, boolean fromGamepad); - private native void nativeDoubleTap( - long nativeContentViewCoreImpl, long timeMs, float x, float y); + private native void nativeDoubleTap(long nativeContentViewCore, long timeMs, float x, float y); private native void nativeResolveTapDisambiguation( - long nativeContentViewCoreImpl, long timeMs, float x, float y, boolean isLongPress); + long nativeContentViewCore, long timeMs, float x, float y, boolean isLongPress); - private native void nativePinchBegin( - long nativeContentViewCoreImpl, long timeMs, float x, float y); + private native void nativePinchBegin(long nativeContentViewCore, long timeMs, float x, float y); - private native void nativePinchEnd(long nativeContentViewCoreImpl, long timeMs); + private native void nativePinchEnd(long nativeContentViewCore, long timeMs); - private native void nativePinchBy(long nativeContentViewCoreImpl, long timeMs, - float anchorX, float anchorY, float deltaScale); + private native void nativePinchBy(long nativeContentViewCore, long timeMs, float anchorX, + float anchorY, float deltaScale); private native void nativeSetTextHandlesTemporarilyHidden( - long nativeContentViewCoreImpl, boolean hidden); + long nativeContentViewCore, boolean hidden); - private native void nativeResetGestureDetection(long nativeContentViewCoreImpl); + private native void nativeResetGestureDetection(long nativeContentViewCore); private native void nativeSetDoubleTapSupportEnabled( - long nativeContentViewCoreImpl, boolean enabled); + long nativeContentViewCore, boolean enabled); private native void nativeSetMultiTouchZoomSupportEnabled( - long nativeContentViewCoreImpl, boolean enabled); + long nativeContentViewCore, boolean enabled); - private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImpl, - long nativeSelectPopupSourceFrame, int[] indices); + private native void nativeSelectPopupMenuItems( + long nativeContentViewCore, long nativeSelectPopupSourceFrame, int[] indices); - private native int nativeGetCurrentRenderProcessId(long nativeContentViewCoreImpl); + private native int nativeGetCurrentRenderProcessId(long nativeContentViewCore); private native void nativeSetAllowJavascriptInterfacesInspection( - long nativeContentViewCoreImpl, boolean allow); + long nativeContentViewCore, boolean allow); - private native void nativeAddJavascriptInterface(long nativeContentViewCoreImpl, Object object, - String name, Class requiredAnnotation); + private native void nativeAddJavascriptInterface( + long nativeContentViewCore, Object object, String name, Class requiredAnnotation); - private native void nativeRemoveJavascriptInterface(long nativeContentViewCoreImpl, - String name); + private native void nativeRemoveJavascriptInterface(long nativeContentViewCore, String name); - private native void nativeWasResized(long nativeContentViewCoreImpl); + private native void nativeWasResized(long nativeContentViewCore); - private native void nativeSetTextTrackSettings(long nativeContentViewCoreImpl, + private native void nativeSetTextTrackSettings(long nativeContentViewCore, boolean textTracksEnabled, String textTrackBackgroundColor, String textTrackFontFamily, String textTrackFontStyle, String textTrackFontVariant, String textTrackTextColor, String textTrackTextShadow, String textTrackTextSize); - private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl, boolean opaque); + private native void nativeSetBackgroundOpaque(long nativeContentViewCore, boolean opaque); }
diff --git a/content/public/browser/BUILD.gn b/content/public/browser/BUILD.gn index c5467c7..4c837937 100644 --- a/content/public/browser/BUILD.gn +++ b/content/public/browser/BUILD.gn
@@ -28,7 +28,6 @@ "android/compositor.h", "android/compositor_client.h", "android/content_protocol_handler.h", - "android/content_view_core.h", "android/content_view_layer_renderer.h", "android/devtools_auth.h", "android/java_interfaces.h",
diff --git a/content/public/browser/android/content_view_core.h b/content/public/browser/android/content_view_core.h deleted file mode 100644 index a032485..0000000 --- a/content/public/browser/android/content_view_core.h +++ /dev/null
@@ -1,46 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_PUBLIC_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_ -#define CONTENT_PUBLIC_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_ - -#include <jni.h> - -#include "base/android/scoped_java_ref.h" -#include "base/callback.h" -#include "base/strings/string16.h" -#include "content/common/content_export.h" -#include "content/public/browser/readback_types.h" -#include "ui/android/view_android.h" -#include "ui/gfx/geometry/rect.h" - -namespace ui { -class WindowAndroid; -} - -namespace content { - -class WebContents; - -// DEPRECATED. Do not add methods. -// Refer to the public WebContents interface or elsewhere instead. -class CONTENT_EXPORT ContentViewCore { - public: - // Returns the existing ContentViewCore for |web_contents|, or nullptr. - static ContentViewCore* FromWebContents(WebContents* web_contents); - - virtual WebContents* GetWebContents() const = 0; - - // May return null reference. - virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0; - - virtual ui::WindowAndroid* GetWindowAndroid() const = 0; - - protected: - ~ContentViewCore() {} -}; - -}; // namespace content - -#endif // CONTENT_PUBLIC_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_