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

Side by Side Diff: trunk/src/chrome/browser/ui/apps/chrome_shell_window_delegate.cc

Issue 164613002: Revert 251094 "Revert 250826 "Remove Profile dependency from app..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/apps/chrome_shell_window_delegate.h" 5 #include "chrome/browser/ui/apps/chrome_shell_window_delegate.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "chrome/browser/favicon/favicon_tab_helper.h" 8 #include "chrome/browser/favicon/favicon_tab_helper.h"
9 #include "chrome/browser/file_select_helper.h" 9 #include "chrome/browser/file_select_helper.h"
10 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 10 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
11 #include "chrome/browser/platform_util.h" 11 #include "chrome/browser/platform_util.h"
12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/shell_integration.h" 13 #include "chrome/browser/shell_integration.h"
13 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_dialogs.h" 15 #include "chrome/browser/ui/browser_dialogs.h"
15 #include "chrome/browser/ui/browser_tabstrip.h" 16 #include "chrome/browser/ui/browser_tabstrip.h"
16 #include "chrome/browser/ui/browser_window.h" 17 #include "chrome/browser/ui/browser_window.h"
17 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 18 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
18 #include "chrome/common/render_messages.h" 19 #include "chrome/common/render_messages.h"
20 #include "content/public/browser/browser_context.h"
19 #include "content/public/browser/render_view_host.h" 21 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
21 #include "content/public/browser/web_contents_view.h" 23 #include "content/public/browser/web_contents_view.h"
22 24
23 #if defined(USE_ASH) 25 #if defined(USE_ASH)
24 #include "ash/shelf/shelf_constants.h" 26 #include "ash/shelf/shelf_constants.h"
25 #endif 27 #endif
26 28
27 #if defined(ENABLE_PRINTING) 29 #if defined(ENABLE_PRINTING)
28 #if defined(ENABLE_FULL_PRINTING) 30 #if defined(ENABLE_FULL_PRINTING)
29 #include "chrome/browser/printing/print_preview_message_handler.h" 31 #include "chrome/browser/printing/print_preview_message_handler.h"
30 #include "chrome/browser/printing/print_view_manager.h" 32 #include "chrome/browser/printing/print_view_manager.h"
31 #else 33 #else
32 #include "chrome/browser/printing/print_view_manager_basic.h" 34 #include "chrome/browser/printing/print_view_manager_basic.h"
33 #endif // defined(ENABLE_FULL_PRINTING) 35 #endif // defined(ENABLE_FULL_PRINTING)
34 #endif // defined(ENABLE_PRINTING) 36 #endif // defined(ENABLE_PRINTING)
35 37
36 namespace { 38 namespace {
37 39
38 bool disable_external_open_for_testing_ = false; 40 bool disable_external_open_for_testing_ = false;
39 41
40 // Opens a URL with Chromium (not external browser) with the right profile. 42 // Opens a URL with Chromium (not external browser) with the right profile.
41 content::WebContents* OpenURLFromTabInternal( 43 content::WebContents* OpenURLFromTabInternal(
42 Profile* profile, 44 content::BrowserContext* context,
43 content::WebContents* source, 45 content::WebContents* source,
44 const content::OpenURLParams& params) { 46 const content::OpenURLParams& params) {
45 // Force all links to open in a new tab, even if they were trying to open a 47 // Force all links to open in a new tab, even if they were trying to open a
46 // window. 48 // window.
47 chrome::NavigateParams new_tab_params( 49 chrome::NavigateParams new_tab_params(
48 static_cast<Browser*>(NULL), params.url, params.transition); 50 static_cast<Browser*>(NULL), params.url, params.transition);
49 new_tab_params.disposition = params.disposition == NEW_BACKGROUND_TAB 51 new_tab_params.disposition = params.disposition == NEW_BACKGROUND_TAB
50 ? params.disposition 52 ? params.disposition
51 : NEW_FOREGROUND_TAB; 53 : NEW_FOREGROUND_TAB;
52 new_tab_params.initiating_profile = profile; 54 new_tab_params.initiating_profile = Profile::FromBrowserContext(context);
53 chrome::Navigate(&new_tab_params); 55 chrome::Navigate(&new_tab_params);
54 56
55 return new_tab_params.target_contents; 57 return new_tab_params.target_contents;
56 } 58 }
57 59
58 // Helper class that opens a URL based on if this browser instance is the 60 // Helper class that opens a URL based on if this browser instance is the
59 // default system browser. If it is the default, open the URL directly instead 61 // default system browser. If it is the default, open the URL directly instead
60 // of asking the system to open it. 62 // of asking the system to open it.
61 class OpenURLFromTabBasedOnBrowserDefault 63 class OpenURLFromTabBasedOnBrowserDefault
62 : public ShellIntegration::DefaultWebClientObserver { 64 : public ShellIntegration::DefaultWebClientObserver {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 #endif // defined(ENABLE_PRINTING) 143 #endif // defined(ENABLE_PRINTING)
142 } 144 }
143 145
144 apps::NativeAppWindow* ChromeShellWindowDelegate::CreateNativeAppWindow( 146 apps::NativeAppWindow* ChromeShellWindowDelegate::CreateNativeAppWindow(
145 apps::ShellWindow* window, 147 apps::ShellWindow* window,
146 const apps::ShellWindow::CreateParams& params) { 148 const apps::ShellWindow::CreateParams& params) {
147 return CreateNativeAppWindowImpl(window, params); 149 return CreateNativeAppWindowImpl(window, params);
148 } 150 }
149 151
150 content::WebContents* ChromeShellWindowDelegate::OpenURLFromTab( 152 content::WebContents* ChromeShellWindowDelegate::OpenURLFromTab(
151 Profile* profile, 153 content::BrowserContext* context,
152 content::WebContents* source, 154 content::WebContents* source,
153 const content::OpenURLParams& params) { 155 const content::OpenURLParams& params) {
154 return OpenURLFromTabInternal(profile, source, params); 156 return OpenURLFromTabInternal(context, source, params);
155 } 157 }
156 158
157 void ChromeShellWindowDelegate::AddNewContents( 159 void ChromeShellWindowDelegate::AddNewContents(
158 Profile* profile, 160 content::BrowserContext* context,
159 content::WebContents* new_contents, 161 content::WebContents* new_contents,
160 WindowOpenDisposition disposition, 162 WindowOpenDisposition disposition,
161 const gfx::Rect& initial_pos, 163 const gfx::Rect& initial_pos,
162 bool user_gesture, 164 bool user_gesture,
163 bool* was_blocked) { 165 bool* was_blocked) {
164 if (!disable_external_open_for_testing_) { 166 if (!disable_external_open_for_testing_) {
165 if (!shell_window_link_delegate_.get()) 167 if (!shell_window_link_delegate_.get())
166 shell_window_link_delegate_.reset(new ShellWindowLinkDelegate()); 168 shell_window_link_delegate_.reset(new ShellWindowLinkDelegate());
167 new_contents->SetDelegate(shell_window_link_delegate_.get()); 169 new_contents->SetDelegate(shell_window_link_delegate_.get());
168 return; 170 return;
169 } 171 }
170 chrome::ScopedTabbedBrowserDisplayer displayer( 172 chrome::ScopedTabbedBrowserDisplayer displayer(
171 profile, chrome::GetActiveDesktop()); 173 Profile::FromBrowserContext(context), chrome::GetActiveDesktop());
172 // Force all links to open in a new tab, even if they were trying to open a 174 // Force all links to open in a new tab, even if they were trying to open a
173 // new window. 175 // new window.
174 disposition = 176 disposition =
175 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB; 177 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB;
176 chrome::AddWebContents(displayer.browser(), NULL, new_contents, disposition, 178 chrome::AddWebContents(displayer.browser(), NULL, new_contents, disposition,
177 initial_pos, user_gesture, was_blocked); 179 initial_pos, user_gesture, was_blocked);
178 } 180 }
179 181
180 content::ColorChooser* ChromeShellWindowDelegate::ShowColorChooser( 182 content::ColorChooser* ChromeShellWindowDelegate::ShowColorChooser(
181 content::WebContents* web_contents, 183 content::WebContents* web_contents,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 if (host) { 216 if (host) {
215 host->Send(new ChromeViewMsg_SetVisuallyDeemphasized( 217 host->Send(new ChromeViewMsg_SetVisuallyDeemphasized(
216 host->GetRoutingID(), blocked)); 218 host->GetRoutingID(), blocked));
217 } 219 }
218 } 220 }
219 221
220 bool ChromeShellWindowDelegate::IsWebContentsVisible( 222 bool ChromeShellWindowDelegate::IsWebContentsVisible(
221 content::WebContents* web_contents) { 223 content::WebContents* web_contents) {
222 return platform_util::IsVisible(web_contents->GetView()->GetNativeView()); 224 return platform_util::IsVisible(web_contents->GetView()->GetNativeView());
223 } 225 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698