OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser.h" | 5 #include "chrome/browser/browser.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 } | 164 } |
165 | 165 |
166 // Return true if a browser is an app window or panel hosting | 166 // Return true if a browser is an app window or panel hosting |
167 // extension |extension_app|, and running under |profile|. | 167 // extension |extension_app|, and running under |profile|. |
168 bool BrowserHostsExtensionApp(Browser* browser, | 168 bool BrowserHostsExtensionApp(Browser* browser, |
169 Profile* profile, | 169 Profile* profile, |
170 Extension* extension_app) { | 170 Extension* extension_app) { |
171 if (browser->profile() != profile) | 171 if (browser->profile() != profile) |
172 return false; | 172 return false; |
173 | 173 |
174 if (browser->type() != Browser::TYPE_EXTENSION_APP && | 174 if (browser->type() != Browser::TYPE_APP_PANEL) |
175 browser->type() != Browser::TYPE_APP_PANEL) | |
176 return false; | 175 return false; |
177 | 176 |
178 if (browser->extension_app() != extension_app) | 177 if (browser->extension_app() != extension_app) |
179 return false; | 178 return false; |
180 | 179 |
181 return true; | 180 return true; |
182 } | 181 } |
183 | 182 |
184 } // namespace | 183 } // namespace |
185 | 184 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 | 318 |
320 // static | 319 // static |
321 Browser* Browser::CreateForApp(const std::string& app_name, | 320 Browser* Browser::CreateForApp(const std::string& app_name, |
322 Extension* extension, | 321 Extension* extension, |
323 Profile* profile, | 322 Profile* profile, |
324 bool is_panel) { | 323 bool is_panel) { |
325 Browser::Type type = TYPE_APP; | 324 Browser::Type type = TYPE_APP; |
326 | 325 |
327 if (is_panel) | 326 if (is_panel) |
328 type = TYPE_APP_PANEL; | 327 type = TYPE_APP_PANEL; |
329 else if (extension) | |
330 type = TYPE_EXTENSION_APP; | |
331 | 328 |
332 Browser* browser = new Browser(type, profile); | 329 Browser* browser = new Browser(type, profile); |
333 browser->app_name_ = app_name; | 330 browser->app_name_ = app_name; |
334 browser->extension_app_ = extension; | 331 browser->extension_app_ = extension; |
335 | 332 |
336 if (extension) { | 333 if (extension) { |
337 gfx::Rect initial_pos(extension->launch_width(), | 334 gfx::Rect initial_pos(extension->launch_width(), |
338 extension->launch_height()); | 335 extension->launch_height()); |
339 if (!initial_pos.IsEmpty()) | 336 if (!initial_pos.IsEmpty()) |
340 browser->set_override_bounds(initial_pos); | 337 browser->set_override_bounds(initial_pos); |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 // Chrome OS opens a FileBrowse pop up instead of using download shelf. | 1166 // Chrome OS opens a FileBrowse pop up instead of using download shelf. |
1170 // So FEATURE_DOWNLOADSHELF is only added for non-chromeos platforms. | 1167 // So FEATURE_DOWNLOADSHELF is only added for non-chromeos platforms. |
1171 features |= FEATURE_DOWNLOADSHELF; | 1168 features |= FEATURE_DOWNLOADSHELF; |
1172 #endif // !defined(OS_CHROMEOS) | 1169 #endif // !defined(OS_CHROMEOS) |
1173 | 1170 |
1174 if (type() == TYPE_NORMAL) { | 1171 if (type() == TYPE_NORMAL) { |
1175 features |= FEATURE_BOOKMARKBAR; | 1172 features |= FEATURE_BOOKMARKBAR; |
1176 } | 1173 } |
1177 | 1174 |
1178 if (!hide_ui_for_fullscreen) { | 1175 if (!hide_ui_for_fullscreen) { |
1179 if (type() != TYPE_NORMAL && type() != TYPE_EXTENSION_APP) | 1176 if (type() != TYPE_NORMAL) |
1180 features |= FEATURE_TITLEBAR; | 1177 features |= FEATURE_TITLEBAR; |
1181 | 1178 |
1182 if (type() == TYPE_NORMAL || type() == TYPE_EXTENSION_APP) | 1179 if (type() == TYPE_NORMAL) |
1183 features |= FEATURE_TABSTRIP; | 1180 features |= FEATURE_TABSTRIP; |
1184 | 1181 |
1185 if (type() == TYPE_NORMAL || type() == TYPE_EXTENSION_APP) | 1182 if (type() == TYPE_NORMAL) |
1186 features |= FEATURE_TOOLBAR; | 1183 features |= FEATURE_TOOLBAR; |
1187 | 1184 |
1188 if (type() != TYPE_EXTENSION_APP && (type() & Browser::TYPE_APP) == 0) | 1185 if ((type() & Browser::TYPE_APP) == 0) |
1189 features |= FEATURE_LOCATIONBAR; | 1186 features |= FEATURE_LOCATIONBAR; |
1190 } | 1187 } |
1191 return !!(features & feature); | 1188 return !!(features & feature); |
1192 } | 1189 } |
1193 | 1190 |
1194 bool Browser::IsClosingPermitted() { | 1191 bool Browser::IsClosingPermitted() { |
1195 TabCloseableStateWatcher* watcher = | 1192 TabCloseableStateWatcher* watcher = |
1196 g_browser_process->tab_closeable_state_watcher(); | 1193 g_browser_process->tab_closeable_state_watcher(); |
1197 bool can_close = !watcher || watcher->CanCloseBrowser(this); | 1194 bool can_close = !watcher || watcher->CanCloseBrowser(this); |
1198 if (!can_close && is_attempting_to_close_browser_) | 1195 if (!can_close && is_attempting_to_close_browser_) |
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2406 g_browser_process->tab_closeable_state_watcher(); | 2403 g_browser_process->tab_closeable_state_watcher(); |
2407 return !watcher || watcher->CanCloseTab(this); | 2404 return !watcher || watcher->CanCloseTab(this); |
2408 } | 2405 } |
2409 | 2406 |
2410 void Browser::ToggleUseVerticalTabs() { | 2407 void Browser::ToggleUseVerticalTabs() { |
2411 use_vertical_tabs_.SetValue(!UseVerticalTabs()); | 2408 use_vertical_tabs_.SetValue(!UseVerticalTabs()); |
2412 UseVerticalTabsChanged(); | 2409 UseVerticalTabsChanged(); |
2413 } | 2410 } |
2414 | 2411 |
2415 bool Browser::LargeIconsPermitted() const { | 2412 bool Browser::LargeIconsPermitted() const { |
2416 // We don't show the big icons in tabs for TYPE_EXTENSION_APP windows because | 2413 return false; |
2417 // for those windows, we already have a big icon in the top-left outside any | |
2418 // tab. Having big tab icons too looks kinda redonk. | |
2419 return TYPE_EXTENSION_APP != type(); | |
2420 } | 2414 } |
2421 | 2415 |
2422 /////////////////////////////////////////////////////////////////////////////// | 2416 /////////////////////////////////////////////////////////////////////////////// |
2423 // Browser, TabStripModelObserver implementation: | 2417 // Browser, TabStripModelObserver implementation: |
2424 | 2418 |
2425 void Browser::TabInsertedAt(TabContents* contents, | 2419 void Browser::TabInsertedAt(TabContents* contents, |
2426 int index, | 2420 int index, |
2427 bool foreground) { | 2421 bool foreground) { |
2428 contents->set_delegate(this); | 2422 contents->set_delegate(this); |
2429 contents->controller().SetWindowID(session_id()); | 2423 contents->controller().SetWindowID(session_id()); |
(...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4050 } | 4044 } |
4051 | 4045 |
4052 bool Browser::IsPinned(TabContents* source) { | 4046 bool Browser::IsPinned(TabContents* source) { |
4053 int index = tabstrip_model_.GetIndexOfTabContents(source); | 4047 int index = tabstrip_model_.GetIndexOfTabContents(source); |
4054 if (index == TabStripModel::kNoTab) { | 4048 if (index == TabStripModel::kNoTab) { |
4055 NOTREACHED() << "IsPinned called for tab not in our strip"; | 4049 NOTREACHED() << "IsPinned called for tab not in our strip"; |
4056 return false; | 4050 return false; |
4057 } | 4051 } |
4058 return tabstrip_model_.IsTabPinned(index); | 4052 return tabstrip_model_.IsTabPinned(index); |
4059 } | 4053 } |
OLD | NEW |