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

Side by Side Diff: chrome/browser/platform_util_chromeos.cc

Issue 10696222: Make chrome::Navigate take in a Browser* that is never NULL. That function doesn't have a context, … (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension_tab_util.cc ('k') | chrome/browser/ui/browser_navigator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/platform_util.h" 5 #include "chrome/browser/platform_util.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/chromeos/extensions/file_manager_util.h" 11 #include "chrome/browser/chromeos/extensions/file_manager_util.h"
12 #include "chrome/browser/profiles/profile_manager.h" 12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/browser/ui/browser_finder.h"
13 #include "chrome/browser/ui/browser_navigator.h" 14 #include "chrome/browser/ui/browser_navigator.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
17 18
18 using content::BrowserThread; 19 using content::BrowserThread;
19 20
20 class Profile; 21 class Profile;
21 22
22 namespace { 23 namespace {
23 24
24 const char kGmailComposeUrl[] = 25 const char kGmailComposeUrl[] =
25 "https://mail.google.com/mail/?extsrc=mailto&url="; 26 "https://mail.google.com/mail/?extsrc=mailto&url=";
26 27
27 void OpenItemOnFileThread(const FilePath& full_path) { 28 void OpenItemOnFileThread(const FilePath& full_path) {
28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
29 base::Closure callback; 30 base::Closure callback;
30 if (file_util::DirectoryExists(full_path)) 31 if (file_util::DirectoryExists(full_path))
31 callback = base::Bind(&file_manager_util::ViewFolder, full_path); 32 callback = base::Bind(&file_manager_util::ViewFolder, full_path);
32 else 33 else
33 callback = base::Bind(&file_manager_util::ViewFile, full_path); 34 callback = base::Bind(&file_manager_util::ViewFile, full_path);
34 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); 35 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback);
35 } 36 }
36 37
37 void OpenURL(const std::string& url) { 38 void OpenURL(const std::string& url) {
38 // TODO(beng): improve this to locate context from call stack. 39 // TODO(beng): improve this to locate context from call stack.
39 chrome::NavigateParams params(NULL, GURL(url), content::PAGE_TRANSITION_LINK); 40 Browser* browser = browser::FindOrCreateTabbedBrowser(
41 ProfileManager::GetDefaultProfileOrOffTheRecord());
42 chrome::NavigateParams params(
43 browser, GURL(url), content::PAGE_TRANSITION_LINK);
40 params.disposition = NEW_FOREGROUND_TAB; 44 params.disposition = NEW_FOREGROUND_TAB;
41 params.profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
42 chrome::Navigate(&params); 45 chrome::Navigate(&params);
43 } 46 }
44 47
45 } // namespace 48 } // namespace
46 49
47 namespace platform_util { 50 namespace platform_util {
48 51
49 void ShowItemInFolder(const FilePath& full_path) { 52 void ShowItemInFolder(const FilePath& full_path) {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
51 file_manager_util::ShowFileInFolder(full_path); 54 file_manager_util::ShowFileInFolder(full_path);
(...skipping 17 matching lines...) Expand all
69 // As such we should keep this code here. 72 // As such we should keep this code here.
70 if (url.SchemeIs("mailto")) { 73 if (url.SchemeIs("mailto")) {
71 std::string string_url = kGmailComposeUrl; 74 std::string string_url = kGmailComposeUrl;
72 string_url.append(url.spec()); 75 string_url.append(url.spec());
73 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 76 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
74 base::Bind(OpenURL, string_url)); 77 base::Bind(OpenURL, string_url));
75 } 78 }
76 } 79 }
77 80
78 } // namespace platform_util 81 } // namespace platform_util
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_tab_util.cc ('k') | chrome/browser/ui/browser_navigator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698