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

Unified Diff: chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_navigation_util.cc

Issue 2973313002: Chrome Cleanup: re-open settings post-cleanup if reboot is needed (Closed)
Patch Set: Revert changes to md_settings_ui.cc (to do in another CL) Created 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_navigation_util.cc
diff --git a/chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_navigation_util.cc b/chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_navigation_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..840d940a5b1fc2dbcfbd804f52c9c0d681790970
--- /dev/null
+++ b/chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_navigation_util.cc
@@ -0,0 +1,51 @@
+// 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 "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_navigation_util.h"
+
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/common/url_constants.h"
+#include "ui/base/page_transition_types.h"
+#include "ui/base/window_open_disposition.h"
+#include "url/gurl.h"
+
+namespace chrome_cleaner_util {
+
+Browser* FindBrowser() {
+ BrowserList* browser_list = BrowserList::GetInstance();
+ for (BrowserList::const_reverse_iterator browser_iterator =
+ browser_list->begin_last_active();
+ browser_iterator != browser_list->end_last_active();
+ ++browser_iterator) {
+ Browser* browser = *browser_iterator;
+ if (browser->is_type_tabbed() &&
+ (browser->window()->IsActive() || !browser->window()->IsMinimized()))
+ return browser;
+ }
+
+ return nullptr;
+}
+
+void OpenSettingsPage(Browser* browser,
+ WindowOpenDisposition disposition,
+ bool skip_if_already_open) {
+ DCHECK(browser);
+
+ // Skip opening the settings page if it's already the currently active tab.
+ content::WebContents* web_contents =
+ browser->tab_strip_model()->GetActiveWebContents();
+ if (skip_if_already_open && web_contents &&
+ web_contents->GetLastCommittedURL() == chrome::kChromeUISettingsURL) {
+ browser->window()->Show();
csharp 2017/07/10 20:53:26 If the settings tab is already the current tab, wh
proberge 2017/07/10 21:16:03 If the window is in the background (ex. a differen
+ return;
+ }
+
+ browser->OpenURL(content::OpenURLParams(
+ GURL(chrome::kChromeUISettingsURL), content::Referrer(), disposition,
+ ui::PAGE_TRANSITION_AUTO_TOPLEVEL, /*is_renderer_initiated=*/false));
+}
+
+} // namespace chrome_cleaner_util

Powered by Google App Engine
This is Rietveld 408576698