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

Side by Side Diff: chrome/browser/ui/ash/launcher/browser_launcher_item_controller.cc

Issue 12288012: Showing launcher items for windowed v1 apps - pinned or not. Also - don't show windowed v1 apps in … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing build breakage with clang Created 7 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 (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/ui/ash/launcher/browser_launcher_item_controller.h" 5 #include "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h"
6 6
7 #include "ash/launcher/launcher.h" 7 #include "ash/launcher/launcher.h"
8 #include "ash/launcher/launcher_model.h" 8 #include "ash/launcher/launcher_model.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 !tab_model->profile()->IsGuestSession()) { 42 !tab_model->profile()->IsGuestSession()) {
43 DCHECK(window_); 43 DCHECK(window_);
44 window_->AddObserver(this); 44 window_->AddObserver(this);
45 } 45 }
46 46
47 BrowserLauncherItemController::~BrowserLauncherItemController() { 47 BrowserLauncherItemController::~BrowserLauncherItemController() {
48 tab_model_->RemoveObserver(this); 48 tab_model_->RemoveObserver(this);
49 window_->RemoveObserver(this); 49 window_->RemoveObserver(this);
50 if (launcher_id() > 0) 50 if (launcher_id() > 0)
51 launcher_controller()->CloseLauncherItem(launcher_id()); 51 launcher_controller()->CloseLauncherItem(launcher_id());
52 if (type() == TYPE_WINDOWED_APP)
53 launcher_controller()->UnlockV1AppWithID(LauncherItemController::app_id());
54 }
55
56 const std::string& BrowserLauncherItemController::app_id() const {
57 if (type() == TYPE_WINDOWED_APP)
58 return empty_app_id_;
59 return LauncherItemController::app_id();
52 } 60 }
53 61
54 void BrowserLauncherItemController::Init() { 62 void BrowserLauncherItemController::Init() {
55 tab_model_->AddObserver(this); 63 tab_model_->AddObserver(this);
56 ash::LauncherItemStatus app_status = 64 ash::LauncherItemStatus app_status =
57 ash::wm::IsActiveWindow(window_) ? 65 ash::wm::IsActiveWindow(window_) ?
58 ash::STATUS_ACTIVE : ash::STATUS_RUNNING; 66 ash::STATUS_ACTIVE : ash::STATUS_RUNNING;
59 if (type() != TYPE_TABBED) { 67 if (type() != TYPE_TABBED && type() != TYPE_WINDOWED_APP) {
60 launcher_controller()->CreateAppLauncherItem(this, app_id(), app_status); 68 launcher_controller()->CreateAppLauncherItem(this, app_id(), app_status);
61 } else { 69 } else {
62 launcher_controller()->CreateTabbedLauncherItem( 70 launcher_controller()->CreateTabbedLauncherItem(
63 this, 71 this,
64 is_incognito_ ? ChromeLauncherController::STATE_INCOGNITO : 72 is_incognito_ ? ChromeLauncherController::STATE_INCOGNITO :
65 ChromeLauncherController::STATE_NOT_INCOGNITO, 73 ChromeLauncherController::STATE_NOT_INCOGNITO,
66 app_status); 74 app_status);
75 if (type() == TYPE_WINDOWED_APP)
76 launcher_controller()->LockV1AppWithID(LauncherItemController::app_id());
67 } 77 }
68 // In testing scenarios we can get tab strips with no active contents. 78 // In testing scenarios we can get tab strips with no active contents.
69 if (tab_model_->active_index() != TabStripModel::kNoTab) 79 if (tab_model_->active_index() != TabStripModel::kNoTab)
70 UpdateLauncher(tab_model_->GetActiveWebContents()); 80 UpdateLauncher(tab_model_->GetActiveWebContents());
71 } 81 }
72 82
73 // static 83 // static
74 BrowserLauncherItemController* BrowserLauncherItemController::Create( 84 BrowserLauncherItemController* BrowserLauncherItemController::Create(
75 Browser* browser) { 85 Browser* browser) {
76 // Under testing this can be called before the controller is created. 86 // Under testing this can be called before the controller is created.
77 if (!ChromeLauncherController::instance()) 87 if (!ChromeLauncherController::instance())
78 return NULL; 88 return NULL;
79 89
80 Type type; 90 Type type;
81 std::string app_id; 91 std::string app_id;
82 if (browser->is_type_tabbed() || browser->is_type_popup()) { 92 if (browser->is_type_tabbed() || browser->is_type_popup()) {
83 type = TYPE_TABBED; 93 type = TYPE_TABBED;
94 if (!browser->is_type_tabbed() &&
95 browser->is_type_popup() &&
96 browser->is_app() &&
97 ChromeLauncherController::instance()->GetPerAppInterface()) {
98 app_id = web_app::GetExtensionIdFromApplicationName(
99 browser->app_name());
100 // Only allow this for known applications. Some unit tests for example
101 // do not have one.
102 if (!app_id.empty())
103 type = TYPE_WINDOWED_APP;
104 }
84 } else if (browser->is_app()) { 105 } else if (browser->is_app()) {
85 if (browser->is_type_panel()) { 106 if (browser->is_type_panel()) {
86 if (browser->app_type() == Browser::APP_TYPE_CHILD) 107 if (browser->app_type() == Browser::APP_TYPE_CHILD)
87 type = TYPE_EXTENSION_PANEL; 108 type = TYPE_EXTENSION_PANEL;
88 else 109 else
89 type = TYPE_APP_PANEL; 110 type = TYPE_APP_PANEL;
90 } else { 111 } else {
91 type = TYPE_TABBED; 112 type = TYPE_TABBED;
92 } 113 }
93 app_id = web_app::GetExtensionIdFromApplicationName(browser->app_name()); 114 app_id = web_app::GetExtensionIdFromApplicationName(browser->app_name());
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 app_state = ChromeLauncherController::APP_STATE_ACTIVE; 345 app_state = ChromeLauncherController::APP_STATE_ACTIVE;
325 } else { 346 } else {
326 app_state = ChromeLauncherController::APP_STATE_INACTIVE; 347 app_state = ChromeLauncherController::APP_STATE_INACTIVE;
327 } 348 }
328 launcher_controller()->UpdateAppState(tab, app_state); 349 launcher_controller()->UpdateAppState(tab, app_state);
329 } 350 }
330 351
331 ash::LauncherModel* BrowserLauncherItemController::launcher_model() { 352 ash::LauncherModel* BrowserLauncherItemController::launcher_model() {
332 return launcher_controller()->model(); 353 return launcher_controller()->model();
333 } 354 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698