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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2060933002: Let Flash join and be controlled by media session (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pepper_to_contents
Patch Set: addressed dcheng's comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/common/frame_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/feature_list.h"
13 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
14 #include "base/location.h" 15 #include "base/location.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
18 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
19 #include "base/process/process.h" 20 #include "base/process/process.h"
20 #include "base/profiler/scoped_tracker.h" 21 #include "base/profiler/scoped_tracker.h"
21 #include "base/single_thread_task_runner.h" 22 #include "base/single_thread_task_runner.h"
22 #include "base/strings/string16.h" 23 #include "base/strings/string16.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 #if defined(OS_MACOSX) 139 #if defined(OS_MACOSX)
139 #include "base/mac/foundation_util.h" 140 #include "base/mac/foundation_util.h"
140 #endif 141 #endif
141 142
142 #if defined(MOJO_SHELL_CLIENT) 143 #if defined(MOJO_SHELL_CLIENT)
143 #include "content/browser/web_contents/web_contents_view_mus.h" 144 #include "content/browser/web_contents/web_contents_view_mus.h"
144 #include "content/public/common/mojo_shell_connection.h" 145 #include "content/public/common/mojo_shell_connection.h"
145 #include "ui/aura/mus/mus_util.h" 146 #include "ui/aura/mus/mus_util.h"
146 #endif 147 #endif
147 148
149 #if defined(ENABLE_PLUGINS)
150 #include "content/browser/media/session/pepper_playback_observer.h"
151 #endif // ENABLE_PLUGINS
152
148 namespace content { 153 namespace content {
149 namespace { 154 namespace {
150 155
151 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; 156 const int kMinimumDelayBetweenLoadingUpdatesMS = 100;
152 const char kDotGoogleDotCom[] = ".google.com"; 157 const char kDotGoogleDotCom[] = ".google.com";
153 158
154 #if defined(OS_ANDROID) 159 #if defined(OS_ANDROID)
155 const char kWebContentsAndroidKey[] = "web_contents_android"; 160 const char kWebContentsAndroidKey[] = "web_contents_android";
156 #endif // OS_ANDROID 161 #endif // OS_ANDROID
157 162
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 loading_weak_factory_(this), 427 loading_weak_factory_(this),
423 weak_factory_(this) { 428 weak_factory_(this) {
424 frame_tree_.SetFrameRemoveListener( 429 frame_tree_.SetFrameRemoveListener(
425 base::Bind(&WebContentsImpl::OnFrameRemoved, 430 base::Bind(&WebContentsImpl::OnFrameRemoved,
426 base::Unretained(this))); 431 base::Unretained(this)));
427 #if defined(OS_ANDROID) 432 #if defined(OS_ANDROID)
428 media_web_contents_observer_.reset(new MediaWebContentsObserverAndroid(this)); 433 media_web_contents_observer_.reset(new MediaWebContentsObserverAndroid(this));
429 #else 434 #else
430 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); 435 media_web_contents_observer_.reset(new MediaWebContentsObserver(this));
431 #endif 436 #endif
437 #if defined (ENABLE_PLUGINS)
438 pepper_playback_observer_.reset(new PepperPlaybackObserver(this));
439 #endif
432 loader_io_thread_notifier_.reset(new LoaderIOThreadNotifier(this)); 440 loader_io_thread_notifier_.reset(new LoaderIOThreadNotifier(this));
433 wake_lock_service_context_.reset(new WakeLockServiceContext(this)); 441 wake_lock_service_context_.reset(new WakeLockServiceContext(this));
434 } 442 }
435 443
436 WebContentsImpl::~WebContentsImpl() { 444 WebContentsImpl::~WebContentsImpl() {
437 is_being_destroyed_ = true; 445 is_being_destroyed_ = true;
438 446
439 rwh_input_event_router_.reset(); 447 rwh_input_event_router_.reset();
440 448
441 for (FrameTreeNode* node : frame_tree_.Nodes()) { 449 for (FrameTreeNode* node : frame_tree_.Nodes()) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 if (IsBrowserSideNavigationEnabled()) { 496 if (IsBrowserSideNavigationEnabled()) {
489 // Do not update state as the WebContents is being destroyed. 497 // Do not update state as the WebContents is being destroyed.
490 frame_tree_.root()->ResetNavigationRequest(true); 498 frame_tree_.root()->ResetNavigationRequest(true);
491 if (root->speculative_frame_host()) { 499 if (root->speculative_frame_host()) {
492 root->speculative_frame_host()->SetRenderFrameCreated(false); 500 root->speculative_frame_host()->SetRenderFrameCreated(false);
493 root->speculative_frame_host()->SetNavigationHandle( 501 root->speculative_frame_host()->SetNavigationHandle(
494 std::unique_ptr<NavigationHandleImpl>()); 502 std::unique_ptr<NavigationHandleImpl>());
495 } 503 }
496 } 504 }
497 505
506 #if defined(ENABLE_PLUGINS)
507 // Call this before WebContentsDestroyed() is broadcasted since
508 // AudioFocusManager will be destroyed after that.
509 pepper_playback_observer_.reset();
510 #endif // defined(ENABLED_PLUGINS)
511
498 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 512 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
499 FrameDeleted(root->current_frame_host())); 513 FrameDeleted(root->current_frame_host()));
500 514
501 if (root->pending_render_view_host()) { 515 if (root->pending_render_view_host()) {
502 FOR_EACH_OBSERVER(WebContentsObserver, 516 FOR_EACH_OBSERVER(WebContentsObserver,
503 observers_, 517 observers_,
504 RenderViewDeleted(root->pending_render_view_host())); 518 RenderViewDeleted(root->pending_render_view_host()));
505 } 519 }
506 520
507 FOR_EACH_OBSERVER(WebContentsObserver, 521 FOR_EACH_OBSERVER(WebContentsObserver,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 OnUpdatePageImportanceSignals) 697 OnUpdatePageImportanceSignals)
684 IPC_MESSAGE_HANDLER(FrameHostMsg_Find_Reply, OnFindReply) 698 IPC_MESSAGE_HANDLER(FrameHostMsg_Find_Reply, OnFindReply)
685 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) 699 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed)
686 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) 700 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend)
687 #if defined(ENABLE_PLUGINS) 701 #if defined(ENABLE_PLUGINS)
688 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceCreated, 702 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceCreated,
689 OnPepperInstanceCreated) 703 OnPepperInstanceCreated)
690 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted, 704 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted,
691 OnPepperInstanceDeleted) 705 OnPepperInstanceDeleted)
692 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) 706 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung)
707 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStartsPlayback,
708 OnPepperStartsPlayback)
709 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStopsPlayback,
710 OnPepperStopsPlayback)
693 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) 711 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed)
694 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, 712 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission,
695 OnRequestPpapiBrokerPermission) 713 OnRequestPpapiBrokerPermission)
696 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, 714 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach,
697 OnBrowserPluginMessage(render_frame_host, 715 OnBrowserPluginMessage(render_frame_host,
698 message)) 716 message))
699 #endif 717 #endif
700 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) 718 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL)
701 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, 719 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage,
702 OnShowValidationMessage) 720 OnShowValidationMessage)
(...skipping 2995 matching lines...) Expand 10 before | Expand all | Expand 10 after
3698 // This exists for render views that don't have a WebUI, but do have WebUI 3716 // This exists for render views that don't have a WebUI, but do have WebUI
3699 // bindings enabled. 3717 // bindings enabled.
3700 void WebContentsImpl::OnWebUISend(const GURL& source_url, 3718 void WebContentsImpl::OnWebUISend(const GURL& source_url,
3701 const std::string& name, 3719 const std::string& name,
3702 const base::ListValue& args) { 3720 const base::ListValue& args) {
3703 if (delegate_) 3721 if (delegate_)
3704 delegate_->WebUISend(this, source_url, name, args); 3722 delegate_->WebUISend(this, source_url, name, args);
3705 } 3723 }
3706 3724
3707 #if defined(ENABLE_PLUGINS) 3725 #if defined(ENABLE_PLUGINS)
3708 void WebContentsImpl::OnPepperInstanceCreated() { 3726 void WebContentsImpl::OnPepperInstanceCreated(int32_t pp_instance) {
3709 FOR_EACH_OBSERVER(WebContentsObserver, observers_, PepperInstanceCreated()); 3727 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3728 PepperInstanceCreated());
3729 pepper_playback_observer_->PepperInstanceCreated(pp_instance);
3710 } 3730 }
3711 3731
3712 void WebContentsImpl::OnPepperInstanceDeleted() { 3732 void WebContentsImpl::OnPepperInstanceDeleted(int32_t pp_instance) {
3713 FOR_EACH_OBSERVER(WebContentsObserver, observers_, PepperInstanceDeleted()); 3733 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3734 PepperInstanceDeleted());
3735 pepper_playback_observer_->PepperInstanceDeleted(pp_instance);
3714 } 3736 }
3715 3737
3716 void WebContentsImpl::OnPepperPluginHung(int plugin_child_id, 3738 void WebContentsImpl::OnPepperPluginHung(int plugin_child_id,
3717 const base::FilePath& path, 3739 const base::FilePath& path,
3718 bool is_hung) { 3740 bool is_hung) {
3719 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1); 3741 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1);
3720 3742
3721 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3743 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3722 PluginHungStatusChanged(plugin_child_id, path, is_hung)); 3744 PluginHungStatusChanged(plugin_child_id, path, is_hung));
3723 } 3745 }
3724 3746
3747 void WebContentsImpl::OnPepperStartsPlayback(int32_t pp_instance) {
3748 pepper_playback_observer_->PepperStartsPlayback(pp_instance);
3749 }
3750
3751 void WebContentsImpl::OnPepperStopsPlayback(int32_t pp_instance) {
3752 pepper_playback_observer_->PepperStopsPlayback(pp_instance);
3753 }
3754
3725 void WebContentsImpl::OnPluginCrashed(const base::FilePath& plugin_path, 3755 void WebContentsImpl::OnPluginCrashed(const base::FilePath& plugin_path,
3726 base::ProcessId plugin_pid) { 3756 base::ProcessId plugin_pid) {
3727 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3757 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3728 PluginCrashed(plugin_path, plugin_pid)); 3758 PluginCrashed(plugin_path, plugin_pid));
3729 } 3759 }
3730 3760
3731 void WebContentsImpl::OnRequestPpapiBrokerPermission( 3761 void WebContentsImpl::OnRequestPpapiBrokerPermission(
3732 int routing_id, 3762 int routing_id,
3733 const GURL& url, 3763 const GURL& url,
3734 const base::FilePath& plugin_path) { 3764 const base::FilePath& plugin_path) {
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after
5131 for (RenderViewHost* render_view_host : render_view_host_set) 5161 for (RenderViewHost* render_view_host : render_view_host_set)
5132 render_view_host->OnWebkitPreferencesChanged(); 5162 render_view_host->OnWebkitPreferencesChanged();
5133 } 5163 }
5134 5164
5135 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( 5165 void WebContentsImpl::SetJavaScriptDialogManagerForTesting(
5136 JavaScriptDialogManager* dialog_manager) { 5166 JavaScriptDialogManager* dialog_manager) {
5137 dialog_manager_ = dialog_manager; 5167 dialog_manager_ = dialog_manager;
5138 } 5168 }
5139 5169
5140 } // namespace content 5170 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698