OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/ash/launcher/browser_shortcut_launcher_item_controll
er.h" | 5 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
10 #include "ash/shelf/shelf_model.h" | 10 #include "ash/shelf/shelf_model.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
33 #include "content/public/common/url_constants.h" | 33 #include "content/public/common/url_constants.h" |
34 #include "grit/ash_resources.h" | 34 #include "grit/ash_resources.h" |
35 #include "ui/aura/window.h" | 35 #include "ui/aura/window.h" |
36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
37 #include "ui/base/resource/resource_bundle.h" | 37 #include "ui/base/resource/resource_bundle.h" |
38 #include "ui/events/event.h" | 38 #include "ui/events/event.h" |
39 #include "ui/gfx/image/image.h" | 39 #include "ui/gfx/image/image.h" |
40 #include "ui/wm/core/window_animations.h" | 40 #include "ui/wm/core/window_animations.h" |
41 | 41 |
| 42 namespace { |
| 43 |
| 44 bool IsSettingsBrowser(Browser* browser) { |
| 45 // Normally this test is sufficient. TODO(stevenjb): Replace this with a |
| 46 // better mechanism (Settings WebUI or Browser type). |
| 47 if (chrome::IsTrustedPopupWindowWithScheme(browser, content::kChromeUIScheme)) |
| 48 return true; |
| 49 // If a settings window navigates away from a kChromeUIScheme (e.g. after a |
| 50 // crash), the above may not be true, so also test against the known list |
| 51 // of settings browsers (which will not be valid during chrome::Navigate |
| 52 // which is why we still need the above test). |
| 53 if (chrome::SettingsWindowManager::GetInstance()->IsSettingsBrowser(browser)) |
| 54 return true; |
| 55 return false; |
| 56 } |
| 57 |
| 58 } // namespace |
| 59 |
42 BrowserShortcutLauncherItemController::BrowserShortcutLauncherItemController( | 60 BrowserShortcutLauncherItemController::BrowserShortcutLauncherItemController( |
43 ChromeLauncherController* launcher_controller) | 61 ChromeLauncherController* launcher_controller) |
44 : LauncherItemController(TYPE_SHORTCUT, | 62 : LauncherItemController(TYPE_SHORTCUT, |
45 extension_misc::kChromeAppId, | 63 extension_misc::kChromeAppId, |
46 launcher_controller) { | 64 launcher_controller) { |
47 } | 65 } |
48 | 66 |
49 BrowserShortcutLauncherItemController:: | 67 BrowserShortcutLauncherItemController:: |
50 ~BrowserShortcutLauncherItemController() { | 68 ~BrowserShortcutLauncherItemController() { |
51 } | 69 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 120 } |
103 | 121 |
104 void BrowserShortcutLauncherItemController::SetShelfIDForBrowserWindowContents( | 122 void BrowserShortcutLauncherItemController::SetShelfIDForBrowserWindowContents( |
105 Browser* browser, | 123 Browser* browser, |
106 content::WebContents* web_contents) { | 124 content::WebContents* web_contents) { |
107 // We need to call SetShelfIDForWindow for V1 applications since they are | 125 // We need to call SetShelfIDForWindow for V1 applications since they are |
108 // content which might change and as such change the application type. | 126 // content which might change and as such change the application type. |
109 if (!browser || | 127 if (!browser || |
110 !launcher_controller()->IsBrowserFromActiveUser(browser) || | 128 !launcher_controller()->IsBrowserFromActiveUser(browser) || |
111 browser->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH || | 129 browser->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH || |
112 chrome::IsTrustedPopupWindowWithScheme(browser, content::kChromeUIScheme)) | 130 IsSettingsBrowser(browser)) |
113 return; | 131 return; |
114 | 132 |
115 ash::SetShelfIDForWindow( | 133 ash::SetShelfIDForWindow( |
116 launcher_controller()->GetShelfIDForWebContents(web_contents), | 134 launcher_controller()->GetShelfIDForWebContents(web_contents), |
117 browser->window()->GetNativeWindow()); | 135 browser->window()->GetNativeWindow()); |
118 } | 136 } |
119 | 137 |
120 bool BrowserShortcutLauncherItemController::IsOpen() const { | 138 bool BrowserShortcutLauncherItemController::IsOpen() const { |
121 const BrowserList* ash_browser_list = | 139 const BrowserList* ash_browser_list = |
122 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | 140 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 browser->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) | 360 browser->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) |
343 return false; | 361 return false; |
344 | 362 |
345 // v1 App popup windows with a valid app id have their own icon. | 363 // v1 App popup windows with a valid app id have their own icon. |
346 if (browser->is_app() && | 364 if (browser->is_app() && |
347 browser->is_type_popup() && | 365 browser->is_type_popup() && |
348 launcher_controller()->GetShelfIDForAppID( | 366 launcher_controller()->GetShelfIDForAppID( |
349 web_app::GetExtensionIdFromApplicationName(browser->app_name())) > 0) | 367 web_app::GetExtensionIdFromApplicationName(browser->app_name())) > 0) |
350 return false; | 368 return false; |
351 | 369 |
352 // Stand-alone chrome:// windows (e.g. settings) have their own icon. | 370 // Settings browsers have their own icon. |
353 if (chrome::IsTrustedPopupWindowWithScheme(browser, content::kChromeUIScheme)) | 371 if (IsSettingsBrowser(browser)) |
354 return false; | 372 return false; |
355 | 373 |
356 // Tabbed browser and other popup windows are all represented. | 374 // Tabbed browser and other popup windows are all represented. |
357 return true; | 375 return true; |
358 } | 376 } |
OLD | NEW |