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

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

Issue 16702003: Move ShellWindow into apps component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Feedback Created 7 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/apps/chrome_shell_window_delegate.h"
6
7 #include "base/stringprintf.h"
8 #include "chrome/browser/favicon/favicon_tab_helper.h"
9 #include "chrome/browser/file_select_helper.h"
10 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
11 #include "chrome/browser/platform_util.h"
12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_dialogs.h"
14 #include "chrome/browser/ui/browser_finder.h"
15 #include "chrome/browser/ui/browser_tabstrip.h"
16 #include "chrome/browser/ui/browser_window.h"
17 #include "chrome/common/render_messages.h"
18 #include "content/public/browser/render_view_host.h"
19 #include "content/public/browser/web_contents.h"
20 #include "content/public/browser/web_contents_view.h"
21
22 #if defined(USE_ASH)
23 #include "ash/launcher/launcher_types.h"
24 #endif
25
26 namespace chrome {
27
28 namespace {
29
30 static bool disable_external_open_for_testing_ = false;
sky 2013/06/19 14:16:04 no need for static here.
benwells 2013/06/25 08:36:03 Done.
31
32 class ShellWindowLinkDelegate : public content::WebContentsDelegate {
33 private:
34 virtual content::WebContents* OpenURLFromTab(
35 content::WebContents* source,
36 const content::OpenURLParams& params) OVERRIDE;
37 };
sky 2013/06/19 14:16:04 DISALLOW_...
benwells 2013/06/25 08:36:03 Done.
38
39 content::WebContents* ShellWindowLinkDelegate::OpenURLFromTab(
40 content::WebContents* source,
41 const content::OpenURLParams& params) {
42 platform_util::OpenExternal(params.url);
43 delete source;
sky 2013/06/19 14:16:04 Are you sure this doesn't crash? In particular del
benwells 2013/06/25 08:36:03 I'm moving this code from shell_window.cc. The que
Ken Rockot(use gerrit already) 2013/06/25 17:18:11 source is always a fresh blank WebContents, so in
sky 2013/06/25 17:53:37 It doesn't matter than source is a fresh webconten
Ken Rockot(use gerrit already) 2013/06/25 22:25:51 The call site in this case is always WebContentsIm
44 return NULL;
45 }
46
47 } // namespace
48
49 ChromeShellWindowDelegate::~ChromeShellWindowDelegate() {}
50
51 void ChromeShellWindowDelegate::DisableExternalOpenForTesting() {
52 disable_external_open_for_testing_ = true;
53 }
54
55 void ChromeShellWindowDelegate::InitWebContents(
56 content::WebContents* web_contents) {
57 FaviconTabHelper::CreateForWebContents(web_contents);
58 }
59
60 content::WebContents* ChromeShellWindowDelegate::OpenURLFromTab(
61 Profile* profile,
62 content::WebContents* source,
63 const content::OpenURLParams& params) {
64 // Force all links to open in a new tab, even if they were trying to open a
65 // window.
66 chrome::NavigateParams new_tab_params(
67 static_cast<Browser*>(NULL), params.url, params.transition);
68 new_tab_params.disposition = params.disposition == NEW_BACKGROUND_TAB ?
69 params.disposition : NEW_FOREGROUND_TAB;
70 new_tab_params.initiating_profile = profile;
71 chrome::Navigate(&new_tab_params);
72
73 return new_tab_params.target_contents;
74 }
75
76 void ChromeShellWindowDelegate::AddNewContents(
77 Profile* profile,
78 content::WebContents* new_contents,
79 WindowOpenDisposition disposition,
80 const gfx::Rect& initial_pos,
81 bool user_gesture,
82 bool* was_blocked) {
83 #if defined(OS_MACOSX) || defined(OS_WIN) || \
84 (defined(OS_LINUX) && !defined(OS_CHROMEOS))
85 if (disable_external_open_for_testing_) {
86 Browser* browser =
87 chrome::FindOrCreateTabbedBrowser(profile, chrome::GetActiveDesktop());
sky 2013/06/19 14:16:04 If this creates a new browser how does it get show
benwells 2013/06/25 08:36:03 Again, I'm just moving this code from shell_window
Ken Rockot(use gerrit already) 2013/06/25 17:18:11 The following AddWebContents calls chrome::Navigat
88 // Force all links to open in a new tab, even if they were trying to open a
89 // new window.
90 disposition =
91 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB;
92 chrome::AddWebContents(browser, NULL, new_contents, disposition,
93 initial_pos, user_gesture, was_blocked);
94 } else {
95 new_contents->SetDelegate(new ShellWindowLinkDelegate());
96 }
97 #else
98 Browser* browser =
99 chrome::FindOrCreateTabbedBrowser(profile, chrome::GetActiveDesktop());
sky 2013/06/19 14:16:04 Same question here. 98-105 look the same as 86-105
benwells 2013/06/25 08:36:03 The ifdef is needed but I've rearranged so the cod
100 // Force all links to open in a new tab, even if they were trying to open a
101 // new window.
102 disposition =
103 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB;
104 chrome::AddWebContents(browser, NULL, new_contents, disposition, initial_pos,
105 user_gesture, was_blocked);
106 #endif
107 }
108
109 content::ColorChooser* ChromeShellWindowDelegate::ShowColorChooser(
110 content::WebContents* web_contents,
111 SkColor initial_color) {
112 return chrome::ShowColorChooser(web_contents, initial_color);
113 }
114
115 void ChromeShellWindowDelegate::RunFileChooser(
116 content::WebContents* tab,
117 const content::FileChooserParams& params) {
118 FileSelectHelper::RunFileChooser(tab, params);
119 }
120
121 void ChromeShellWindowDelegate::RequestMediaAccessPermission(
122 content::WebContents* web_contents,
123 const content::MediaStreamRequest& request,
124 const content::MediaResponseCallback& callback,
125 const extensions::Extension* extension) {
126 MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest(
127 web_contents, request, callback, extension);
128 }
129
130 int ChromeShellWindowDelegate::PreferredIconSize() {
131 #if defined(USE_ASH)
132 return ash::kLauncherPreferredSize;
133 #else
134 return extension_misc::EXTENSION_ICON_SMALL;
135 #endif
136 }
137
138 void ChromeShellWindowDelegate::SetWebContentsBlocked(
139 content::WebContents* web_contents,
140 bool blocked) {
141 // RenderViewHost may be NULL during shutdown.
142 content::RenderViewHost* host = web_contents->GetRenderViewHost();
143 if (host) {
144 host->Send(new ChromeViewMsg_SetVisuallyDeemphasized(
145 host->GetRoutingID(), blocked));
146 }
147 }
148
149 bool ChromeShellWindowDelegate::IsWebContentsVisible(
150 content::WebContents* web_contents) {
151 return platform_util::IsVisible(web_contents->GetView()->GetNativeView());
152 }
153
154 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698