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

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: Fix unit test 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 15 matching lines...) Expand all
26 #include "ui/base/resource/resource_bundle.h" 26 #include "ui/base/resource/resource_bundle.h"
27 #include "ui/views/widget/widget.h" 27 #include "ui/views/widget/widget.h"
28 28
29 using extensions::Extension; 29 using extensions::Extension;
30 30
31 BrowserLauncherItemController::BrowserLauncherItemController( 31 BrowserLauncherItemController::BrowserLauncherItemController(
32 Type type, 32 Type type,
33 aura::Window* window, 33 aura::Window* window,
34 TabStripModel* tab_model, 34 TabStripModel* tab_model,
35 ChromeLauncherController* launcher_controller, 35 ChromeLauncherController* launcher_controller,
36 const std::string& app_id) 36 const std::string& app_id,
37 const std::string& v1_app_id)
37 : LauncherItemController(type, app_id, launcher_controller), 38 : LauncherItemController(type, app_id, launcher_controller),
38 window_(window), 39 window_(window),
40 v1_app_id_(v1_app_id),
39 tab_model_(tab_model), 41 tab_model_(tab_model),
40 is_incognito_(tab_model->profile()->GetOriginalProfile() != 42 is_incognito_(tab_model->profile()->GetOriginalProfile() !=
41 tab_model->profile() && 43 tab_model->profile() &&
42 !tab_model->profile()->IsGuestSession()) { 44 !tab_model->profile()->IsGuestSession()) {
43 DCHECK(window_); 45 DCHECK(window_);
44 window_->AddObserver(this); 46 window_->AddObserver(this);
45 } 47 }
46 48
47 BrowserLauncherItemController::~BrowserLauncherItemController() { 49 BrowserLauncherItemController::~BrowserLauncherItemController() {
48 tab_model_->RemoveObserver(this); 50 tab_model_->RemoveObserver(this);
49 window_->RemoveObserver(this); 51 window_->RemoveObserver(this);
50 if (launcher_id() > 0) 52 if (launcher_id() > 0)
51 launcher_controller()->CloseLauncherItem(launcher_id()); 53 launcher_controller()->CloseLauncherItem(launcher_id());
54 if (type() == TYPE_WINDOWED_APP)
55 launcher_controller()->UnlockAppWithID(v1_app_id_);
sky 2013/02/19 17:55:56 Why do you need the lock/unlock? Shouldn't that be
Mr4D (OOO till 08-26) 2013/02/19 19:22:13 As discussed.
52 } 56 }
53 57
54 void BrowserLauncherItemController::Init() { 58 void BrowserLauncherItemController::Init() {
55 tab_model_->AddObserver(this); 59 tab_model_->AddObserver(this);
56 ash::LauncherItemStatus app_status = 60 ash::LauncherItemStatus app_status =
57 ash::wm::IsActiveWindow(window_) ? 61 ash::wm::IsActiveWindow(window_) ?
58 ash::STATUS_ACTIVE : ash::STATUS_RUNNING; 62 ash::STATUS_ACTIVE : ash::STATUS_RUNNING;
59 if (type() != TYPE_TABBED) { 63 if (type() != TYPE_TABBED && type() != TYPE_WINDOWED_APP) {
60 launcher_controller()->CreateAppLauncherItem(this, app_id(), app_status); 64 launcher_controller()->CreateAppLauncherItem(this, app_id(), app_status);
61 } else { 65 } else {
62 launcher_controller()->CreateTabbedLauncherItem( 66 launcher_controller()->CreateTabbedLauncherItem(
63 this, 67 this,
64 is_incognito_ ? ChromeLauncherController::STATE_INCOGNITO : 68 is_incognito_ ? ChromeLauncherController::STATE_INCOGNITO :
65 ChromeLauncherController::STATE_NOT_INCOGNITO, 69 ChromeLauncherController::STATE_NOT_INCOGNITO,
66 app_status); 70 app_status);
71 if (type() == TYPE_WINDOWED_APP)
72 launcher_controller()->LockAppWithID(v1_app_id_);
67 } 73 }
68 // In testing scenarios we can get tab strips with no active contents. 74 // In testing scenarios we can get tab strips with no active contents.
69 if (tab_model_->active_index() != TabStripModel::kNoTab) 75 if (tab_model_->active_index() != TabStripModel::kNoTab)
70 UpdateLauncher(tab_model_->GetActiveWebContents()); 76 UpdateLauncher(tab_model_->GetActiveWebContents());
71 } 77 }
72 78
73 // static 79 // static
74 BrowserLauncherItemController* BrowserLauncherItemController::Create( 80 BrowserLauncherItemController* BrowserLauncherItemController::Create(
75 Browser* browser) { 81 Browser* browser) {
76 // Under testing this can be called before the controller is created. 82 // Under testing this can be called before the controller is created.
77 if (!ChromeLauncherController::instance()) 83 if (!ChromeLauncherController::instance())
78 return NULL; 84 return NULL;
79 85
80 Type type; 86 Type type;
81 std::string app_id; 87 std::string app_id;
88 std::string v1_app_id;
82 if (browser->is_type_tabbed() || browser->is_type_popup()) { 89 if (browser->is_type_tabbed() || browser->is_type_popup()) {
83 type = TYPE_TABBED; 90 type = TYPE_TABBED;
91 if (!browser->is_type_tabbed() &&
92 browser->is_type_popup() &&
93 browser->is_app() &&
94 ChromeLauncherController::instance()->GetPerAppInterface()) {
95 v1_app_id = web_app::GetExtensionIdFromApplicationName(
96 browser->app_name());
97 // Only allow this for known applications. Some unit tests for example
98 // do not have one.
99 if (!v1_app_id.empty())
100 type = TYPE_WINDOWED_APP;
101 }
84 } else if (browser->is_app()) { 102 } else if (browser->is_app()) {
85 if (browser->is_type_panel()) { 103 if (browser->is_type_panel()) {
86 if (browser->app_type() == Browser::APP_TYPE_CHILD) 104 if (browser->app_type() == Browser::APP_TYPE_CHILD)
87 type = TYPE_EXTENSION_PANEL; 105 type = TYPE_EXTENSION_PANEL;
88 else 106 else
89 type = TYPE_APP_PANEL; 107 type = TYPE_APP_PANEL;
90 } else { 108 } else {
91 type = TYPE_TABBED; 109 type = TYPE_TABBED;
92 } 110 }
93 app_id = web_app::GetExtensionIdFromApplicationName(browser->app_name()); 111 app_id = web_app::GetExtensionIdFromApplicationName(browser->app_name());
94 } else { 112 } else {
95 return NULL; 113 return NULL;
96 } 114 }
97 BrowserLauncherItemController* controller = 115 BrowserLauncherItemController* controller =
98 new BrowserLauncherItemController(type, 116 new BrowserLauncherItemController(type,
99 browser->window()->GetNativeWindow(), 117 browser->window()->GetNativeWindow(),
100 browser->tab_strip_model(), 118 browser->tab_strip_model(),
101 ChromeLauncherController::instance(), 119 ChromeLauncherController::instance(),
102 app_id); 120 app_id,
121 v1_app_id);
103 controller->Init(); 122 controller->Init();
104 return controller; 123 return controller;
105 } 124 }
106 125
107 void BrowserLauncherItemController::BrowserActivationStateChanged() { 126 void BrowserLauncherItemController::BrowserActivationStateChanged() {
108 content::WebContents* active_contents = tab_model_->GetActiveWebContents(); 127 content::WebContents* active_contents = tab_model_->GetActiveWebContents();
109 if (active_contents) 128 if (active_contents)
110 UpdateAppState(active_contents); 129 UpdateAppState(active_contents);
111 UpdateItemStatus(); 130 UpdateItemStatus();
112 } 131 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 app_state = ChromeLauncherController::APP_STATE_ACTIVE; 343 app_state = ChromeLauncherController::APP_STATE_ACTIVE;
325 } else { 344 } else {
326 app_state = ChromeLauncherController::APP_STATE_INACTIVE; 345 app_state = ChromeLauncherController::APP_STATE_INACTIVE;
327 } 346 }
328 launcher_controller()->UpdateAppState(tab, app_state); 347 launcher_controller()->UpdateAppState(tab, app_state);
329 } 348 }
330 349
331 ash::LauncherModel* BrowserLauncherItemController::launcher_model() { 350 ash::LauncherModel* BrowserLauncherItemController::launcher_model() {
332 return launcher_controller()->model(); 351 return launcher_controller()->model();
333 } 352 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698