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

Unified Diff: chrome/browser/android/webapps/single_tab_mode_tab_helper.cc

Issue 2821473002: Service CreateNewWindow on the UI thread with a new mojo interface (Closed)
Patch Set: MakeShared goodness Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/webapps/single_tab_mode_tab_helper.cc
diff --git a/chrome/browser/android/webapps/single_tab_mode_tab_helper.cc b/chrome/browser/android/webapps/single_tab_mode_tab_helper.cc
index 85f4755f4d300ac4d957b768728ad81174254ee1..6b85d151e301659fb3d562125cd8e5204226d4cf 100644
--- a/chrome/browser/android/webapps/single_tab_mode_tab_helper.cc
+++ b/chrome/browser/android/webapps/single_tab_mode_tab_helper.cc
@@ -4,103 +4,13 @@
#include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h"
-#include "base/lazy_instance.h"
-#include "chrome/browser/android/tab_android.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/render_frame_host.h"
-#include "content/public/browser/render_process_host.h"
-#include "content/public/browser/web_contents.h"
-
DEFINE_WEB_CONTENTS_USER_DATA_KEY(SingleTabModeTabHelper);
-namespace {
-
-typedef std::pair<int32_t, int32_t> RenderFrameHostID;
-typedef std::set<RenderFrameHostID> SingleTabIDSet;
-base::LazyInstance<SingleTabIDSet>::DestructorAtExit g_blocked_ids =
- LAZY_INSTANCE_INITIALIZER;
-
-void AddPairOnIOThread(int32_t process_id, int32_t frame_routing_id) {
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- RenderFrameHostID single_tab_pair(process_id, frame_routing_id);
- g_blocked_ids.Get().insert(single_tab_pair);
-}
-
-void RemovePairOnIOThread(int32_t process_id, int32_t frame_routing_id) {
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- RenderFrameHostID single_tab_pair(process_id, frame_routing_id);
- SingleTabIDSet::iterator itr = g_blocked_ids.Get().find(single_tab_pair);
- DCHECK(itr != g_blocked_ids.Get().end());
- g_blocked_ids.Get().erase(itr);
-}
-
-void AddPair(content::RenderFrameHost* render_frame_host) {
- if (!render_frame_host)
- return;
-
- int32_t process_id = render_frame_host->GetProcess()->GetID();
- int32_t frame_routing_id = render_frame_host->GetRoutingID();
- content::BrowserThread::PostTask(
- content::BrowserThread::IO, FROM_HERE,
- base::Bind(&AddPairOnIOThread, process_id, frame_routing_id));
-}
-
-void RemovePair(content::RenderFrameHost* render_frame_host) {
- if (!render_frame_host)
- return;
-
- int32_t process_id = render_frame_host->GetProcess()->GetID();
- int32_t frame_routing_id = render_frame_host->GetRoutingID();
- content::BrowserThread::PostTask(
- content::BrowserThread::IO, FROM_HERE,
- base::Bind(&RemovePairOnIOThread, process_id, frame_routing_id));
-}
-
-} // namespace
-
SingleTabModeTabHelper::SingleTabModeTabHelper(
- content::WebContents* web_contents)
- : content::WebContentsObserver(web_contents),
- block_all_new_windows_(false) {
-}
-
-SingleTabModeTabHelper::~SingleTabModeTabHelper() {
-}
-
-void SingleTabModeTabHelper::RenderFrameCreated(
- content::RenderFrameHost* render_frame_host) {
- if (!block_all_new_windows_)
- return;
- AddPair(render_frame_host);
-}
+ content::WebContents* web_contents) {}
-void SingleTabModeTabHelper::RenderFrameDeleted(
- content::RenderFrameHost* render_frame_host) {
- if (!block_all_new_windows_)
- return;
- RemovePair(render_frame_host);
-}
+SingleTabModeTabHelper::~SingleTabModeTabHelper() {}
void SingleTabModeTabHelper::PermanentlyBlockAllNewWindows() {
block_all_new_windows_ = true;
- for (content::RenderFrameHost* frame : web_contents()->GetAllFrames())
- AddPair(frame);
-}
-
-bool SingleTabModeTabHelper::IsRegistered(int32_t process_id,
- int32_t frame_routing_id) {
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- RenderFrameHostID single_tab_pair(process_id, frame_routing_id);
- SingleTabIDSet::iterator itr = g_blocked_ids.Get().find(single_tab_pair);
- return itr != g_blocked_ids.Get().end();
-}
-
-void SingleTabModeTabHelper::HandleOpenUrl(const BlockedWindowParams& params) {
- TabAndroid* tab = TabAndroid::FromWebContents(web_contents());
- if (!tab)
- return;
-
- chrome::NavigateParams nav_params =
- params.CreateNavigateParams(web_contents());
- tab->HandlePopupNavigation(&nav_params);
}

Powered by Google App Engine
This is Rietveld 408576698