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

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 and mlamouri'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
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 #if defined(OS_MACOSX) 138 #if defined(OS_MACOSX)
138 #include "base/mac/foundation_util.h" 139 #include "base/mac/foundation_util.h"
139 #endif 140 #endif
140 141
141 #if defined(MOJO_SHELL_CLIENT) 142 #if defined(MOJO_SHELL_CLIENT)
142 #include "content/browser/web_contents/web_contents_view_mus.h" 143 #include "content/browser/web_contents/web_contents_view_mus.h"
143 #include "content/public/common/mojo_shell_connection.h" 144 #include "content/public/common/mojo_shell_connection.h"
144 #include "ui/aura/mus/mus_util.h" 145 #include "ui/aura/mus/mus_util.h"
145 #endif 146 #endif
146 147
148 #if defined(ENABLE_PLUGINS)
149 #include "content/browser/media/session/pepper_playback_observer.h"
150 #endif // ENABLE_PLUGINS
151
147 namespace content { 152 namespace content {
148 namespace { 153 namespace {
149 154
150 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; 155 const int kMinimumDelayBetweenLoadingUpdatesMS = 100;
151 const char kDotGoogleDotCom[] = ".google.com"; 156 const char kDotGoogleDotCom[] = ".google.com";
152 157
153 #if defined(OS_ANDROID) 158 #if defined(OS_ANDROID)
154 const char kWebContentsAndroidKey[] = "web_contents_android"; 159 const char kWebContentsAndroidKey[] = "web_contents_android";
155 #endif // OS_ANDROID 160 #endif // OS_ANDROID
156 161
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 loading_weak_factory_(this), 426 loading_weak_factory_(this),
422 weak_factory_(this) { 427 weak_factory_(this) {
423 frame_tree_.SetFrameRemoveListener( 428 frame_tree_.SetFrameRemoveListener(
424 base::Bind(&WebContentsImpl::OnFrameRemoved, 429 base::Bind(&WebContentsImpl::OnFrameRemoved,
425 base::Unretained(this))); 430 base::Unretained(this)));
426 #if defined(OS_ANDROID) 431 #if defined(OS_ANDROID)
427 media_web_contents_observer_.reset(new MediaWebContentsObserverAndroid(this)); 432 media_web_contents_observer_.reset(new MediaWebContentsObserverAndroid(this));
428 #else 433 #else
429 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); 434 media_web_contents_observer_.reset(new MediaWebContentsObserver(this));
430 #endif 435 #endif
436 #if defined (ENABLE_PLUGINS)
437 pepper_playback_observer_.reset(new PepperPlaybackObserver(this));
438 #endif
431 loader_io_thread_notifier_.reset(new LoaderIOThreadNotifier(this)); 439 loader_io_thread_notifier_.reset(new LoaderIOThreadNotifier(this));
432 wake_lock_service_context_.reset(new WakeLockServiceContext(this)); 440 wake_lock_service_context_.reset(new WakeLockServiceContext(this));
433 } 441 }
434 442
435 WebContentsImpl::~WebContentsImpl() { 443 WebContentsImpl::~WebContentsImpl() {
436 is_being_destroyed_ = true; 444 is_being_destroyed_ = true;
437 445
438 rwh_input_event_router_.reset(); 446 rwh_input_event_router_.reset();
439 447
440 for (FrameTreeNode* node : frame_tree_.Nodes()) { 448 for (FrameTreeNode* node : frame_tree_.Nodes()) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 if (IsBrowserSideNavigationEnabled()) { 495 if (IsBrowserSideNavigationEnabled()) {
488 // Do not update state as the WebContents is being destroyed. 496 // Do not update state as the WebContents is being destroyed.
489 frame_tree_.root()->ResetNavigationRequest(true); 497 frame_tree_.root()->ResetNavigationRequest(true);
490 if (root->speculative_frame_host()) { 498 if (root->speculative_frame_host()) {
491 root->speculative_frame_host()->SetRenderFrameCreated(false); 499 root->speculative_frame_host()->SetRenderFrameCreated(false);
492 root->speculative_frame_host()->SetNavigationHandle( 500 root->speculative_frame_host()->SetNavigationHandle(
493 std::unique_ptr<NavigationHandleImpl>()); 501 std::unique_ptr<NavigationHandleImpl>());
494 } 502 }
495 } 503 }
496 504
505 #if defined(ENABLE_PLUGINS)
506 // Call this before WebContentsDestroyed() is broadcasted since
507 // AudioFocusManager will be destroyed after that.
508 pepper_playback_observer_.reset();
509 #endif // defined(ENABLED_PLUGINS)
510
497 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 511 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
498 FrameDeleted(root->current_frame_host())); 512 FrameDeleted(root->current_frame_host()));
499 513
500 if (root->pending_render_view_host()) { 514 if (root->pending_render_view_host()) {
501 FOR_EACH_OBSERVER(WebContentsObserver, 515 FOR_EACH_OBSERVER(WebContentsObserver,
502 observers_, 516 observers_,
503 RenderViewDeleted(root->pending_render_view_host())); 517 RenderViewDeleted(root->pending_render_view_host()));
504 } 518 }
505 519
506 FOR_EACH_OBSERVER(WebContentsObserver, 520 FOR_EACH_OBSERVER(WebContentsObserver,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 OnUpdatePageImportanceSignals) 696 OnUpdatePageImportanceSignals)
683 IPC_MESSAGE_HANDLER(FrameHostMsg_Find_Reply, OnFindReply) 697 IPC_MESSAGE_HANDLER(FrameHostMsg_Find_Reply, OnFindReply)
684 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) 698 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed)
685 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) 699 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend)
686 #if defined(ENABLE_PLUGINS) 700 #if defined(ENABLE_PLUGINS)
687 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceCreated, 701 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceCreated,
688 OnPepperInstanceCreated) 702 OnPepperInstanceCreated)
689 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted, 703 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted,
690 OnPepperInstanceDeleted) 704 OnPepperInstanceDeleted)
691 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) 705 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung)
706 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStartsPlayback,
707 OnPepperStartsPlayback)
708 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStopsPlayback,
709 OnPepperStopsPlayback)
692 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) 710 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed)
693 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, 711 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission,
694 OnRequestPpapiBrokerPermission) 712 OnRequestPpapiBrokerPermission)
695 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, 713 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach,
696 OnBrowserPluginMessage(render_frame_host, 714 OnBrowserPluginMessage(render_frame_host,
697 message)) 715 message))
698 #endif 716 #endif
699 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) 717 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL)
700 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, 718 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage,
701 OnShowValidationMessage) 719 OnShowValidationMessage)
(...skipping 2991 matching lines...) Expand 10 before | Expand all | Expand 10 after
3693 // This exists for render views that don't have a WebUI, but do have WebUI 3711 // This exists for render views that don't have a WebUI, but do have WebUI
3694 // bindings enabled. 3712 // bindings enabled.
3695 void WebContentsImpl::OnWebUISend(const GURL& source_url, 3713 void WebContentsImpl::OnWebUISend(const GURL& source_url,
3696 const std::string& name, 3714 const std::string& name,
3697 const base::ListValue& args) { 3715 const base::ListValue& args) {
3698 if (delegate_) 3716 if (delegate_)
3699 delegate_->WebUISend(this, source_url, name, args); 3717 delegate_->WebUISend(this, source_url, name, args);
3700 } 3718 }
3701 3719
3702 #if defined(ENABLE_PLUGINS) 3720 #if defined(ENABLE_PLUGINS)
3703 void WebContentsImpl::OnPepperInstanceCreated() { 3721 void WebContentsImpl::OnPepperInstanceCreated(int32_t pp_instance) {
3704 FOR_EACH_OBSERVER(WebContentsObserver, observers_, PepperInstanceCreated()); 3722 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3723 PepperInstanceCreated());
3724 pepper_playback_observer_->PepperInstanceCreated(pp_instance);
3705 } 3725 }
3706 3726
3707 void WebContentsImpl::OnPepperInstanceDeleted() { 3727 void WebContentsImpl::OnPepperInstanceDeleted(int32_t pp_instance) {
3708 FOR_EACH_OBSERVER(WebContentsObserver, observers_, PepperInstanceDeleted()); 3728 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3729 PepperInstanceDeleted());
3730 pepper_playback_observer_->PepperInstanceDeleted(pp_instance);
3709 } 3731 }
3710 3732
3711 void WebContentsImpl::OnPepperPluginHung(int plugin_child_id, 3733 void WebContentsImpl::OnPepperPluginHung(int plugin_child_id,
3712 const base::FilePath& path, 3734 const base::FilePath& path,
3713 bool is_hung) { 3735 bool is_hung) {
3714 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1); 3736 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1);
3715 3737
3716 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3738 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3717 PluginHungStatusChanged(plugin_child_id, path, is_hung)); 3739 PluginHungStatusChanged(plugin_child_id, path, is_hung));
3718 } 3740 }
3719 3741
3742 void WebContentsImpl::OnPepperStartsPlayback(int32_t pp_instance) {
3743 pepper_playback_observer_->PepperStartsPlayback(pp_instance);
3744 }
3745
3746 void WebContentsImpl::OnPepperStopsPlayback(int32_t pp_instance) {
3747 pepper_playback_observer_->PepperStopsPlayback(pp_instance);
3748 }
3749
3720 void WebContentsImpl::OnPluginCrashed(const base::FilePath& plugin_path, 3750 void WebContentsImpl::OnPluginCrashed(const base::FilePath& plugin_path,
3721 base::ProcessId plugin_pid) { 3751 base::ProcessId plugin_pid) {
3722 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3752 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3723 PluginCrashed(plugin_path, plugin_pid)); 3753 PluginCrashed(plugin_path, plugin_pid));
3724 } 3754 }
3725 3755
3726 void WebContentsImpl::OnRequestPpapiBrokerPermission( 3756 void WebContentsImpl::OnRequestPpapiBrokerPermission(
3727 int routing_id, 3757 int routing_id,
3728 const GURL& url, 3758 const GURL& url,
3729 const base::FilePath& plugin_path) { 3759 const base::FilePath& plugin_path) {
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after
5126 for (RenderViewHost* render_view_host : render_view_host_set) 5156 for (RenderViewHost* render_view_host : render_view_host_set)
5127 render_view_host->OnWebkitPreferencesChanged(); 5157 render_view_host->OnWebkitPreferencesChanged();
5128 } 5158 }
5129 5159
5130 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( 5160 void WebContentsImpl::SetJavaScriptDialogManagerForTesting(
5131 JavaScriptDialogManager* dialog_manager) { 5161 JavaScriptDialogManager* dialog_manager) {
5132 dialog_manager_ = dialog_manager; 5162 dialog_manager_ = dialog_manager;
5133 } 5163 }
5134 5164
5135 } // namespace content 5165 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698