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

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

Powered by Google App Engine
This is Rietveld 408576698