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

Unified Diff: chrome/browser/chromeos/extensions/file_manager_util.cc

Issue 10255024: [File Manager] Make sure the new tab is always visible when opening files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/extensions/file_manager_util.cc
diff --git a/chrome/browser/chromeos/extensions/file_manager_util.cc b/chrome/browser/chromeos/extensions/file_manager_util.cc
index 3b5ff6641df7dff739d3b3d0856765a3e92a125c..67adf58efaf16fb9916ac87d9174882f0fb1852d 100644
--- a/chrome/browser/chromeos/extensions/file_manager_util.cc
+++ b/chrome/browser/chromeos/extensions/file_manager_util.cc
@@ -215,6 +215,16 @@ DictionaryValue* ProgessStatusToDictionaryValue(
return result.release();
}
+void OpenNewTab(const GURL& url, Profile* profile) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ Browser* browser = Browser::GetOrCreateTabbedBrowser(
+ profile ? profile : ProfileManager::GetDefaultProfileOrOffTheRecord());
+ browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_LINK);
+ // If the current browser is not tabbed then the new tab will be created
+ // in a different browser. Make sure it is visible.
+ browser->window()->Show();
+}
+
// Shows a warning message box saying that the file could not be opened.
void ShowWarningMessageBox(Profile* profile, const FilePath& path) {
Browser* browser = Browser::GetOrCreateTabbedBrowser(profile);
@@ -247,8 +257,7 @@ void OnGDataFileFound(Profile* profile,
} else {
NOTREACHED();
}
- Browser* browser = Browser::GetOrCreateTabbedBrowser(profile);
- browser->AddSelectedTabWithURL(page_url, content::PAGE_TRANSITION_LINK);
+ OpenNewTab(page_url, profile);
} else {
ShowWarningMessageBox(profile, file_path);
}
@@ -567,13 +576,6 @@ bool ReadSmallFileToString(const FilePath& path, std::string* contents) {
return len < sizeof(buf);
}
-void OpenUrlOnUIThread(const GURL& url) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- Browser* browser = Browser::GetOrCreateTabbedBrowser(
- ProfileManager::GetDefaultProfileOrOffTheRecord());
- browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_LINK);
-}
-
// Reads JSON from a Google Docs file, extracts a document url and opens it
// in a tab.
void ReadUrlFromGDocOnFileThread(const FilePath& file_path) {
@@ -597,14 +599,12 @@ void ReadUrlFromGDocOnFileThread(const FilePath& file_path) {
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(OpenUrlOnUIThread, GURL(edit_url_string)));
+ base::Bind(OpenNewTab, GURL(edit_url_string), (Profile*)NULL));
}
bool TryViewingFile(Profile* profile, const FilePath& path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- Browser* browser = Browser::GetOrCreateTabbedBrowser(profile);
-
std::string file_extension = path.Extension();
// For things supported natively by the browser, we should open it
// in a tab.
@@ -627,8 +627,7 @@ bool TryViewingFile(Profile* profile, const FilePath& path) {
return true;
}
#endif
- browser->AddSelectedTabWithURL(page_url,
- content::PAGE_TRANSITION_LINK);
+ OpenNewTab(page_url, (Profile*)NULL);
return true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698